Skip to content
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

Error in unicode entry scripts #252

Open
julienmalard opened this issue Dec 8, 2024 · 6 comments · May be fixed by #254
Open

Error in unicode entry scripts #252

julienmalard opened this issue Dec 8, 2024 · 6 comments · May be fixed by #254

Comments

@julienmalard
Copy link

In utils.py, the _ENTRYPOINT_REGEX regex does not recognise valid unicode Python identifiers (https://peps.python.org/pep-3131/), preventing the use of non-ascii file paths as entry points. Using the regex module as a drop-in replacement for re would solve this issue; please let me know if you would like me to submit a pull request.

@eli-schwartz
Copy link
Contributor

Using the regex module as a drop-in replacement for re would solve this issue

This would be quite problematic since a major feature of this package was that it has no dependencies and can run purely based on the stdlib, making it suitable as the very bottom package in an ecosystem bootstrap.

It would also prevent being vendored into pip, though that is less about having dependencies and more about having dependencies that have a binary component.

@uranusjr
Copy link
Member

uranusjr commented Dec 9, 2024

Do we even need a regex engine though? The spec basically just requires splitting on the first equal sign, and checking some leading and trailing special characters. It can be hand-rolled.

@julienmalard
Copy link
Author

Interesting...would something using the following functions to check for valid identifiers be useful?
If so, I could make a pull request.

def isalnum(x):
    if len(x) != 1:
        return all(isalnum(y) for y in x)
    return unicodedata.category(x) in ['Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl', 'Mn', 'Mc', 'Nd', 'Pc']


def isalpha(x):
    if len(x) != 1:
        return all(isalpha(y) for y in x)
    return unicodedata.category(x) in ['Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Mn', 'Mc', 'Pc']

@eli-schwartz
Copy link
Contributor

Valid identifiers can be determined via x.isidentifier(), presumably.

@julienmalard julienmalard linked a pull request Dec 14, 2024 that will close this issue
@julienmalard
Copy link
Author

Reproduced here (pull request with failing tests): https://github.com/pypa/installer/actions/runs/12326732550?pr=254

@julienmalard
Copy link
Author

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 a pull request may close this issue.

3 participants