Skip to content

Conversation

scoder
Copy link
Contributor

@scoder scoder commented Aug 30, 2024

  • Rename 'unicode' and 'basestring' to 'str' internally.
  • Remove legacy code that dealt with the mixed Py2 string types.
  • Keep recognising the names in (legacy) code.

Closes #1370
Closes #5854

scoder added 3 commits August 30, 2024 06:22
Remove legacy code that dealt with the mixed Py2 string types.
Keep recognising the names in (legacy) code.

Closes cython#1370
Closes cython#5854
@scoder scoder added this to the 3.1 milestone Aug 30, 2024
@scoder
Copy link
Contributor Author

scoder commented Aug 30, 2024

The first two commits are loosely related and just happened along the way.

if name == 'long' and language_level == 2:
def lookup(self, name, language_level=None):
# 'language_level' is passed by ModuleScope
if name == 'unicode' or name == 'basestring':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how useful it is to map basestring to anything. In that if I've got some legacy code with ininstance(something, basestring) I'd expect it to match either str or bytes in Python 3.

I don't think it's worth the effort of making it work, but I also don't know if it's worth keeping around an incorrect mapping that only does half of what it should.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basestring always mapped to only str in Py3. It only included bytes in Py2, because that used to be str there.

I kept the name purely to avoid breaking existing code that uses it correctly. It might be worth adding a warning about the usage, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough - if it's been that way for a while then it probably makes sense to keep it like that.

@scoder
Copy link
Contributor Author

scoder commented Aug 31, 2024

@da-woods are you generally ok with a change of this size and effect? It's somewhat mitigated by keeping unicode and basestring as names, but it's definitely user visible. Hopefully in a good way.

@da-woods
Copy link
Contributor

are you generally ok with a change of this size and effect?

Yeah - seems like the right time to do it I think.

@scoder scoder merged commit 2a2c983 into cython:master Sep 1, 2024
68 checks passed
@scoder scoder deleted the remove_py2_str branch September 1, 2024 08:58
@scoder
Copy link
Contributor Author

scoder commented Sep 1, 2024

I think this was the last major brick for Cython 3.1. Let's see what else wants to go in before we can release the first alpha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decide how to represent the str type internally Py3 mode renames "str" type to "unicode" in auto-embedded signature
2 participants