8000 gh-116608: Bring back importlib.resources functional API by encukou · Pull Request #116609 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-116608: Bring back importlib.resources functional API #116609

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 12 commits into from
Apr 5, 2024
Prev Previous commit
Next Next commit
PEP-8 formatting
  • Loading branch information
encukou committed Mar 21, 2024
commit e788bf36ba290511d7b3ac26ac1c75fec05d4db6
4 changes: 2 additions & 2 deletions Lib/importlib/resources/functional.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Simplified function-based API for importlib.resources
"""
"""Simplified function-based API for importlib.resources"""

import warnings

Expand All @@ -8,6 +7,7 @@

_MISSING = object()


def open_binary(anchor, *path_names):
"""Open for binary reading the *resource* within *package*."""
return _get_resource(anchor, path_names).open('rb')
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_importlib/resources/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ModuleAnchorMixin:
from . import data02 as anchor02


class FunctionalAPIBase():
class FunctionalAPIBase:
def _gen_resourcetxt_path_parts(self):
"""Yield various names of a text file in anchor02, each in a subTest
"""
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_read_text(self):
),
'Hello, UTF-16 world!\n'.encode('utf-16').decode(
errors='backslashreplace',
)
),
)

def test_read_binary(self):
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_open_text(self):
f.read(),
'Hello, UTF-16 world!\n'.encode('utf-16').decode(
errors='backslashreplace',
)
),
)

def test_open_binary(self):
Expand Down
0