8000 gh-110235: Raise `TypeError` for duplicate/unknown fields in PyStructSequence constructor by XuehaiPan · Pull Request #110258 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-110235: Raise TypeError for duplicate/unknown fields in PyStructSequence constructor #110258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Oct 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert test changes for structseq.__reduce__
  • Loading branch information
XuehaiPan committed Oct 3, 2023
commit c173451172b29ba81c188c35b6c3a68422916631
18 changes: 1 addition & 17 deletions Lib/test/test_structseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,7 @@ def __len__(self):

def test_reduce(self):
t = time.gmtime()
cls, (tup, dct) = t.__reduce__()
self.assertIs(cls, time.struct_time)
self.assertEqual(tup, tuple(t))
reconstructed = cls(tup, dct)
self.assertEqual(reconstructed, t)
self.assertEqual(reconstructed.tm_zone, t.tm_zone)

def test_reduce_with_unnamed_fields(self):
r = os.stat_result(range(os.stat_result.n_sequence_fields), {'st_atime': 1.0})
self.assertEqual(r.st_atime, 1.0)
cls, (tup, dct) = r.__reduce__()
self.assertIs(cls, os.stat_result)
self.assertEqual(tup, tuple(r))
self.assertIn('st_atime', dct)
reconstructed = cls(tup, dct)
self.assertEqual(reconstructed, r)
self.assertAlmostEqual(reconstructed.st_atime, r.st_atime)
x = t.__reduce__()

def test_extended_getslice(self):
# Test extended slicing by comparing with list slicing.
Expand Down
0