[issue1877] unhelpful error when calling "python <dirname>"

Alexander Belopolsky report at bugs.python.org
Fri Feb 22 05:08:06 CET 2008


Alexander Belopolsky added the comment:

Actually, a very simple change restores python2.5 behavior:

===================================================================
--- Modules/main.c      (revision 60941)
+++ Modules/main.c      (working copy)
@@ -187,6 +187,7 @@
 
        if ((argv0 = PyString_FromString(filename)) && 
            (importer = PyImport_GetImporter(argv0)) &&
+           (importer != Py_None) &&
            (importer->ob_type != &PyNullImporter_Type))
        {
                 /* argv0 is usable as an import source, so

$ ./python.exe .   
./python.exe: '.' is a directory, cannot continue
$ ./python.exe abc
./python.exe: can't open file 'abc': [Errno 2] No such file or directory

I'm not sure, however that PyImport_GetImporter is behaving correctly in 
this case.  (For one, it should INCREF Py_None before returning it.)

I could not find any documentation for PyImport_GetImporter.  Can 
someone enlighten me what Py_None (instead of NULL) return from yImport_GetImporter signifies?

----------
nosy: +belopolsky

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1877>
__________________________________


More information about the Python-bugs-list mailing list