[Python-checkins] r42631 - python/trunk/Python/errors.c

tim.peters python-checkins at python.org
Tue Feb 28 00:29:46 CET 2006


Author: tim.peters
Date: Tue Feb 28 00:29:46 2006
New Revision: 42631

Modified:
   python/trunk/Python/errors.c
Log:
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")).


Modified: python/trunk/Python/errors.c
==============================================================================
--- python/trunk/Python/errors.c	(original)
+++ python/trunk/Python/errors.c	Tue Feb 28 00:29:46 2006
@@ -738,7 +738,7 @@
 	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)


More information about the Python-checkins mailing list