8000 simplify check, since now there are only new-style classes · python/cpython@5dd3cae · GitHub
[go: up one dir, main page]

Skip to content

Commit 5dd3cae

Browse files
committed
simplify check, since now there are only new-style classes
1 parent 9d08562 commit 5dd3cae

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Lib/urllib/request.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,6 @@ def build_opener(*handlers):
511511
If any of the handlers passed as arguments are subclasses of the
512512
default handlers, the default handlers will not be used.
513513
"""
514-
def isclass(obj):
515-
return isinstance(obj, type) or hasattr(obj, "__bases__")
516-
517514
opener = OpenerDirector()
518515
default_classes = [ProxyHandler, UnknownHandler, HTTPHandler,
519516
HTTPDefaultErrorHandler, HTTPRedirectHandler,
@@ -524,7 +521,7 @@ def isclass(obj):
524521
skip = set()
525522
for klass in default_classes:
526523
for check in handlers:
527-
if isclass(check):
524+
if instance(check, type):
528525
if issubclass(check, klass):
529526
skip.add(klass)
530527
elif isinstance(check, klass):
@@ -536,7 +533,7 @@ def isclass(obj):
536533
opener.add_handler(klass())
537534

538535
for h in handlers:
539-
if isclass(h):
536+
if isinstance(h, type):
540537
h = h()
541538
opener.add_handler(h)
542539
return opener

0 commit comments

Comments
 (0)
0