Skip to content

Commit

Permalink
Add special accounting for pypy when computing the stack level for te…
Browse files Browse the repository at this point in the history
…xt encoding warnings.

Closes #114.
  • Loading branch information
jaraco committed Mar 13, 2024
1 parent 2ec3ed8 commit 4cceb49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions 114.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add special accounting for pypy when computing the stack level for text encoding warnings.
7 changes: 5 additions & 2 deletions zipp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import contextlib
import pathlib
import re
import sys

from .compat.py310 import text_encoding
from .glob import Translator
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4cceb49

Please sign in to comment.