summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-11-23 20:36:40 (GMT)
committerGitHub <noreply@github.com>2021-11-23 20:36:40 (GMT)
commitf840398a5fd8741653c26eb8641c48656c9800d4 (patch)
tree60e0df1663a23a1f4519eaa2d05d46d74ec74cc8 /Tools
parent4ae26b9c1d0c33e3db92c6f305293f9240dea358 (diff)
downloadcpython-f840398a5fd8741653c26eb8641c48656c9800d4.zip
cpython-f840398a5fd8741653c26eb8641c48656c9800d4.tar.gz
cpython-f840398a5fd8741653c26eb8641c48656c9800d4.tar.bz2
bpo-45873: Restore Python 3.6 compatibility (GH-29730)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Diffstat (limited to 'Tools')
-rw-r--r--Tools/scripts/deepfreeze.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Tools/scripts/deepfreeze.py b/Tools/scripts/deepfreeze.py
index b840c4b..e51a408 100644
--- a/Tools/scripts/deepfreeze.py
+++ b/Tools/scripts/deepfreeze.py
@@ -5,8 +5,10 @@ import collections
import contextlib
import os
import re
+import sys
import time
import types
+import unicodedata
from typing import Dict, FrozenSet, Tuple, TextIO
import umarshal
@@ -14,9 +16,13 @@ import umarshal
verbose = False
+def isprintable(b: bytes) -> bool:
+ return all(0x20 <= c < 0x7f for c in b)
+
+
def make_string_literal(b: bytes) -> str:
res = ['"']
- if b.isascii() and b.decode("ascii").isprintable():
+ if isprintable(b):
res.append(b.decode("ascii").replace("\\", "\\\\").replace("\"", "\\\""))
else:
for i in b: