[Python-Dev] Classes that claim to be defined in __builtin__ but aren't

James Y Knight foom at fuhm.net
Mon Aug 16 07:11:48 CEST 2004


On Aug 12, 2004, at 5:28 PM, James Y Knight wrote:
> Okay, so, I don't have a patch

Submitted, http://www.python.org/sf/1009811

I'll note here, too, that I didn't add all the missing core types, only 
the ones that weren't iterators, descriptor internal stuff, or list 
comparison wrappers. For any of those that are at all possible to 
access from python code, I think they ought to show up somewhere, but 
I'm not convinced __builtin__ is the right place. Also the ones with 
"-" in their name need to be renamed.

> I have made a script to examine the situation.

Improved it slightly, and found another set of problems. Some modules 
have a function bound in place of the type:

E.g.

 >>> select.poll()
<select.poll object at 0x401cdea8>
 >>> isinstance(select.poll(), select.poll)
TypeError: isinstance() arg 2 must be a class, type, or tuple of 
classes and types
 >>> select.poll
<built-in function poll>
 >>> "D'oh!"

Here's the list of these:
select.poll    not a type.
mpz.mpz    not a type.
itertools.tee    not a type.
_csv.reader    not a type.
_csv.writer    not a type.
md5.md5    not a type.
cPickle.Pickler    not a type.
cPickle.Unpickler    not a type.
mmap.mmap    not a type.
xreadlines.xreadlines    not a type.

James



More information about the Python-Dev mailing list