Repository navigation
Honour character ranges in MANIFEST.in exclude patterns - #5374
andrewstellman wants to merge 3 commits into
Conversation
translate_pattern escaped the inside of a [...] class with re.escape, so "-" was literal and [a-c] matched only "a", "-" and "c".
agammann
left a comment
There was a problem hiding this comment.
The global hyphen replacement also turns a reversed class such as key[z-a].pem into the regex [z-a], which re.compile rejects as a bad character range. Before this change the hyphen was escaped, so this pattern did not abort MANIFEST.in file-list generation. Could the translator handle invalid range endpoints without an uncaught regex error, with a regression for this case? I reviewed the current diff; I did not run the test suite locally.
Like fnmatch, a reversed range such as [z-a] now matches nothing instead of raising re.error.
|
@agammann Thanks, good catch. Reversed ranges are now dropped the way fnmatch drops them, so key[z-a].pem matches nothing instead of raising, [!z-a] matches any character and [z-ab] still matches b. All three are in translate_specs. I also renamed the news fragment to the PR number. |
|
Thanks for the update. I rechecked head |
Summary of changes
With
graft keysandexclude keys/[a-z].pemin MANIFEST.in, the sdist still containskeys/b.pem.translate_patternpasses the inside of a[...]class throughre.escape, so-is literal and[a-c]matches onlya,-andc, although the docs say ranges such as[a-z]are supported andincludehonours them. The fix leaves-unescaped inside the class, and two newtranslate_specsentries cover[a-c]and[!a-c].Found with the Quality Playbook, an AI code-review tool I maintain. The fix and test were written with AI assistance and reviewed by me.
Pull Request Checklist
newsfragments/.