[Python-Dev] when is path==NULL? (original) (raw)

Christian Heimes lists at cheimes.de
Tue Sep 30 14:48:40 CEST 2008


Ulrich Eckhardt wrote:

Hi!

I'm looking at trunk/Python/sysmodule.c, function PySysSetArgv(). In that function, there is code like this: PyObject* path = PySysGetObject("path"); ... if (path != NULL) { ... } My intuition says that if path==NULL, something is very wrong. At least I would expect to get 'None', but never NULL, except when out of memory. So, for the case that path==NULL', I would simply invoke PyFatalError("no mem for sys.path"), similarly to the other call there.

PySys_GetObject may return NULL after the user has removed sys.path with delattr(sys, 'path'). There are valid applications for removing sys.path.

Christian



More information about the Python-Dev mailing list