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
bpo-38347: find Python scripts whose name contain a '-' #16536
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
This requires a bigger amount of work since the ability of pathfix.py to recursively search a directory is not tested at all currently. But the issue only happens in this case. If you specify an explicit filename on command line with '-' in the name things work fine. |
It sounds like a nice enhancement to write a test for this code path. By the way, I don't see the point of using a regex to match the filename. Why not only checking for the ".py" suffix? |
I tried to keep the changes to a minimum. Of course it can be changed to allow all filenames that just have the .py suffix. I can adjust this. Whatever preference you have :-) |
The regex is quite old:
I don't see any rationale for rejecting filenames which don't match '^[a-zA-Z0-9_]+.py$', I suggest to only check for the suffix. |
By the way, please add a NEWS entry using the Python tool "blurb" ("python3 -m pip install --user blurb" then run "blurb"). |
I already did: 7aa6c09 |
Test case created (05f15f8). I hope the code is not too weird. |
Done in 0c1e65c |
Allow Python scripts to contain a '-' in their filename when working recursively.
Assume all files that end on '.py' are Python scripts when working recursively.
Add a test case for the recursive search including filenames with a '-'.
Fix a test failure on Windows by using os.sep instead of the Unix specific '/' as path separator.
Misc/NEWS.d/next/Tests/2019-10-02-12-27-58.bpo-38347.zdkCBX.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Tools/Demos/2019-10-02-09-48-42.bpo-38347.2Tq5D1.rst
Outdated
Show resolved
Hide resolved
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I see that you updated your PR, but setUp() still creates a temporary directory (I asked to move that into the test_recursive() method), there is still "**kwargs", and now test_recursive() inspects self to call other functions... I don't understand what you are trying to do.
My expectation is that test_recursive() creates a temporary directory which contains one ".py" file which has a shebang, you can pathfix on the directory, and then you check that the .py file shebang is updated.
Please don't try to magically make other test methods work on a temporary directory. I prefer simple tests.
After reverting the previous changes to |
Use local variables with better names instead of class attributes.
Misc/NEWS.d/next/Tools/Demos/2019-10-02-09-48-42.bpo-38347.2Tq5D1.rst
Outdated
Show resolved
Hide resolved
Co-Authored-By: Victor Stinner <vstinner@python.org>
The Azure failure seems to be caused by the inability to download OpenSSL sources for the Ubuntu tests. Maybe a temporary network issue on Azure / Openssl side. I would like to reexecute the Azure pipeline, but I don't know how. |
I closed/reopened the PR to schedule a new Azure Pipelines run. |
LGTM, but please fix the typo. It seems like I'm not allowed to push into your branch.
…ythonGH-16536) pathfix.py: Assume all files that end on '.py' are Python scripts when working recursively. (cherry picked from commit 2b7dc40) Co-authored-by: Ruediger Pluem <r.pluem@gmx.de>
GH-16718 is a backport of this pull request to the 3.8 branch. |
…ythonGH-16536) pathfix.py: Assume all files that end on '.py' are Python scripts when working recursively.
Allow Python scripts to contain a '-' in their filename when working
recursively.
https://bugs.python.org/issue38347