-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
bpo-33689: Blank lines in .pth file cause a duplicate sys.path entry #20679
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, a few minor notes.
Lib/test/test_site.py
Outdated
@classmethod | ||
def _calc_sys_path_for_underpth_nosite(self, sys_prefix, lines): | ||
sys_path = [] | ||
for line in lines: | ||
if not line or line[0] == '#': | ||
continue | ||
abs_path = os.path.abspath(os.path.join(sys_prefix, line)) | ||
sys_path.append(abs_path) | ||
return sys_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right removed it.
I couldn't find where to put the last parts of it: https://bugs.python.org/file46433/underpth_blank_lines.diff
@@ -0,0 +1,2 @@ | |||
Added support for empty .pth lines in the :mod:`site.py` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a bugfix rather than a new feature, I'd re-word this as something like "ignore empty or whitespace-only lines".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also mention that this is what the documentation already says.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed to:
Ignore empty or whitespace-only lines according to the existing documentation.
Lib/test/test_site.py
Outdated
# Issue 33689 | ||
pth_dir, pth_fn = self.make_pth("\n\n \n\n") | ||
known_paths = site.addpackage(pth_dir, pth_fn, set()) | ||
self.assertEqual(len(known_paths), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.assertEqual(len(known_paths), 0) | |
self.assertEqual(known_paths, set()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
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 have made the requested changes; please review again |
Thanks for making the requested changes! @taleinat: please review the changes made to this pull request. |
@taleinat ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is certainly a bug fix, but since it may break backwards-compatibility in delicate ways, I'm not going to backport it to earlier versions. Expect this to land in 3.10. |
https://bugs.python.org/issue33689