Skip to content

bpo-24960: use pkgutil.get_data in lib2to3 to read pickled grammar files #4977

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

Merged
merged 1 commit into from
Dec 22, 2017

Conversation

benjaminp
Copy link
Contributor

@benjaminp benjaminp commented Dec 22, 2017

This is more complicated than it should be because we need to preserve the
useful mtime-based regeneration feature that lib2to3.pgen2.driver.load_grammar
has. We only look for the pickled grammar file with pkgutil.get_data and only if
the source file does not exist.

https://bugs.python.org/issue24960

This is more complicated than it should be because we need to preserve the
useful mtime-based regeneration feature that lib2to3.pgen2.driver.load_grammar
has. We only look for the pickled grammar file with pkgutil.get_data and only if
the source file does not exist.
@gpshead
Copy link
Member

gpshead commented Dec 22, 2017

Should this ultimately use importlib.resources (landing soon, right @brettcannon @warsaw?) in 3.7?

Copy link
Member

@gpshead gpshead left a comment

Choose a reason for hiding this comment

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

As is I believe this is correct. Don't let the importlib.resources question hold you back, as this is the form the change will need backporting to 3.6 and 2.7 in anyways.

@benjaminp benjaminp merged commit 8a58771 into master Dec 22, 2017
@miss-islington
Copy link
Contributor

Thanks @benjaminp for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6.
🐍🍒⛏🤖

@benjaminp benjaminp deleted the benjamin-2to3-pickle branch December 22, 2017 20:18
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 22, 2017
…les (pythonGH-4977)

This is more complicated than it should be because we need to preserve the
useful mtime-based regeneration feature that lib2to3.pgen2.driver.load_grammar
has. We only look for the pickled grammar file with pkgutil.get_data and only if
the source file does not exist.
(cherry picked from commit 8a58771)
@bedevere-bot
Copy link

GH-4979 is a backport of this pull request to the 3.6 branch.

@miss-islington
Copy link
Contributor

Sorry, @benjaminp, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 8a5877165e993afb2633cd48da5222326d3f6e0e 2.7

@bedevere-bot
Copy link

GH-4980 is a backport of this pull request to the 2.7 branch.

benjaminp added a commit that referenced this pull request Dec 22, 2017
…mar files (GH-4977)

This is more complicated than it should be because we need to preserve the
useful mtime-based regeneration feature that lib2to3.pgen2.driver.load_grammar
has. We only look for the pickled grammar file with pkgutil.get_data and only if
the source file does not exist..
(cherry picked from commit 8a58771)
benjaminp pushed a commit that referenced this pull request Dec 22, 2017
…les (GH-4977) (#4979)

This is more complicated than it should be because we need to preserve the
useful mtime-based regeneration feature that lib2to3.pgen2.driver.load_grammar
has. We only look for the pickled grammar file with pkgutil.get_data and only if
the source file does not exist.
(cherry picked from commit 8a58771)
benjaminp added a commit that referenced this pull request Dec 22, 2017
…mar files (GH-4977) (#4980)

This is more complicated than it should be because we need to preserve the
useful mtime-based regeneration feature that lib2to3.pgen2.driver.load_grammar
has. We only look for the pickled grammar file with pkgutil.get_data and only if
the source file does not exist..
(cherry picked from commit 8a58771)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants