Re: [Python-Dev] [Python-checkins] cpython (3.4): simplify check, since now there are only new-style classes
On Tue, Apr 1, 2014 at 1:21 PM, benjamin.peterson <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/abb85902ce79 changeset: 90090:abb85902ce79 branch: 3.4 parent: 90088:4a2dabac976d user: Benjamin Peterson <benjamin@python.org> date: Tue Apr 01 14:20:56 2014 -0400 summary: simplify check, since now there are only new-style classes
files: Lib/urllib/request.py | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -511,9 +511,6 @@ If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used. """ - def isclass(obj): - return isinstance(obj, type) or hasattr(obj, "__bases__") - opener = OpenerDirector() default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, HTTPDefaultErrorHandler, HTTPRedirectHandler, @@ -524,7 +521,7 @@ skip = set() for klass in default_classes: for check in handlers: - if isclass(check): + if instance(check, type):
Should be isinstance, should it not? -- Zach
On Tue, 1 Apr 2014 13:28:53 -0500 Zachary Ware <zachary.ware+pydev@gmail.com> wrote:
@@ -524,7 +521,7 @@ skip = set() for klass in default_classes: for check in handlers: - if isclass(check): + if instance(check, type):
Should be isinstance, should it not?
Sounds like a well-tested code path :-) Regards Antoine.
participants (2)
-
Antoine Pitrou -
Zachary Ware