diff options
author | Christian Heimes <christian@python.org> | 2021-11-23 20:36:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 20:36:40 (GMT) |
commit | f840398a5fd8741653c26eb8641c48656c9800d4 (patch) | |
tree | 60e0df1663a23a1f4519eaa2d05d46d74ec74cc8 /Tools | |
parent | 4ae26b9c1d0c33e3db92c6f305293f9240dea358 (diff) | |
download | cpython-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.py | 8 |
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: |