Skip to content

[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

Closed
wants to merge 5 commits into from
Closed

[WIP] make unicode vs bytes more distinct in py2 #2621

wants to merge 5 commits into from

Conversation

remdragon
Copy link

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

…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
@JelleZijlstra
Copy link
Member

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
Copy link
Member

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.

@JelleZijlstra
Copy link
Member

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 str.

@remdragon
Copy link
Author

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.

@remdragon
Copy link
Author

wow, there are massive changes in master. I'm afraid I just don't have the time to maintain this fork against such volume.

@srittau
Copy link
Collaborator

srittau commented May 8, 2019

I am going to close this for now. Please reopen if you should find to work on this.

@srittau srittau closed this May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants