]> granicus.if.org Git - python/commitdiff
Fix ast_error_finish() and err_input(): filename can be NULL
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 16 Oct 2010 13:42:53 +0000 (13:42 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 16 Oct 2010 13:42:53 +0000 (13:42 +0000)
Fix my previous commit (r85569).

Python/ast.c
Python/pythonrun.c

index b9beef88ef9626d705a8d0ae032b9674f38c6730..d1aa61640a2f80d043aab4a8b46d1bd77d2345af 100644 (file)
@@ -131,7 +131,12 @@ ast_error_finish(const char *filename)
         Py_INCREF(Py_None);
         loc = Py_None;
     }
-    filename_obj = PyUnicode_DecodeFSDefault(filename);
+    if (filename != NULL)
+        filename_obj = PyUnicode_DecodeFSDefault(filename);
+    else {
+        Py_INCREF(Py_None);
+        filename_obj = Py_None;
+    }
     if (filename_obj != NULL)
         tmp = Py_BuildValue("(NlOO)", filename_obj, lineno, offset, loc);
     else
index 8c535fd8a61a36f72c088f8db143a41474ef52fc..f72c9d705af7bb885a8b3f215cd636655a33b2f3 100644 (file)
@@ -2054,7 +2054,12 @@ err_input(perrdetail *err)
         errtext = PyUnicode_DecodeUTF8(err->text, strlen(err->text),
                                        "replace");
     }
-    filename = PyUnicode_DecodeFSDefault(err->filename);
+    if (err->filename != NULL)
+        filename = PyUnicode_DecodeFSDefault(err->filename);
+    else {
+        Py_INCREF(Py_None);
+        filename = Py_None;
+    }
     if (filename != NULL)
         v = Py_BuildValue("(NiiN)", filename,
                           err->lineno, err->offset, errtext);