-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[WIP] make unicode vs bytes more distinct in py2 #2621
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
…arameters from str/unicode to Text, getattr/hasattr/setattr/__import__ name: unicode->Text, open() mode: unicode->Text stdlib/2/_threading_local.pyi: convert several object method parameters from str to Text ( same changes as were made to object in __builtin__.pyi ) stdlib/2/builtins.pyi: see changes to __builtin__.pyi, additionally print() sep/end: unicode->Text stdlib/2and3/logging/__init__.pyi: Logger.getChild() suffix: str->Text stdlib/2and3/unicodedata.pyi: normalize() __unistr: Text->unicode ( this is a RESTRICTIVE change - py2 pukes if you pass a str for this parameter )
…needs to include unicode now stdlib/2and3/unicodedata.pyi: pull in unicode definition for py3
… types for the rest of the files, fix issues caused by the changes in builtins
FYI there's a merge conflict. |
@@ -66,18 +66,18 @@ class classmethod(object): # Special, only valid as a decorator. | |||
|
|||
class type(object): | |||
__bases__ = ... # type: Tuple[type, ...] | |||
__name__ = ... # type: str | |||
__module__ = ... # type: str | |||
__name__ = ... # type: Text |
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.
I don't think this is correct. __name__
is always str in Python 2, not unicode.
And now there's another merge conflict and a CI failure. I'm also not sure most of the changes I checked are correct; sometimes it's really just |
I tried a couple ways and can't figure out how to overwrite type's name attribute with a unicode string, so I believe you're right, I'll make that adjustment and fix the merge conflict. |
wow, there are massive changes in master. I'm afraid I just don't have the time to maintain this fork against such volume. |
I am going to close this for now. Please reopen if you should find to work on this. |
Implementing and testing the changes suggested by gvanrossum where py2's Text is redefined as Union[bytes,unicode] and automatic str->unicode promotion is disabled.
This PR is a WIP but submitting now for CI and peer review
See the following issues for more discussion:
python/typing#208
#2609