gh-105931: Fix surprising compileall stripdir behaviour#108671
Merged
encukou merged 2 commits intopython:mainfrom Oct 23, 2023
Merged
gh-105931: Fix surprising compileall stripdir behaviour#108671encukou merged 2 commits intopython:mainfrom
encukou merged 2 commits intopython:mainfrom
Conversation
This resolves issue python#105931. Currently the '-s STRIPDIR' option on compileall can lead to some surprising results as it only strips away path components that match, but leaves alone the non-matching ones interspersed in between. For example, with: python -m compileall -s/path/to/another/src /path/to/build/src/file.py The resulting written path will be: build/file.py This fix only strips directories that are a fully matching prefix of the source path. If a stripdir is provided that is not a valid prefix, a warning will be displayed (which can be silenced with '-qq').
Contributor
frenzymadness
left a comment
There was a problem hiding this comment.
I like the simplicity of the solution and I have just one suggestion. I'm not a core developer so we'll need someone to approve and merge this, Cc: @encukou (helped with the original implementation so he has the necessary context).
Contributor
|
@encukou could you please help us to move this forward? |
encukou
approved these changes
Oct 23, 2023
Member
encukou
left a comment
There was a problem hiding this comment.
The original behaviour is clearly wrong.
IMO, we don't need a deprecation period to change it: the filename is essentially debug information.
I don't plan to backport to this to previous versions (at least initially): new warnings/outputs tend to cause trouble for users.
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
…GH-108671) Before, the '-s STRIPDIR' option on compileall lead to some surprising results as it only strips away path components that match, but leaves alone the non-matching ones interspersed in between. For example, with: python -m compileall -s/path/to/another/src /path/to/build/src/file.py The resulting written path will be: build/file.py This fix only strips directories that are a fully matching prefix of the source path. If a stripdir is provided that is not a valid prefix, a warning will be displayed (which can be silenced with '-qq').
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this pull request
Sep 2, 2024
…GH-108671) Before, the '-s STRIPDIR' option on compileall lead to some surprising results as it only strips away path components that match, but leaves alone the non-matching ones interspersed in between. For example, with: python -m compileall -s/path/to/another/src /path/to/build/src/file.py The resulting written path will be: build/file.py This fix only strips directories that are a fully matching prefix of the source path. If a stripdir is provided that is not a valid prefix, a warning will be displayed (which can be silenced with '-qq').
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This resolves issue #105931. Currently the '-s STRIPDIR' option on compileall can lead to some surprising results as it only strips away path components that match, but leaves alone the non-matching ones interspersed in between.
For example, with: python -m compileall -s/path/to/another/src /path/to/build/src/file.py
The resulting written path will be: build/file.py
This fix only strips directories that are a fully matching prefix of the source path. If a stripdir is provided that is not a valid prefix, a warning will be displayed (which can be silenced with '-qq').