]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-93096: Remove `-t` and `-v` flags from `pickle` cli (#131068)
authordonBarbos <donbarbos@proton.me>
Tue, 11 Mar 2025 11:07:00 +0000 (15:07 +0400)
committerGitHub <noreply@github.com>
Tue, 11 Mar 2025 11:07:00 +0000 (12:07 +0100)
* Remove `python -m pickle -t`

* Revert adding doctest to unittests

Lib/pickle.py
Misc/NEWS.d/next/Library/2025-03-11-08-07-07.gh-issue-93096.DyPXUX.rst [new file with mode: 0644]

index 8afb4aa4285f3725646ca566bf91d382dcef4c55..8f7406d2534f2c3e785d6932327456aec8513d4c 100644 (file)
@@ -1906,10 +1906,6 @@ except ImportError:
     Pickler, Unpickler = _Pickler, _Unpickler
     dump, dumps, load, loads = _dump, _dumps, _load, _loads
 
-# Doctest
-def _test():
-    import doctest
-    return doctest.testmod()
 
 if __name__ == "__main__":
     import argparse
@@ -1918,24 +1914,15 @@ if __name__ == "__main__":
     parser.add_argument(
         'pickle_file',
         nargs='*', help='the pickle file')
-    parser.add_argument(
-        '-t', '--test', action='store_true',
-        help='run self-test suite')
-    parser.add_argument(
-        '-v', action='store_true',
-        help='run verbosely; only affects self-test run')
     args = parser.parse_args()
-    if args.test:
-        _test()
+    if not args.pickle_file:
+        parser.print_help()
     else:
-        if not args.pickle_file:
-            parser.print_help()
-        else:
-            import pprint
-            for fn in args.pickle_file:
-                if fn == '-':
-                    obj = load(sys.stdin.buffer)
-                else:
-                    with open(fn, 'rb') as f:
-                        obj = load(f)
-                pprint.pprint(obj)
+        import pprint
+        for fn in args.pickle_file:
+            if fn == '-':
+                obj = load(sys.stdin.buffer)
+            else:
+                with open(fn, 'rb') as f:
+                    obj = load(f)
+            pprint.pprint(obj)
diff --git a/Misc/NEWS.d/next/Library/2025-03-11-08-07-07.gh-issue-93096.DyPXUX.rst b/Misc/NEWS.d/next/Library/2025-03-11-08-07-07.gh-issue-93096.DyPXUX.rst
new file mode 100644 (file)
index 0000000..919cc43
--- /dev/null
@@ -0,0 +1,2 @@
+Removed undocumented ``-t`` and ``-v`` arguments of ``python -m pickle``.
+Use ``python -m doctest Lib/pickle.py -v`` instead. Patch by Semyon Moroz.