diff --git a/Lib/pickletools.py b/Lib/pickletools.py index c462d26da97ce1..45bfab2ca6ef5e 100644 --- a/Lib/pickletools.py +++ b/Lib/pickletools.py @@ -2539,8 +2539,6 @@ def dis(pickle, out=None, memo=None, indentlevel=4, annotate=0): stack.extend(after) print("highest protocol among opcodes =", maxproto, file=out) - if stack: - raise ValueError("stack not empty after STOP: %r" % stack) # For use in the doctest, simply as an example of a class to pickle. class _Example: diff --git a/Misc/NEWS.d/next/Library/2024-11-20-22-30-55.gh-issue-127079.egXnLz.rst b/Misc/NEWS.d/next/Library/2024-11-20-22-30-55.gh-issue-127079.egXnLz.rst new file mode 100644 index 00000000000000..bed241198818a2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-11-20-22-30-55.gh-issue-127079.egXnLz.rst @@ -0,0 +1 @@ +:mod:`pickletools` no longer errors out when more than one item is left in the stack upon reaching the `STOP` opcode