file_name = script_helper.make_script(temp_dir, 'foo', '\\')
rc, out, err = script_helper.assert_python_failure(file_name)
self.assertIn(b'unexpected EOF while parsing', err)
+ self.assertIn(b'line 2', err)
+ self.assertIn(b'\\', err)
file_name = script_helper.make_script(temp_dir, 'foo', 'y = 6\\')
rc, out, err = script_helper.assert_python_failure(file_name)
self.assertIn(b'unexpected EOF while parsing', err)
+ self.assertIn(b'line 2', err)
+ self.assertIn(b'y = 6\\', err)
if __name__ == "__main__":
unittest.main()
{
int i;
char linebuf[1000];
-
- if (fp == NULL)
+ if (fp == NULL) {
return NULL;
+ }
+
for (i = 0; i < lineno; i++) {
char *pLastChar = &linebuf[sizeof(linebuf) - 2];
do {
*pLastChar = '\0';
if (Py_UniversalNewlineFgets(linebuf, sizeof linebuf,
- fp, NULL) == NULL)
- break;
+ fp, NULL) == NULL) {
+ goto after_loop;
+ }
/* fgets read *something*; if it didn't get as
far as pLastChar, it must have found a newline
or hit the end of the file; if pLastChar is \n,
yet seen a newline, so must continue */
} while (*pLastChar != '\0' && *pLastChar != '\n');
}
+
+after_loop:
fclose(fp);
if (i == lineno) {
PyObject *res;