]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45557: Fix underscore_numbers in pprint.pprint(). (GH-29129)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 21 Oct 2021 21:16:59 +0000 (14:16 -0700)
committerGitHub <noreply@github.com>
Thu, 21 Oct 2021 21:16:59 +0000 (14:16 -0700)
(cherry picked from commit 087f089e5e04d5b132ffbff0576667d591f13219)

Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
Lib/pprint.py
Misc/NEWS.d/next/Library/2021-10-21-16-18-51.bpo-45557.4MQt4r.rst [new file with mode: 0644]

index 13819f3fef212a3c05896deeeb62fbfba9efb6f4..d91421f0a6bf60a5a79b0c46050941d58637f180 100644 (file)
@@ -50,7 +50,8 @@ def pprint(object, stream=None, indent=1, width=80, depth=None, *,
     """Pretty-print a Python object to a stream [default is sys.stdout]."""
     printer = PrettyPrinter(
         stream=stream, indent=indent, width=width, depth=depth,
-        compact=compact, sort_dicts=sort_dicts, underscore_numbers=False)
+        compact=compact, sort_dicts=sort_dicts,
+        underscore_numbers=underscore_numbers)
     printer.pprint(object)
 
 def pformat(object, indent=1, width=80, depth=None, *,
diff --git a/Misc/NEWS.d/next/Library/2021-10-21-16-18-51.bpo-45557.4MQt4r.rst b/Misc/NEWS.d/next/Library/2021-10-21-16-18-51.bpo-45557.4MQt4r.rst
new file mode 100644 (file)
index 0000000..7472b08
--- /dev/null
@@ -0,0 +1,2 @@
+pprint.pprint() now handles underscore_numbers correctly. Previously it was
+always setting it to False.