mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #25111: Fixed comparison of traceback.FrameSummary.
This commit is contained in:
commit
87b93fe36f
3 changed files with 21 additions and 9 deletions
|
@ -640,7 +640,7 @@ class MiscTracebackCases(unittest.TestCase):
|
||||||
return traceback.extract_stack()
|
return traceback.extract_stack()
|
||||||
result = extract()
|
result = extract()
|
||||||
lineno = extract.__code__.co_firstlineno
|
lineno = extract.__code__.co_firstlineno
|
||||||
self.assertEqual([tuple(x) for x in result[-2:]], [
|
self.assertEqual(result[-2:], [
|
||||||
(__file__, lineno+2, 'test_extract_stack', 'result = extract()'),
|
(__file__, lineno+2, 'test_extract_stack', 'result = extract()'),
|
||||||
(__file__, lineno+1, 'extract', 'return traceback.extract_stack()'),
|
(__file__, lineno+1, 'extract', 'return traceback.extract_stack()'),
|
||||||
])
|
])
|
||||||
|
@ -652,10 +652,16 @@ class TestFrame(unittest.TestCase):
|
||||||
linecache.clearcache()
|
linecache.clearcache()
|
||||||
linecache.lazycache("f", globals())
|
linecache.lazycache("f", globals())
|
||||||
f = traceback.FrameSummary("f", 1, "dummy")
|
f = traceback.FrameSummary("f", 1, "dummy")
|
||||||
self.assertEqual(
|
self.assertEqual(f,
|
||||||
("f", 1, "dummy", '"""Test cases for traceback module"""'),
|
("f", 1, "dummy", '"""Test cases for traceback module"""'))
|
||||||
tuple(f))
|
self.assertEqual(tuple(f),
|
||||||
self.assertEqual(None, f.locals)
|
("f", 1, "dummy", '"""Test cases for traceback module"""'))
|
||||||
|
self.assertEqual(f, traceback.FrameSummary("f", 1, "dummy"))
|
||||||
|
self.assertEqual(f, tuple(f))
|
||||||
|
# Since tuple.__eq__ doesn't support FrameSummary, the equality
|
||||||
|
# operator fallbacks to FrameSummary.__eq__.
|
||||||
|
self.assertEqual(tuple(f), f)
|
||||||
|
self.assertIsNone(f.locals)
|
||||||
|
|
||||||
def test_lazy_lines(self):
|
def test_lazy_lines(self):
|
||||||
linecache.clearcache()
|
linecache.clearcache()
|
||||||
|
|
|
@ -257,10 +257,14 @@ class FrameSummary:
|
||||||
dict((k, repr(v)) for k, v in locals.items()) if locals else None
|
dict((k, repr(v)) for k, v in locals.items()) if locals else None
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
if isinstance(other, FrameSummary):
|
||||||
return (self.filename == other.filename and
|
return (self.filename == other.filename and
|
||||||
self.lineno == other.lineno and
|
self.lineno == other.lineno and
|
||||||
self.name == other.name and
|
self.name == other.name and
|
||||||
self.locals == other.locals)
|
self.locals == other.locals)
|
||||||
|
if isinstance(other, tuple):
|
||||||
|
return (self.filename, self.lineno, self.name, self.line) == other
|
||||||
|
return NotImplemented
|
||||||
|
|
||||||
def __getitem__(self, pos):
|
def __getitem__(self, pos):
|
||||||
return (self.filename, self.lineno, self.name, self.line)[pos]
|
return (self.filename, self.lineno, self.name, self.line)[pos]
|
||||||
|
|
|
@ -190,6 +190,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #25111: Fixed comparison of traceback.FrameSummary.
|
||||||
|
|
||||||
- Issue #25262. Added support for BINBYTES8 opcode in Python implementation of
|
- Issue #25262. Added support for BINBYTES8 opcode in Python implementation of
|
||||||
unpickler. Highest 32 bits of 64-bit size for BINUNICODE8 and BINBYTES8
|
unpickler. Highest 32 bits of 64-bit size for BINUNICODE8 and BINBYTES8
|
||||||
opcodes no longer silently ignored on 32-bit platforms in C implementation.
|
opcodes no longer silently ignored on 32-bit platforms in C implementation.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue