Skip to content

Commit 7c74b50

Browse files
committed
Move workaround for #327 to _compat module
1 parent 5583567 commit 7c74b50

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v4.6.3
2+
======
3+
4+
* Moved workaround for #327 to ``_compat`` module.
5+
16
v4.6.2
27
======
38

importlib_metadata/__init__.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import email
88
import pathlib
99
import operator
10-
import platform
1110
import textwrap
1211
import warnings
1312
import functools
@@ -21,6 +20,7 @@
2120
NullFinder,
2221
PyPy_repr,
2322
install,
23+
pypy_partial,
2424
)
2525
from ._functools import method_cache
2626
from ._itertools import unique_everseen
@@ -49,16 +49,6 @@
4949
]
5050

5151

52-
def _pypy_partial(val):
53-
"""
54-
Adjust for variable stacklevel on partial under PyPy.
55-
56-
Workaround for #327.
57-
"""
58-
is_pypy = platform.python_implementation() == 'PyPy'
59-
return val + is_pypy
60-
61-
6252
class PackageNotFoundError(ModuleNotFoundError):
6353
"""The package was not found."""
6454

@@ -256,7 +246,7 @@ class DeprecatedList(list):
256246
warnings.warn,
257247
"EntryPoints list interface is deprecated. Cast to list if needed.",
258248
DeprecationWarning,
259-
stacklevel=_pypy_partial(2),
249+
stacklevel=pypy_partial(2),
260250
)
261251

262252
def __setitem__(self, *args, **kwargs):
@@ -405,7 +395,7 @@ class Deprecated:
405395
warnings.warn,
406396
"SelectableGroups dict interface is deprecated. Use select.",
407397
DeprecationWarning,
408-
stacklevel=_pypy_partial(2),
398+
stacklevel=pypy_partial(2),
409399
)
410400

411401
def __getitem__(self, name):

importlib_metadata/_compat.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import platform
23

34

45
__all__ = ['install', 'NullFinder', 'PyPy_repr', 'Protocol']
@@ -84,3 +85,13 @@ def make_param(name):
8485
if affected: # pragma: nocover
8586
__repr__ = __compat_repr__
8687
del affected
88+
89+
90+
def pypy_partial(val):
91+
"""
92+
Adjust for variable stacklevel on partial under PyPy.
93+
94+
Workaround for #327.
95+
"""
96+
is_pypy = platform.python_implementation() == 'PyPy'
97+
return val + is_pypy

0 commit comments

Comments
 (0)