Skip to content
Merged
Show file tree
Hide file tree
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
Add comments
  • Loading branch information
vstinner committed Jun 12, 2024
commit 13efcc91cadd3519fb93d3d93968899e71e39cf0
1 change: 1 addition & 0 deletions Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
_collections_abc.MutableSequence.register(deque)

try:
# Expose _deque_iterator to support pickling deque iterators
from _collections import _deque_iterator # noqa
except ImportError:
pass
Comment on lines 48 to 52

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_collections passes for me if I remove this import. Does it need to stay? It was added in 52f96d3

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erlend-aasland @kumaraditya303: Do you know/recall why this symbol is exposed?

@AlexWaygood AlexWaygood Jun 12, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, test_deque fails if the import is removed. I expected deque to be tested as part of test_collections, but apparently it has its own test file. Could you add a comment that it is (apparently) required to expose it in the collections module in order for deque iterators to be pickled?

======================================================================
ERROR: test_iterator_pickle (test.test_deque.TestBasic.test_iterator_pickle)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/alexw/dev/cpython/Lib/test/test_deque.py", line 640, in test_iterator_pickle
    dump = pickle.dumps((itorg, orig), proto)
_pickle.PicklingError: Can't pickle <class 'collections._deque_iterator'>: attribute lookup _deque_iterator on collections failed

----------------------------------------------------------------------

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I added a comment.

Expand Down
4 changes: 3 additions & 1 deletion Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ class or function within a module or module in a package. If the

from _pyrepl.pager import (get_pager, pipe_pager,
plain_pager, tempfile_pager, tty_pager,
Comment thread
serhiy-storchaka marked this conversation as resolved.
Outdated
plain) # noqa

# Expose plain() as pydoc.plain()
from _pyrepl.pager import plain # noqa


# --------------------------------------------------------- old names
Expand Down