From bde67df0cd4de5e034c2cf4bd43c0d5657649942 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 22 Jun 2010 18:09:02 +0000 Subject: [PATCH] keep UserDict an old-style class Be generous in abc.py to allow this. --- Lib/UserDict.py | 2 +- Lib/abc.py | 4 +++- Misc/NEWS | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/UserDict.py b/Lib/UserDict.py index bd64f84d42..bb2218ab6c 100644 --- a/Lib/UserDict.py +++ b/Lib/UserDict.py @@ -1,6 +1,6 @@ """A more or less complete user-defined wrapper around dictionary objects.""" -class UserDict(object): +class UserDict: def __init__(self, dict=None, **kwargs): self.data = {} if dict is not None: diff --git a/Lib/abc.py b/Lib/abc.py index c37ed8fd61..515ba08f23 100644 --- a/Lib/abc.py +++ b/Lib/abc.py @@ -3,6 +3,8 @@ """Abstract Base Classes (ABCs) according to PEP 3119.""" +import types + # Instance of old-style class class _C: pass @@ -101,7 +103,7 @@ class ABCMeta(type): def register(cls, subclass): """Register a virtual subclass of an ABC.""" - if not isinstance(subclass, type): + if not isinstance(subclass, (type, types.ClassType)): raise TypeError("Can only register classes") if issubclass(subclass, cls): return # Already a subclass diff --git a/Misc/NEWS b/Misc/NEWS index 5926603b11..feab9c55e4 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -971,8 +971,6 @@ Library position to the given argument, which goes against the tradition of ftruncate() and other truncation APIs. Patch by Pascal Chambon. -- UserDict is now a new-style class. - - Issue #7610: Reworked implementation of the internal ``zipfile.ZipExtFile`` class used to represent files stored inside an archive. The new implementation is significantly faster and can be wrapped in a -- 2.50.1