From 82cf867fb73fb86ae70f12f32dbbba4201ece1f0 Mon Sep 17 00:00:00 2001 From: "Eric V. Smith" Date: Thu, 21 Oct 2021 16:42:55 -0400 Subject: [PATCH] bpo-45557: Fix underscore_numbers in pprint.pprint(). (GH-29129) (cherry picked from commit 087f089e5e04d5b132ffbff0576667d591f13219) Co-authored-by: Eric V. Smith --- Lib/pprint.py | 3 ++- .../next/Library/2021-10-21-16-18-51.bpo-45557.4MQt4r.rst | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2021-10-21-16-18-51.bpo-45557.4MQt4r.rst diff --git a/Lib/pprint.py b/Lib/pprint.py index 13819f3fef212a..d91421f0a6bf60 100644 --- a/Lib/pprint.py +++ b/Lib/pprint.py @@ -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 index 00000000000000..7472b08d1b08e2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-10-21-16-18-51.bpo-45557.4MQt4r.rst @@ -0,0 +1,2 @@ +pprint.pprint() now handles underscore_numbers correctly. Previously it was +always setting it to False.