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-38735: Don't fail when importing from / with sys.pycache_prefix set #30456

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

encukou
Copy link
Member

@encukou encukou commented Jan 7, 2022

This fixes the issue, but testing it would require putting a file in the root directory.

https://bugs.python.org/issue38735

@github-actions
Copy link

github-actions bot commented Feb 7, 2022

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 7, 2022
@serhiy-storchaka
Copy link
Member

You can test it without writing a file.

>>> from importlib.util import cache_from_source
>>> import os
>>> os.chdir('/')
>>> cache_from_source('spam.py')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    cache_from_source('spam.py')
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 558, in cache_from_source
IndexError: string index out of range

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting merge stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants