8000 bpo-34574: Prevent OrderedDict iterators from exhaustion during pickling. by sir-sigurd · Pull Request #9051 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-34574: Prevent OrderedDict iterators from exhaustion during pickling. #9051

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 4 commits into from
Oct 20, 2018
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
Removed unused code. Use subTest also for pickling protocol.
  • Loading branch information
sir-sigurd committed Sep 4, 2018
commit 438c739976bccbe7e33270d41e895334413e31c1
11 changes: 3 additions & 8 deletions Lib/test/test_ordered_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,15 +737,10 @@ def test_iterators_pickling(self):
pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
od = OrderedDict(pairs)

expected = (
('keys', [k for k, v in pairs[:1]]),
('values', [v for k, v in pairs[:1]]),
('items', pairs[:1]),
)
for method_name, items in expected:
for method_name in ('keys', 'values', 'items'):
meth = getattr(od, method_name)
with self.subTest(method_name=method_name):
for i in range(pickle.HIGHEST_PROTOCOL + 1):
for i in range(pickle.HIGHEST_PROTOCOL + 1):
with self.subTest(method_name=method_name, protocol=i):
it = iter(meth())
next(it)
p = pickle.dumps(it, i)
Expand Down
0