-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
py_compile: foo.bar.py → __pycache__/foo.cpython-34.pyc #67155
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
Comments
when py_compile module is asked to create .pyc file for file with invalid name, it doesn't fail or ignore such request - it creates/overwrites .pyc file for sane file name (i.e. ignores everything after dot) $ touch foo.bar.py
$ python3.4 -m py_compile foo.bar.py
$ ls __pycache__
foo.cpython-34.pyc Even though foo.bar.py is not a valid file name, some programmers are using such names for plugins which leads to bugs similar to https://lists.debian.org/debian-python/2014/11/msg00061.html. I will update my scripts to not feed py_compile module with file names containing dot (and remove already generated .pyc files if such files are detected), but please do not generate them or generate .pyc files with invalid file names as well. |
Python 3.2 generates foo.bar.cpython-32.pyc so it's a regression |
And, therefore, a missing test :(. This probably snuck in when we refactored the CLI. |
seen as well with 3.3 |
proposed patch: diff -r 8dacb1a21793 Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py Fri Nov 28 13:15:41 2014 +0100
+++ b/Lib/importlib/_bootstrap.py Mon Dec 01 17:05:00 2014 +0100
@@ -453,7 +453,7 @@
else:
suffixes = OPTIMIZED_BYTECODE_SUFFIXES
head, tail = _path_split(path)
- base_filename, sep, _ = tail.partition('.')
+ base_filename, sep, _ = tail.rpartition('.')
tag = sys.implementation.cache_tag
if tag is None:
raise NotImplementedError('sys.implementation.cache_tag is None') |
I'll take this one. I think it should be easy to add a test case, which I'll do. |
Not counting importlib.h, here's the diff I'm going to apply to 3.4. It passes all the existing tests and includes a new test for this behavior. |
New changeset 269bf37a57a1 by Barry Warsaw in branch '3.4':
New changeset 3b3ba38d503a by Barry Warsaw in branch '3.4':
New changeset 25113281d543 by Barry Warsaw in branch 'default':
|
Apparently this broke under Windows: http://buildbot.python.org/all/builders/x86%20Windows7%203.x/builds/8999/steps/test/logs/stdio |
I already pushed a fix. (although asyncio is still failing there but that should be unrelated) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: