From 6a5cb5092342071fca9310c5b343a8ad67193633 Mon Sep 17 00:00:00 2001 From: Yahya Abou Imran Date: Wed, 3 Jan 2018 18:49:15 +0000 Subject: [PATCH 1/3] bpo-32473: Improve ABCMeta._dump_registry() readibility --- Lib/abc.py | 2 ++ .../next/Library/2018-01-10-20-37-59.bpo-32473.mP_yJG.rst | 1 + 2 files changed, 3 insertions(+) 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 d13a0de89b4054..ec22e2650ed56f 100644 --- a/Lib/abc.py +++ b/Lib/abc.py @@ -173,6 +173,8 @@ def _dump_registry(cls, file=None): for name in sorted(cls.__dict__.keys()): 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 8fd993595ccc42859673b010e9e2ddb4efd5657c Mon Sep 17 00:00:00 2001 From: Yahya Abou Imran Date: Thu, 11 Jan 2018 18:07:38 +0000 Subject: [PATCH 2/3] Don't use sorted (dict order is now stable) --- Lib/abc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/abc.py b/Lib/abc.py index ec22e2650ed56f..0517df26ddb07c 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 sorted(cls.__dict__.keys()): + for name in cls.__dict__.keys(): if name.startswith("_abc_"): value = getattr(cls, name) if isinstance(value, WeakSet): From 27a75af391a7961e4d3ff17cbf72513e3e79aab4 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Fri, 12 Jan 2018 17:25:25 +0900 Subject: [PATCH 3/3] Update abc.py --- Lib/abc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/abc.py b/Lib/abc.py index 0517df26ddb07c..9bdc36dce65eab 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__.keys(): + for name in cls.__dict__: if name.startswith("_abc_"): value = getattr(cls, name) if isinstance(value, WeakSet):