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

bpo-33689: Blank lines in .pth file cause a duplicate sys.path entry #20679

Merged
merged 8 commits into from Sep 19, 2020

Conversation

idomic
Copy link
Contributor

@idomic idomic commented Jun 6, 2020

Copy link
Contributor

@taleinat taleinat left a comment

Looking good, a few minor notes.

@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
Copy link
Contributor

@taleinat taleinat Jun 8, 2020

Choose a reason for hiding this comment

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

This seems unused?

Copy link
Contributor Author

@idomic idomic Jun 20, 2020

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`
Copy link
Contributor

@taleinat taleinat Jun 8, 2020

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".

Copy link
Contributor

@taleinat taleinat Jun 8, 2020

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.

Copy link
Contributor Author

@idomic idomic Jun 20, 2020

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.

# 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)
Copy link
Contributor

@taleinat taleinat Jun 8, 2020

Choose a reason for hiding this comment

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

Suggested change
self.assertEqual(len(known_paths), 0)
self.assertEqual(known_paths, set())

Copy link
Contributor Author

@idomic idomic Jun 20, 2020

Choose a reason for hiding this comment

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

fixed

@bedevere-bot
Copy link

bedevere-bot commented Jun 8, 2020

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. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@idomic
Copy link
Contributor Author

idomic commented Jun 20, 2020

I have made the requested changes; please review again

@bedevere-bot
Copy link

bedevere-bot commented Jun 20, 2020

Thanks for making the requested changes!

@taleinat: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from taleinat Jun 20, 2020
@idomic
Copy link
Contributor Author

idomic commented Jun 27, 2020

@taleinat ping

Copy link
Contributor

@taleinat taleinat left a comment

LGTM

@taleinat taleinat added the type-bug An unexpected behavior, bug, or error label Sep 19, 2020
@taleinat
Copy link
Contributor

taleinat commented Sep 19, 2020

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.

@taleinat taleinat merged commit 0c71a66 into python:master Sep 19, 2020
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants