diff --git a/114.bugfix.rst b/114.bugfix.rst new file mode 100644 index 0000000..fb6fc40 --- /dev/null +++ b/114.bugfix.rst @@ -0,0 +1 @@ +Add special accounting for pypy when computing the stack level for text encoding warnings. \ No newline at end of file diff --git a/zipp/__init__.py b/zipp/__init__.py index a1b9884..093b1e0 100644 --- a/zipp/__init__.py +++ b/zipp/__init__.py @@ -5,6 +5,7 @@ import contextlib import pathlib import re +import sys from .compat.py310 import text_encoding from .glob import Translator @@ -179,8 +180,10 @@ def _name_set(self): def _extract_text_encoding(encoding=None, *args, **kwargs): - # stacklevel=3 so that the caller of the caller see any warning. - return text_encoding(encoding, 3), args, kwargs + # compute stack level so that the caller of the caller sees any warning. + is_pypy = sys.implementation.name == 'pypy' + stack_level = 3 + is_pypy + return text_encoding(encoding, stack_level), args, kwargs class Path: