Skip to content

Commit

Permalink
Move text_encoding compatibility to its own module.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Oct 24, 2022
1 parent 92dc242 commit 653e3c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
13 changes: 2 additions & 11 deletions zipp/__init__.py
@@ -1,23 +1,14 @@
import io
import sys
import posixpath
import zipfile
import itertools
import contextlib
import pathlib

from .py310compat import text_encoding

__all__ = ['Path']


te_impl = 'lambda encoding, stacklevel=2, /: encoding'
te_impl_37 = te_impl.replace(', /', '')
_text_encoding = eval(te_impl if sys.version_info > (3, 8) else te_impl_37)


text_encoding = (
io.text_encoding if sys.version_info > (3, 10) else _text_encoding # type: ignore
)
__all__ = ['Path']


def _parents(path):
Expand Down
12 changes: 12 additions & 0 deletions zipp/py310compat.py
@@ -0,0 +1,12 @@
import sys
import io


te_impl = 'lambda encoding, stacklevel=2, /: encoding'
te_impl_37 = te_impl.replace(', /', '')
_text_encoding = eval(te_impl) if sys.version_info > (3, 8) else eval(te_impl_37)


text_encoding = (
io.text_encoding if sys.version_info > (3, 10) else _text_encoding # type: ignore
)

0 comments on commit 653e3c8

Please sign in to comment.