mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-43024: improve signature (in help, etc) for functions taking sent… (GH-24331)
…inel defaults
This commit is contained in:
parent
ba2f32a983
commit
f73377d57c
3 changed files with 21 additions and 1 deletions
|
@ -4,6 +4,7 @@ from collections import namedtuple
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
import linecache
|
import linecache
|
||||||
import sys
|
import sys
|
||||||
|
import inspect
|
||||||
import unittest
|
import unittest
|
||||||
import re
|
import re
|
||||||
from test import support
|
from test import support
|
||||||
|
@ -255,6 +256,21 @@ class TracebackCases(unittest.TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
traceback.format_exception_only(None, None), [NONE_EXC_STRING])
|
traceback.format_exception_only(None, None), [NONE_EXC_STRING])
|
||||||
|
|
||||||
|
def test_signatures(self):
|
||||||
|
self.assertEqual(
|
||||||
|
str(inspect.signature(traceback.print_exception)),
|
||||||
|
('(exc, /, value=<implicit>, tb=<implicit>, '
|
||||||
|
'limit=None, file=None, chain=True)'))
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
str(inspect.signature(traceback.format_exception)),
|
||||||
|
('(exc, /, value=<implicit>, tb=<implicit>, limit=None, '
|
||||||
|
'chain=True)'))
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
str(inspect.signature(traceback.format_exception_only)),
|
||||||
|
'(exc, /, value=<implicit>)')
|
||||||
|
|
||||||
|
|
||||||
class TracebackFormatTests(unittest.TestCase):
|
class TracebackFormatTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,11 @@ _context_message = (
|
||||||
"another exception occurred:\n\n")
|
"another exception occurred:\n\n")
|
||||||
|
|
||||||
|
|
||||||
_sentinel = object()
|
class _Sentinel:
|
||||||
|
def __repr__(self):
|
||||||
|
return "<implicit>"
|
||||||
|
|
||||||
|
_sentinel = _Sentinel()
|
||||||
|
|
||||||
def _parse_value_tb(exc, value, tb):
|
def _parse_value_tb(exc, value, tb):
|
||||||
if (value is _sentinel) != (tb is _sentinel):
|
if (value is _sentinel) != (tb is _sentinel):
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Improve the help signature of :func:`traceback.print_exception`, :func:`traceback.format_exception` and :func:`traceback.format_exception_only`.
|
Loading…
Add table
Add a link
Reference in a new issue