@@ -393,28 +393,21 @@ class Session(Configurable):
393
393
394
394
@observe ("packer" , "unpacker" )
395
395
def _packer_unpacker_changed (self , change : t .Any ) -> None :
396
- new = change ["new" ]
397
- new_ = new .lower ()
398
- if new_ == "orjson" and orjson :
399
- self .pack = orjson_packer
400
- self .unpack = orjson_unpacker
401
- self .packer = self .unpacker = new
402
- elif new_ in ["json" , "orjson" ]:
403
- self .pack = json_packer
404
- self .unpack = json_unpacker
405
- self .packer = self .unpacker = new
406
- elif new_ == "pickle" :
407
- self .pack = pickle_packer
408
- self .unpack = pickle_unpacker
409
- self .packer = self .unpacker = new
410
- elif new_ == "msgpack" :
411
- self .pack = msgpack_packer
412
- self .unpack = msgpack_unpacker
413
- self .packer = self .unpacker = new
396
+ new = change ["new" ].lower ()
397
+ if new == "orjson" and orjson :
398
+ self .pack , self .unpack = orjson_packer , orjson_unpacker
399
+ elif new == "json" or new == "orjson" :
400
+ self .pack , self .unpack = json_packer , json_unpacker
401
+ elif new == "pickle" :
402
+ self .pack , self .unpack = pickle_packer , pickle_unpacker
403
+ elif new == "msgpack" and msgpack :
404
+ self .pack , self .unpack = msgpack_packer , msgpack_unpacker
414
405
else :
415
- obj = import_item (str (new ))
406
+ obj = import_item (str (change [ " new" ] ))
416
407
name = "pack" if change ["name" ] == "packer" else "unpack"
417
408
self .set_trait (name , obj )
409
+ return
410
+ self .packer = self .unpacker = change ["new" ]
418
411
419
412
session = CUnicode ("" , config = True , help = """The UUID identifying this session.""" )
420
413
0 commit comments