This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Error usage of class.__bases__
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ZealotuS
Priority: normal Keywords:

Created on 2014-03-31 14:30 by ZealotuS, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg215241 - (view) Author: Lotus Qin (ZealotuS) Date: 2014-03-31 14:30
function in urllib.request.build_opener()

    def isclass(obj):
        return isinstance(obj, type) or hasattr(obj, "__bases__")

should it be `obj` or `obj.__class__`?

cause in the man of 3.4, there is only `class.__bases__`, but the code there may function like `instance.__bases__`.

=======

# my code behave like this: 

cookie = http.cookiejar.CookieJar()
cookie_handler = urllib.request.HTTPCookieProcessor(cookie)
opener = urllib.request.build_opener(cookie_handler)

# the variable `skip` in `build_opener` will be empty cause `isclass(obj)` always return false. 

cookie_handler.__bases__
AttributeError: 'HTTPCookieProcessor' object has no attribute '__bases__'

cookie_handler.__class__.__bases__
(<class 'urllib.request.BaseHandler'>,)
msg215304 - (view) Author: Lotus Qin (ZealotuS) Date: 2014-04-01 10:06
get the __doc__ in a wrong way, it works now.
History
Date User Action Args
2022-04-11 14:58:01adminsetgithub: 65312
2014-04-01 10:06:41ZealotuSsetstatus: open -> closed
resolution: not a bug
messages: + msg215304
2014-03-31 14:31:33ZealotuSsettitle: Error usage of class.__bases__() -> Error usage of class.__bases__
2014-03-31 14:30:34ZealotuScreate