You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importlib_metadata 3.9 introduced this deprecation. As you can see in the call, the warning is issued with a stacklevel of 2, and on CPython, this stack level causes the warning to attach to the correct caller of the deprecated methods. On PyPy, however, the call stack is different and thus the errors can't be ignored based on the module where the usage occurs.
Run it with CPython and it passes, but run it with PyPy and it fails with:
Traceback (most recent call last):
File "test_suppress_warning.py", line 18, in <module>
__name__ == '__main__' and main()
File "test_suppress_warning.py", line 15, in main
lookup()
File "test_suppress_warning.py", line 9, in lookup
md.entry_points().get('foo')
File "/usr/local/Cellar/pypy3/7.3.4/libexec/site-packages/importlib_metadata/__init__.py", line 405, in get
self._warn()
File "/usr/local/Cellar/pypy3/7.3.4/libexec/lib_pypy/_functools.py", line 80, in __call__
return self._func(*(self._args + fargs), **fkeywords)
DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
The exception occurs because the 'ignore' filter failed to match the caller's module.
The issue can be replicated without importlib_metadata with these two files:
Run pypy test.py and it fails, but succeeds on CPython.
Traceback (most recent call last):
File "test_suppress_warning.py", line 12, in <module>
__name__ == '__main__' and main()
File "test_suppress_warning.py", line 9, in main
lookup()
File "/Users/jaraco/code/public/pypa/setuptools/other.py", line 13, in lookup
do_warn()
File "/usr/local/Cellar/pypy3/7.3.4/libexec/lib_pypy/_functools.py", line 80, in __call__
return self._func(*(self._args + fargs), **fkeywords)
DeprecationWarning: Do something else
The impact of this mismatch is that users wishing to suppress this deprecation warning are unable to do so consistently across CPython and PyPy and moreover are unable to address the deprecation warning by caller (the module always looks like importlib_metadata on PyPy).
Is there anything to be done?
The text was updated successfully, but these errors were encountered:
I'm still interested in feedback on the underlying behavior. Is it something that PyPy would want to address? I'm not even sure I know how it could. Happy to answer questions or explore solutions.
In Heptapod by @jaraco on Jul 4, 2021, 23:53
importlib_metadata 3.9 introduced this deprecation. As you can see in the call, the warning is issued with a stacklevel of 2, and on CPython, this stack level causes the warning to attach to the correct caller of the deprecated methods. On PyPy, however, the call stack is different and thus the errors can't be ignored based on the module where the usage occurs.
I've replicated the issue with this script:
Run it with CPython and it passes, but run it with PyPy and it fails with:
The exception occurs because the 'ignore' filter failed to match the caller's module.
The issue can be replicated without importlib_metadata with these two files:
Run
pypy test.py
and it fails, but succeeds on CPython.The impact of this mismatch is that users wishing to suppress this deprecation warning are unable to do so consistently across CPython and PyPy and moreover are unable to address the deprecation warning by caller (the module always looks like
importlib_metadata
on PyPy).Is there anything to be done?
The text was updated successfully, but these errors were encountered: