Skip to content

Commit 653e3c8

Browse files
committed
Move text_encoding compatibility to its own module.
1 parent 92dc242 commit 653e3c8

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

zipp/__init__.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
import io
2-
import sys
32
import posixpath
43
import zipfile
54
import itertools
65
import contextlib
76
import pathlib
87

8+
from .py310compat import text_encoding
99

10-
__all__ = ['Path']
11-
12-
13-
te_impl = 'lambda encoding, stacklevel=2, /: encoding'
14-
te_impl_37 = te_impl.replace(', /', '')
15-
_text_encoding = eval(te_impl if sys.version_info > (3, 8) else te_impl_37)
1610

17-
18-
text_encoding = (
19-
io.text_encoding if sys.version_info > (3, 10) else _text_encoding # type: ignore
20-
)
11+
__all__ = ['Path']
2112

2213

2314
def _parents(path):

zipp/py310compat.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import sys
2+
import io
3+
4+
5+
te_impl = 'lambda encoding, stacklevel=2, /: encoding'
6+
te_impl_37 = te_impl.replace(', /', '')
7+
_text_encoding = eval(te_impl) if sys.version_info > (3, 8) else eval(te_impl_37)
8+
9+
10+
text_encoding = (
11+
io.text_encoding if sys.version_info > (3, 10) else _text_encoding # type: ignore
12+
)

0 commit comments

Comments
 (0)