Skip to content

Commit a7444f4

Browse files
committed
PyErr_ProgramText(): Grrrrrr.
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")).
1 parent 0023a2f commit a7444f4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Python/errors.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ PyErr_ProgramText(const char *filename, int lineno)
738738
int i;
739739
char linebuf[1000];
740740

741-
if (filename == NULL || lineno <= 0)
741+
if (filename == NULL || *filename == '\0' || lineno <= 0)
742742
return NULL;
743743
fp = fopen(filename, "r" PY_STDIOTEXTMODE);
744744
if (fp == NULL)

0 commit comments

Comments
 (0)