From 4ad41f697ad5945690f915cc5465dabc8faa50ed Mon Sep 17 00:00:00 2001 From: Pierre Glaser Date: Fri, 11 Oct 2024 16:43:06 +0100 Subject: [PATCH] Update cloudpickle/cloudpickle.py Co-authored-by: Olivier Grisel --- cloudpickle/cloudpickle.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cloudpickle/cloudpickle.py b/cloudpickle/cloudpickle.py index e8da3c7e..8c50ba17 100644 --- a/cloudpickle/cloudpickle.py +++ b/cloudpickle/cloudpickle.py @@ -1171,7 +1171,11 @@ def _class_setstate(obj, state): if sys.version_info >= (3, 13) and "__firstlineno__" in state: # Set the Python 3.13+ only __firstlineno__ attribute one more time, as it # will be automatically deleted by the `setattr(obj, attrname, attr)` call - # above when `attrname` is "__firstlineno__". + # above when `attrname` is "__firstlineno__". We assume that preserving this + # information might be important for some users and that it not stale in the + # context of cloudpickle usage, hence legitimate to propagate. Furthermore it + # is necessary to do so to keep deterministic chained pickling as tested in + # test_deterministic_str_interning_for_chained_dynamic_class_pickling. obj.__firstlineno__ = state["__firstlineno__"] if registry is not None: