]> granicus.if.org Git - python/commitdiff
PyErr_ProgramText(): Grrrrrr.
authorTim Peters <tim.peters@gmail.com>
Mon, 27 Feb 2006 23:29:46 +0000 (23:29 +0000)
committerTim Peters <tim.peters@gmail.com>
Mon, 27 Feb 2006 23:29:46 +0000 (23:29 +0000)
In a Windows debug build, trying to open a file using
an empty string as the name causes assertion death
inside MS's C runtime code.  We probably need to worm
around that in many places.  I'm worming around it here
to stop the new test_with.py from assert-dying in the
Windows debug build (it calls compile() with an empty
string for "the file name", which indirectly leads to
C-level code in Python trying to fopen("", "r")).

Python/errors.c

index ace63ffd8115fd7c1949d23059d6f4d39893d678..cbcc6facaf58e667eb163f4253f9e885465f74ae 100644 (file)
@@ -738,7 +738,7 @@ PyErr_ProgramText(const char *filename, int lineno)
        int i;
        char linebuf[1000];
 
-       if (filename == NULL || lineno <= 0)
+       if (filename == NULL || *filename == '\0' || lineno <= 0)
                return NULL;
        fp = fopen(filename, "r" PY_STDIOTEXTMODE);
        if (fp == NULL)