From 810a40c50373b4e2a1d81f7171385b0ea2aa1159 Mon Sep 17 00:00:00 2001 From: yahya-abou-imran Date: Fri, 12 Jan 2018 10:18:44 +0100 Subject: [PATCH 1/2] bpo-32473: Improve ABCMeta._dump_registry() readability (GH-5091) (cherry picked from commit ae12f5d4c98f2095c2aadd58981453e955044697) --- Lib/abc.py | 4 +++- .../next/Library/2018-01-10-20-37-59.bpo-32473.mP_yJG.rst | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2018-01-10-20-37-59.bpo-32473.mP_yJG.rst diff --git a/Lib/abc.py b/Lib/abc.py index 43a34a0bbded78..86963db9772b54 100644 --- a/Lib/abc.py +++ b/Lib/abc.py @@ -170,9 +170,11 @@ def _dump_registry(cls, file=None): """Debug helper to print the ABC registry.""" print("Class: %s.%s" % (cls.__module__, cls.__qualname__), file=file) print("Inv.counter: %s" % ABCMeta._abc_invalidation_counter, file=file) - for name in sorted(cls.__dict__.keys()): + for name in cls.__dict__: if name.startswith("_abc_"): value = getattr(cls, name) + if isinstance(value, WeakSet): + value = set(value) print("%s: %r" % (name, value), file=file) def __instancecheck__(cls, instance): diff --git a/Misc/NEWS.d/next/Library/2018-01-10-20-37-59.bpo-32473.mP_yJG.rst b/Misc/NEWS.d/next/Library/2018-01-10-20-37-59.bpo-32473.mP_yJG.rst new file mode 100644 index 00000000000000..95b9d45e4227fe --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-01-10-20-37-59.bpo-32473.mP_yJG.rst @@ -0,0 +1 @@ +Improve ABCMeta._dump_registry() output readability From b538c112f14dd4c15ee53af32f2df64811898341 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Fri, 12 Jan 2018 19:18:22 +0900 Subject: [PATCH 2/2] Sort keys Dict of Python 3.6 doesn't keep insertion order by language spec, regardless CPython and PyPy does. --- Lib/abc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/abc.py b/Lib/abc.py index 86963db9772b54..a092db2618ac82 100644 --- a/Lib/abc.py +++ b/Lib/abc.py @@ -170,7 +170,7 @@ def _dump_registry(cls, file=None): """Debug helper to print the ABC registry.""" print("Class: %s.%s" % (cls.__module__, cls.__qualname__), file=file) print("Inv.counter: %s" % ABCMeta._abc_invalidation_counter, file=file) - for name in cls.__dict__: + for name in sorted(cls.__dict__): if name.startswith("_abc_"): value = getattr(cls, name) if isinstance(value, WeakSet):