Skip to content

Stdlib binascii #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 66 additions & 6 deletions py/args.go
Original file line number Diff line number Diff line change
@@ -465,17 +465,77 @@ func ParseTupleAndKeywords(args Tuple, kwargs StringDict, format string, kwlist
switch op.code {
case 'O':
*result = arg
case 'Z', 'z':
if _, ok := arg.(NoneType); ok {
*result = arg
break
case 'Z':
switch op.modifier {
default:
return ExceptionNewf(TypeError, "%s() argument %d must be str or None, not %s", name, i+1, arg.Type().Name)
case '#', 0:
switch arg := arg.(type) {
case String, NoneType:
default:
return ExceptionNewf(TypeError, "%s() argument %d must be str or None, not %s", name, i+1, arg.Type().Name)
}
}
*result = arg
case 'z':
switch op.modifier {
default:
switch arg := arg.(type) {
case String, NoneType:
// ok
default:
return ExceptionNewf(TypeError, "%s() argument %d must be str or None, not %s", name, i+1, arg.Type().Name)
}
case '#':
fallthrough // FIXME(sbinet): check for read-only?
case '*':
switch arg := arg.(type) {
case String, Bytes, NoneType:
// ok.
default:
return ExceptionNewf(TypeError, "%s() argument %d must be str, bytes-like or None, not %s", name, i+1, arg.Type().Name)
}
}
fallthrough
case 'U', 's':
*result = arg
case 'U':
if _, ok := arg.(String); !ok {
return ExceptionNewf(TypeError, "%s() argument %d must be str, not %s", name, i+1, arg.Type().Name)
}
*result = arg
case 's':
switch op.modifier {
default:
if _, ok := arg.(String); !ok {
return ExceptionNewf(TypeError, "%s() argument %d must be str, not %s", name, i+1, arg.Type().Name)
}
case '#':
fallthrough // FIXME(sbinet): check for read-only?
case '*':
switch arg := arg.(type) {
case String, Bytes:
// ok.
default:
return ExceptionNewf(TypeError, "%s() argument %d must be str or bytes-like, not %s", name, i+1, arg.Type().Name)
}
}
*result = arg
case 'y':
switch op.modifier {
default:
if _, ok := arg.(Bytes); !ok {
return ExceptionNewf(TypeError, "%s() argument %d must be bytes-like, not %s", name, i+1, arg.Type().Name)
}
case '#':
fallthrough // FIXME(sbinet): check for read-only?
case '*':
switch arg := arg.(type) {
case Bytes:
// ok.
default:
return ExceptionNewf(TypeError, "%s() argument %d must be bytes-like, not %s", name, i+1, arg.Type().Name)
}
}
*result = arg
case 'i', 'n':
if _, ok := arg.(Int); !ok {
return ExceptionNewf(TypeError, "%s() argument %d must be int, not %s", name, i+1, arg.Type().Name)
Loading