Fix BaseSerialization double-wrapping args for builtin exceptions#69752
Fix BaseSerialization double-wrapping args for builtin exceptions#69752bujjibabukatta wants to merge 1 commit into
Conversation
|
Hi @bujjibabukatta, thanks for the contribution! I'm a bit concerned this might introduce a regression. Could you please double-check to ensure this change won't break existing behavior? Thanks! |
821e847 to
d238824
Compare
|
Hi @nailo2c |
Ran into this from #69743 —
BaseSerializationwas manglingargsforbuilt-in exceptions like
KeyErroron the round trip.Turns out the exception-serialization branch for
KeyError/AttributeErrorwas storing
argsas[var.args]. Sincevar.argsis already a tuple(e.g.
("boom",)), that wraps it in an extra layer. When deserializing,exc_cls(*args)unpacks that as a single positional arg — so you getKeyError(("boom",))instead ofKeyError("boom"), and.argscomes backas
(("boom",),)instead of("boom",).Fix is a one-liner: store
list(var.args)instead of[var.args]so itstays flat.
Added a parametrized test covering single-arg, multi-arg, and no-arg
KeyError/AttributeErrorround-trips so this doesn't regress.closes: #69743