odd isinstance failure

John J. Lee jjl at pobox.com
Sat May 4 12:29:26 EDT 2002


urllib2 does an (unwise, of course) isinstance check:

    def open(self, fullurl, data=None):
[...]
        assert isinstance(req, Request) # really only care about interface

(the Request class is also defined in urllib2) which fails in my code
which does this:

from urllib2 import Request
[...]
req = Request(url)
res = urlopen(req)

The urlopen trips up on the type-checking assertion in urllib2 (actually,
I'm using my own urlopen function, but it uses the urllib2 code).  I don't
see how, because in fact the class used in my code should be identical to
the one that urllib2 is checking for.

I'm sure I've heard about this problem before, but I can't remember what
the answer was.


John




More information about the Python-list mailing list