gh-144412: Require tuple args in pickle REDUCE#144419
gh-144412: Require tuple args in pickle REDUCE#144419sabasiddique1 wants to merge 12 commits intopython:mainfrom
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
| self.check_unpickling_error(TypeError, b'cbuiltins\nint\nNR.') | ||
| self.check_unpickling_error(TypeError, b'cbuiltins\nint\nNR.') |
There was a problem hiding this comment.
Can you explain what this test adds?
There was a problem hiding this comment.
NR. case ensures that when REDUCE receives a non-tuple args, pickle.load_reduce() raises TypeError consistently (matching _pickle) and prevents regressions in this validation.
There was a problem hiding this comment.
Could you look carefully at the surrounding code and explain what this test adds?
There was a problem hiding this comment.
Surrounding tests already cover an invalid callable (N)R.) and a valid REDUCE call with tuple args (int + ()).
cbuiltins\nint\nNR. is different because the callable is valid, but the REDUCE args object is not a tuple (None), so it reaches load_reduce() and hits the new gh-144412 tuple check.
This confirms we raise TypeError at the correct point, consistent with _pickle.
It also acts as a regression test to ensure non-tuple REDUCE args aren’t accidentally accepted again.
There was a problem hiding this comment.
I've try once again.
All you have done is to duplicate the test on the line above.
What benefit do you get from running exactly the same test twice?
Summary
pickle.load_reduce()to match_pickleload_reducefunction doesn't check ifargsis a tuple #144412