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

importlib.resources.read_text() raises FileNotFound #90184

Closed
Zac-HD mannequin opened this issue Dec 9, 2021 · 3 comments
Closed

importlib.resources.read_text() raises FileNotFound #90184

Zac-HD mannequin opened this issue Dec 9, 2021 · 3 comments
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Zac-HD
Copy link
Mannequin

Zac-HD mannequin commented Dec 9, 2021

BPO 46026
Nosy @warsaw, @brettcannon, @jaraco, @Zac-HD

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:

assignee = None
closed_at = None
created_at = <Date 2021-12-09.11:22:12.324>
labels = ['type-bug', 'library', '3.11']
title = 'importlib.resources.read_text() raises FileNotFound'
updated_at = <Date 2021-12-09.11:23:59.697>
user = 'https://github.com/Zac-HD'

bugs.python.org fields:

activity = <Date 2021-12-09.11:23:59.697>
actor = 'Zac Hatfield-Dodds'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-12-09.11:22:12.324>
creator = 'Zac Hatfield-Dodds'
dependencies = []
files = []
hgrepos = []
issue_num = 46026
keywords = []
message_count = 2.0
messages = ['408107', '408108']
nosy_count = 4.0
nosy_names = ['barry', 'brett.cannon', 'jaraco', 'Zac Hatfield-Dodds']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue46026'
versions = ['Python 3.11']

@Zac-HD
Copy link
Mannequin Author

Zac-HD mannequin commented Dec 9, 2021

Testing Hypothesis with Python 3.11.0a3, I've triggered a frustrating regression in importlib.resources:

# Both work in Python 3.9 and 3.10, but both fail in 3.11.0a3
from importlib.resources import files, read_text
read_text("hypothesis.vendor", "tlds-alpha-by-domain.txt")
files("hypothesis.vendor").joinpath("tlds-alpha-by-domain.txt").read_text()
Traceback (most recent call last):
  ...
  File "example.py", line 4, in <module>
    read_text("hypothesis.vendor", "tlds-alpha-by-domain.txt")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/importlib/_legacy.py", line 25, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/importlib/_legacy.py", line 67, in read_text
    with open_text(package, resource, encoding, errors) as fp:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/importlib/_legacy.py", line 25, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/importlib/_legacy.py", line 50, in open_text
    return (_common.files(package) / _common.normalize_path(resource)).open(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/importlib/_adapters.py", line 141, in open
    raise FileNotFoundError("Can't open orphan path")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Can't open orphan path

At first I thought this was just a problem with the _legacy shims, but since it also affects the new files() API it might be more serious.

@Zac-HD Zac-HD mannequin added 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 9, 2021
@Zac-HD
Copy link
Mannequin Author

Zac-HD mannequin commented Dec 9, 2021

This may have appeared in the wild, via the backport, in

Nuitka/Nuitka#1274 and
Nuitka/Nuitka@ffe861c

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@Zac-HD
Copy link
Contributor

Zac-HD commented Apr 16, 2022

This issue has been fixed in more recent alphas and can therefore be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants