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

[mypyc] fix name generation for modules with similar full names #18001

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

aatle
Copy link
Contributor

@aatle aatle commented Oct 20, 2024

Fixes mypyc/mypyc#1071
Adds a test to cover this case

Building certain package layouts now succeeds instead of failing. The behavior for all package layouts not affected by the error is unchanged.

In namegen.make_module_translation_map(names), if argument names have "foo" and "foo.foo", all suffixes found for "foo" are also found for "foo.foo". This means that module foo has no unique suffixes, which currently causes an AssertionError.
The fix forces a module to take the last, fullest suffix if none are unique. It is guaranteed that no other module will also take the same suffix because they either will have a unique suffix to take, or they will take the fullest suffix for their name which is always going to be different.

P.S. 'suffix' or 'prefix'?

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! Looks good.

@JukkaL JukkaL merged commit 5bae05d into python:master Oct 21, 2024
12 checks passed
@aatle aatle deleted the mypyc-module-name branch November 5, 2024 01:31
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.

AssertionError when building modules with similar names
2 participants