
PyDict_Size() sets an exception and returns 0 if it is passed NULL or a non-dict. Is this a bug? It seems like it should return -1, otherwise you'd have to distinguish between an empty dict and an error by calling PyErr_Occurred(). Jeremy

PyDict_Size() sets an exception and returns 0 if it is passed NULL or a non-dict. Is this a bug? It seems like it should return -1, otherwise you'd have to distinguish between an empty dict and an error by calling PyErr_Occurred().
Looks like an (old) bug to me. All other similar cases return NULL or -1, and some calls to PyDict_Size() actually check for < 0. (Many calls don't check for errors, but those probably "know" that they are dealing with a dict and maintain that invariant in other ways.) --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (2)
-
Guido van Rossum
-
Jeremy Hylton