]> granicus.if.org Git - python/commitdiff
Fix issue # 15033 - Return the proper exitcode for failure when modules are invoked...
authorSenthil Kumaran <senthil@uthcode.com>
Thu, 5 Jul 2012 02:33:45 +0000 (19:33 -0700)
committerSenthil Kumaran <senthil@uthcode.com>
Thu, 5 Jul 2012 02:33:45 +0000 (19:33 -0700)
1  2 
Lib/test/test_cmd_line_script.py
Misc/NEWS
Modules/main.c

index 83aa1633566babb11a8756776ff256182d773f54,6b59d9634914834ee4fc64b6f3f4b53eafad72a8..d8bc2637af5bbdf0ec60f7d9422389b56467174d
@@@ -287,24 -279,21 +287,39 @@@ 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
+         # and results in an error that the return code to the
+         # shell is '1'
+         with temp_dir() as script_dir:
+             with support.temp_cwd(path=script_dir):
+                 pkg_dir = os.path.join(script_dir, 'test_pkg')
+                 make_pkg(pkg_dir)
+                 script_name = _make_test_script(pkg_dir, 'other',
+                                                 "if __name__ == '__main__': raise ValueError")
+                 rc, out, err = assert_python_failure('-m', 'test_pkg.other', *example_args)
+                 if verbose > 1:
+                     print(out)
+                 self.assertEqual(rc, 1)
 +    def test_pep_409_verbiage(self):
 +        # Make sure PEP 409 syntax properly suppresses
 +        # the context of an exception
 +        script = textwrap.dedent("""\
 +            try:
 +                raise ValueError
 +            except:
 +                raise NameError from None
 +            """)
 +        with temp_dir() as script_dir:
 +            script_name = _make_test_script(script_dir, 'script', script)
 +            exitcode, stdout, stderr = assert_python_failure(script_name)
 +            text = stderr.decode('ascii').split('\n')
 +            self.assertEqual(len(text), 4)
 +            self.assertTrue(text[0].startswith('Traceback'))
 +            self.assertTrue(text[1].startswith('  File '))
 +            self.assertTrue(text[3].startswith('NameError'))
 +
  def test_main():
      support.run_unittest(CmdLineTest)
      support.reap_children()
diff --cc Misc/NEWS
index cba8c416e28057934fc3350fb808e6251b938ea2,5adf15e1d35af9d45016c0aa9a5d328ec4b6a27c..ab02a97d30f5d8487d6a4ac7a97be8dbd14e445a
+++ b/Misc/NEWS
@@@ -10,72 -10,9 +10,75 @@@ What's New in Python 3.3.0 Beta 2
  Core and Builtins
  -----------------
  
+ - Issue #15033: Fix the exit status bug when modules invoked using -m swith,
+   return the proper failure return value (1). Patch contributed by Jeff Knupp.
 +- Issue #15229: An OSError subclass whose __init__ doesn't call back
 +  OSError.__init__ could produce incomplete instances, leading to crashes
 +  when calling str() on them.
 +
 +Library
 +-------
 +
 +- Issue #15166: Implement imp.get_tag() using sys.implementation.cache_tag.
 +
 +- Issue #15210: Catch KeyError when imprortlib.__init__ can't find
 +  _frozen_importlib in sys.modules, not ImportError.
 +
 +- Issue #15030: importlib.abc.PyPycLoader now supports the new source size
 +  header field in .pyc files.
 +
 +- Issue #5346: Preserve permissions of mbox, MMDF and Babyl mailbox
 +  files on flush().
 +
 +- Issue #10571: Fix the "--sign" option of distutils' upload command.
 +  Patch by Jakub Wilk.
 +
 +- Issue #9559: If messages were only added, a new file is no longer
 +  created and renamed over the old file when flush() is called on an
 +  mbox, MMDF or Babyl mailbox.
 +
 +- Issue 10924: Fixed mksalt() to use a RNG that is suitable for cryptographic
 +  purpose.
 +
 +Extension Modules
 +-----------------
 +
 +- Issue #15194: Update libffi to the 3.0.11 release.
 +
 +Tools/Demos
 +-----------
 +
 +- Issue #12605: The gdb hooks for debugging CPython (within Tools/gdb) have
 +  been enhanced to show information on more C frames relevant to CPython within
 +  the "py-bt" and "py-bt-full" commands:
 +    * C frames that are waiting on the GIL
 +    * C frames that are garbage-collecting
 +    * C frames that are due to the invocation of a PyCFunction
 +
 +Build
 +-----
 +
 +- Issue #14330: For cross builds, don't use host python, use host search paths
 +  for host compiler.
 +
 +- Issue #15235: Allow Berkley DB versions up to 5.3 to build the dbm module.
 +
 +
 +What's New in Python 3.3.0 Beta 1?
 +==================================
 +
 +*Release date: 27-Jun-2012*
 +
 +Core and Builtins
 +-----------------
 +
 +- Fix a (most likely) very rare memory leak when calling main() and not being
 +  able to decode a command-line argument.
 +
 +- Issue #14815: Use Py_ssize_t instead of long for the object hash, to
 +  preserve all 64 bits of hash on Win64.
 +
  - 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
diff --cc Modules/main.c
Simple merge