File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -4158,10 +4158,15 @@ def evaluate_forward_ref(
4158
4158
4159
4159
_sentinel_registry = {}
4160
4160
4161
- def _unpickle_fetch_sentinel (name : str , module_name : str ):
4162
- """Stable Sentinel unpickling function, fetch Sentinel at 'module_name.name'."""
4161
+ def _unpickle_sentinel (
4162
+ name : str ,
4163
+ module_name : str ,
4164
+ config : typing .Dict [str , typing .Any ],
4165
+ / ,
4166
+ ):
4167
+ """Stable Sentinel unpickling function, get Sentinel at 'module_name.name'."""
4163
4168
# Explicit repr=name because a saved module_name is known to be valid
4164
- return Sentinel (name , module_name , repr = name )
4169
+ return Sentinel (name , module_name , repr = config . get ( "repr" , name ) )
4165
4170
4166
4171
class Sentinel :
4167
4172
"""A sentinel object.
@@ -4258,13 +4263,15 @@ def __ror__(self, other):
4258
4263
return typing .Union [other , self ]
4259
4264
4260
4265
def __reduce__ (self ):
4261
- """Record where this sentinel is defined."""
4266
+ """Record where this sentinel is defined and its current parameters."""
4267
+ config = {"repr" : self ._repr }
4262
4268
# Reduce callable must be at the top-level to be stable whenever Sentinel changes
4263
4269
return (
4264
- _unpickle_fetch_sentinel ,
4265
- ( # Only the location of the sentinel needs to be stored
4270
+ _unpickle_sentinel ,
4271
+ (
4266
4272
self ._name ,
4267
4273
self ._module_name ,
4274
+ config ,
4268
4275
),
4269
4276
)
4270
4277
You can’t perform that action at this time.
0 commit comments