-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Merge binascii module into 2and3 #1144
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
stdlib/2and3/binascii.pyi
Outdated
def a2b_uu(string: Union[Text, bytes]) -> bytes: ... | ||
def b2a_uu(data: _Bytes) -> bytes: ... | ||
def a2b_base64(string: Union[Text, bytes]) -> bytes: ... | ||
def b2a_base64(data: _Bytes) -> bytes: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has another positional-only parameter as of Python 3: newline: bool(accept={int}) = True
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add.
stdlib/2and3/binascii.pyi
Outdated
def rledecode_hqx(data: _Bytes) -> bytes: ... | ||
def rlecode_hqx(data: _Bytes) -> bytes: ... | ||
def b2a_hqx(data: _Bytes) -> bytes: ... | ||
def crc_hqx(data: _Bytes, crc: int) -> int: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argument is called oldcrc
in the Python 2 docstring, but it's positional-only so it doesn't really matter. If we want to be really precise we can make the arguments positional-only in Python 2 (and probably also pre-3.5 Python 3, but I haven't checked), but I think it's fine to ignore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's positional only in both. Technically this entire module is positonal only everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in 3.6. Presumably it was changed to use Argument Clinic at some point.
In [5]: binascii.b2a_base64(data=b'')
Out[5]: b'\n'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting. Well crc is still positional only at least in 3.6.1
>>> binascii.crc32(b'foo', crc=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: crc32() takes no keyword arguments
Also, there's some trailing whitespace (see Travis) and I just noticed that the documentation says |
stdlib/2and3/binascii.pyi
Outdated
# Python 2 accepts unicode ascii pretty much everywhere. | ||
_Bytes = Union[bytes, Text] | ||
_Ascii = Union[bytes, Text] | ||
elif sys.version_info <= (3, 2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be < (3, 3)
. But we're probably going to drop 3.2 support anyway (#1145).
Kept the python 3 version but modified it so that python 2 also accepts unicode strings.