aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Lib/pickletools.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-12-23 19:39:02 +0300
committershadchin <shadchin@yandex-team.com>2024-12-23 19:54:20 +0300
commit65a5bf9d37a3b29eb394f560b9a09318196c40e8 (patch)
treee5cd68fb0682b2388e52d9806bb87adc348e21a8 /contrib/tools/python3/Lib/pickletools.py
parenta1dd87a52878ab3e46e5fd2dba5ecbba6113d7e0 (diff)
downloadydb-65a5bf9d37a3b29eb394f560b9a09318196c40e8.tar.gz
Update Python 3 to 3.12.8
commit_hash:c20045b8a987d8720e1f3328270357491d5530f3
Diffstat (limited to 'contrib/tools/python3/Lib/pickletools.py')
-rw-r--r--contrib/tools/python3/Lib/pickletools.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/contrib/tools/python3/Lib/pickletools.py b/contrib/tools/python3/Lib/pickletools.py
index 51ee4a7a26..33a51492ea 100644
--- a/contrib/tools/python3/Lib/pickletools.py
+++ b/contrib/tools/python3/Lib/pickletools.py
@@ -312,7 +312,7 @@ uint8 = ArgumentDescriptor(
doc="Eight-byte unsigned integer, little-endian.")
-def read_stringnl(f, decode=True, stripquotes=True):
+def read_stringnl(f, decode=True, stripquotes=True, *, encoding='latin-1'):
r"""
>>> import io
>>> read_stringnl(io.BytesIO(b"'abcd'\nefg\n"))
@@ -356,7 +356,7 @@ def read_stringnl(f, decode=True, stripquotes=True):
raise ValueError("no string quotes around %r" % data)
if decode:
- data = codecs.escape_decode(data)[0].decode("ascii")
+ data = codecs.escape_decode(data)[0].decode(encoding)
return data
stringnl = ArgumentDescriptor(
@@ -370,7 +370,7 @@ stringnl = ArgumentDescriptor(
""")
def read_stringnl_noescape(f):
- return read_stringnl(f, stripquotes=False)
+ return read_stringnl(f, stripquotes=False, encoding='utf-8')
stringnl_noescape = ArgumentDescriptor(
name='stringnl_noescape',
@@ -2513,7 +2513,10 @@ def dis(pickle, out=None, memo=None, indentlevel=4, annotate=0):
# make a mild effort to align arguments
line += ' ' * (10 - len(opcode.name))
if arg is not None:
- line += ' ' + repr(arg)
+ if opcode.name in ("STRING", "BINSTRING", "SHORT_BINSTRING"):
+ line += ' ' + ascii(arg)
+ else:
+ line += ' ' + repr(arg)
if markmsg:
line += ' ' + markmsg
if annotate: