Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
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
2 changes: 1 addition & 1 deletion Doc/library/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The following modules have a command-line interface.
* :ref:`json <json-commandline>`
* :mod:`mimetypes`
* :mod:`pdb`
* :mod:`pickle`
* :ref:`pickle <pickle-cli>`
* :ref:`pickletools <pickletools-cli>`
* :mod:`platform`
* :mod:`poplib`
Expand Down
24 changes: 24 additions & 0 deletions Doc/library/pickle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,30 @@ The :mod:`pickle` module exports three classes, :class:`Pickler`,
Release the underlying buffer exposed by the PickleBuffer object.


.. _pickle-cli:

Command-line interface
----------------------

The :mod:`pickle` module can be invoked as a script from the command line,
it will display contents of the pickle files. However, when the pickle file
that you want to examine comes from an untrusted source, ``-m pickletools``
is a safer option because it does not execute pickle bytecode, see
:ref:`pickletools CLI usage <pickletools-cli>`.

.. code-block:: bash

python -m pickle pickle_file [pickle_file ...]

The following option is accepted:

.. program:: pickle

.. option:: pickle_file

A pickle file.


.. _pickle-picklable:

What can be pickled and unpickled?
Expand Down
2 changes: 1 addition & 1 deletion Lib/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,7 @@ def _loads(s, /, *, fix_imports=True, encoding="ASCII", errors="strict",
description='display contents of the pickle files')
parser.add_argument(
'pickle_file',
nargs='*', help='the pickle file')
nargs='+', help='the pickle file')
args = parser.parse_args()
if not args.pickle_file:
parser.print_help()
Expand Down
Loading