Skip to content

Commit a30578e

Browse files
committed
Add workaround for CPython bug
1 parent 8031953 commit a30578e

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎src/manage/__init__.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
################################################################################
2+
# HACK: Work around gh-148750 in 3.15
3+
# In short, encodings is now partially frozen, which means its submodules can
4+
# only be loaded if they are also frozen or if they are in their default
5+
# location relative to the executable. For embedded runtimes, this is not true,
6+
# so we need to patch the __path__ to point at our expected location.
7+
# This code is very fragile and should not be reused.
8+
import sys
9+
import encodings
10+
for p in sys.path:
11+
if p.endswith(".zip"):
12+
encodings.__path__[:] = [f"{p}\\encodings"]
13+
break
14+
################################################################################
15+
116
from .exceptions import (
217
ArgumentError,
318
AutomaticInstallDisabledError,

0 commit comments

Comments
 (0)