mirror of
https://github.com/python/cpython.git
synced 2025-08-21 01:15:03 +00:00
Fix a bug in traceback.format_exception_only() that led to an error
being raised when print_exc() was called without an exception set. In version 2.4, this printed "None", restored that behavior. (backport from rev. 51995)
This commit is contained in:
parent
a6b9ce185e
commit
edd81b2402
3 changed files with 9 additions and 1 deletions
|
@ -149,6 +149,10 @@ def test():
|
||||||
str_value = '<unprintable %s object>' % X.__name__
|
str_value = '<unprintable %s object>' % X.__name__
|
||||||
self.assertEqual(err[0], X.__name__ + ': ' + str_value + '\n')
|
self.assertEqual(err[0], X.__name__ + ': ' + str_value + '\n')
|
||||||
|
|
||||||
|
def test_without_exception(self):
|
||||||
|
err = traceback.format_exception_only(None, None)
|
||||||
|
self.assertEqual(err, ['None\n'])
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
run_unittest(TracebackCases)
|
run_unittest(TracebackCases)
|
||||||
|
|
|
@ -170,7 +170,7 @@ def format_exception_only(etype, value):
|
||||||
# would throw another exception and mask the original problem.
|
# would throw another exception and mask the original problem.
|
||||||
if (isinstance(etype, BaseException) or
|
if (isinstance(etype, BaseException) or
|
||||||
isinstance(etype, types.InstanceType) or
|
isinstance(etype, types.InstanceType) or
|
||||||
type(etype) is str):
|
etype is None or type(etype) is str):
|
||||||
return [_format_final_exc_line(etype, value)]
|
return [_format_final_exc_line(etype, value)]
|
||||||
|
|
||||||
stype = etype.__name__
|
stype = etype.__name__
|
||||||
|
|
|
@ -28,6 +28,10 @@ Extension Modules
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Fix a bug in traceback.format_exception_only() that led to an error
|
||||||
|
being raised when print_exc() was called without an exception set.
|
||||||
|
In version 2.4, this printed "None", restored that behavior.
|
||||||
|
|
||||||
- Make webbrowser.BackgroundBrowser usable in Windows (it wasn't because
|
- Make webbrowser.BackgroundBrowser usable in Windows (it wasn't because
|
||||||
the close_fds arg to subprocess.Popen is not supported).
|
the close_fds arg to subprocess.Popen is not supported).
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue