cpython: fcbd3bda7c0f (original) (raw)
Mercurial > cpython
changeset 77946:fcbd3bda7c0f 3.2
Fix issue # 15033 - Return the proper exitcode for failure when modules are invoked using -m switch. Patch contributed by Jeff Knupp [#15033]
Senthil Kumaran senthil@uthcode.com | |
---|---|
date | Wed, 04 Jul 2012 19:28:16 -0700 |
parents | 4de541fbdd58 |
children | 1186d68715cc c97d78415f5a |
files | Lib/test/test_cmd_line_script.py Misc/NEWS Modules/main.c |
diffstat | 3 files changed, 19 insertions(+), 1 deletions(-)[+] [-] Lib/test/test_cmd_line_script.py 15 Misc/NEWS 3 Modules/main.c 2 |
line wrap: on
line diff
--- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -279,6 +279,21 @@ class CmdLineTest(unittest.TestCase): self._check_output(script_name, rc, out, script_name, script_name, '', '')
- def test_dash_m_error_code_is_one(self):
# If a module is invoked with the -m command line flag[](#l1.8)
# and results in an error that the return code to the[](#l1.9)
# shell is '1'[](#l1.10)
with temp_dir() as script_dir:[](#l1.11)
with support.temp_cwd(path=script_dir):[](#l1.12)
pkg_dir = os.path.join(script_dir, 'test_pkg')[](#l1.13)
make_pkg(pkg_dir)[](#l1.14)
script_name = _make_test_script(pkg_dir, 'other',[](#l1.15)
"if __name__ == '__main__': raise ValueError")[](#l1.16)
rc, out, err = assert_python_failure('-m', 'test_pkg.other', *example_args)[](#l1.17)
if verbose > 1:[](#l1.18)
print(out)[](#l1.19)
self.assertEqual(rc, 1)[](#l1.20)
+ def test_main(): support.run_unittest(CmdLineTest) support.reap_children()
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.2.4 Core and Builtins ----------------- +- Issue #15033: Fix the exit status bug when modules invoked using -m swith,
- Issue #12268: File readline, readlines and read() or readall() methods no longer lose data when an underlying read system call is interrupted. IOError is no longer raised due to a read system call returning EINTR
--- a/Modules/main.c +++ b/Modules/main.c @@ -673,7 +673,7 @@ Py_Main(int argc, wchar_t **argv) sts = run_command(command, &cf); free(command); } else if (module) {
sts = RunModule(module, 1);[](#l3.7)