[Python-Dev] PyMapping_Check Bug? (fwd)

Skip Montanaro skip at pobox.com
Wed Aug 13 15:18:15 EDT 2003


(muffed the first send...)

>>>>> "Guido" == Guido van Rossum <guido at python.org> writes:

    >> Passing along a fragment from the psycopg list where Federico Di Gregorio
    >> (fog at initd.org) wrote:
    >> 
    >> .... because on python 2.3 PyMapping_Check apperently return True for
    >> every new-type instance....
    >> 
    >> Is this true?  If so, is it a bug?

    Guido> I don't see this.  operator.isMappingType() maps directly to
    Guido> PyMapping_Check(); and I tried this:

    >>>> import operator
    >>>> operator.isMappingType(str)
    Guido>     False
    >>>> class C(object): pass
    Guido>     ...
    >>>> operator.isMappingType(C)
    Guido>     False
    >>>> operator.isMappingType(C())
    Guido>     False
    >>>> operator.isMappingType({})
    Guido>     True
    >>>> 

    Guido> Looks okay to me. :-)

    Guido> --Guido van Rossum (home page: http://www.python.org/~guido/)

Good to hear, and straight from the horse's mouth!

Nice to know about operator.isMappingType as well.  I had no idea that it
existed and didn't want to write C just to check this.

Skip



More information about the Python-Dev mailing list