[Python-checkins] r42932 - in python/trunk: Lib/test/test_cmd_line.py Modules/main.c Python/sysmodule.c
neal.norwitz
python-checkins at python.org
Thu Mar 9 06:58:12 CET 2006
Author: neal.norwitz
Date: Thu Mar 9 06:58:11 2006
New Revision: 42932
Modified:
python/trunk/Lib/test/test_cmd_line.py
python/trunk/Modules/main.c
python/trunk/Python/sysmodule.c
Log:
Try to be a bit more consistent on all platforms:
python .
python < .
both print a message, return non-zero and do not core dump.
Modified: python/trunk/Lib/test/test_cmd_line.py
==============================================================================
--- python/trunk/Lib/test/test_cmd_line.py (original)
+++ python/trunk/Lib/test/test_cmd_line.py Thu Mar 9 06:58:11 2006
@@ -16,19 +16,8 @@
return subprocess.call([sys.executable, cmd_line], stderr=subprocess.PIPE)
def test_directories(self):
- if sys.platform == 'win32':
- # Exit code for "python .", Error 13: permission denied = 2
- expected_exit_code = 2
- elif sys.platform.startswith('freebsd'):
- # On FreeBSD, it more likely raise SyntaxError for binary
- # directory data.
- expected_exit_code = 1
- else:
- # Linux has no problem with "python .", Exit code = 0
- expected_exit_code = 0
- self.assertEqual(self.exit_code('.'), expected_exit_code)
-
- self.assertTrue(self.exit_code('< .') != 0)
+ self.assertNotEqual(self.exit_code('.'), 0)
+ self.assertNotEqual(self.exit_code('< .'), 0)
def verify_valid_flag(self, cmd_line):
data = self.start_python(cmd_line)
Modified: python/trunk/Modules/main.c
==============================================================================
--- python/trunk/Modules/main.c (original)
+++ python/trunk/Modules/main.c Thu Mar 9 06:58:11 2006
@@ -364,7 +364,8 @@
struct stat sb;
if (fstat(fileno(fp), &sb) == 0 &&
S_ISDIR(sb.st_mode)) {
- fprintf(stderr, "%s: warning '%s' is a directory\n", argv[0], filename);
+ fprintf(stderr, "%s: '%s' is a directory, cannot continue\n", argv[0], filename);
+ return 1;
}
}
}
Modified: python/trunk/Python/sysmodule.c
==============================================================================
--- python/trunk/Python/sysmodule.c (original)
+++ python/trunk/Python/sysmodule.c Thu Mar 9 06:58:11 2006
@@ -1037,7 +1037,10 @@
struct stat sb;
if (fstat(fileno(stdin), &sb) == 0 &&
S_ISDIR(sb.st_mode)) {
- Py_FatalError("<stdin> is a directory");
+ /* There's nothing more we can do. */
+ /* Py_FatalError() will core dump, so just exit. */
+ PySys_WriteStderr("Python error: <stdin> is a directory, cannot continue\n");
+ exit(EXIT_FAILURE);
}
}
More information about the Python-checkins
mailing list