Skip to content

Commit 4cceb49

Browse files
committed
Add special accounting for pypy when computing the stack level for text encoding warnings.
Closes #114.
1 parent 2ec3ed8 commit 4cceb49

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

114.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add special accounting for pypy when computing the stack level for text encoding warnings.

zipp/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import contextlib
66
import pathlib
77
import re
8+
import sys
89

910
from .compat.py310 import text_encoding
1011
from .glob import Translator
@@ -179,8 +180,10 @@ def _name_set(self):
179180

180181

181182
def _extract_text_encoding(encoding=None, *args, **kwargs):
182-
# stacklevel=3 so that the caller of the caller see any warning.
183-
return text_encoding(encoding, 3), args, kwargs
183+
# compute stack level so that the caller of the caller sees any warning.
184+
is_pypy = sys.implementation.name == 'pypy'
185+
stack_level = 3 + is_pypy
186+
return text_encoding(encoding, stack_level), args, kwargs
184187

185188

186189
class Path:

0 commit comments

Comments
 (0)