Message393580
I recently noticed that some functions use sentinel values to differentiate between not having been passed any value vs. None. One example of this is traceback.print_exception(), hence I'm adding Irit to the nosy list.
However, using e.g. `sentinel = object()` or a single instance of a dedicated class/type can break when combined with pickling (see examples below).
Since these sentinel are usually compared using the `is` operator, having more than a single instance will break things, sometimes in very confusing ways.
I suggest ensuring that a single instance is always used, probably by using a class with a __new__() method making sure to always return a single instance.
>>> sentinel = object()
>>> sentinel2 = pickle.loads(pickle.dumps(sentinel))
>>> sentinel is sentinel2
False
>>> sentinel
<object object at 0x7fd00a986560>
>>> sentinel2
<object object at 0x7fd00a986500>
>>> class A:
... pass
...
>>> a = A()
>>> a2 = pickle.loads(pickle.dumps(a))
>>> a is a2
False
>>> a
<__main__.A object at 0x7fd00a9972f0>
>>> a2
<__main__.A object at 0x7fd009599450> |
|
Date |
User |
Action |
Args |
2021-05-13 13:17:06 | taleinat | set | recipients:
+ taleinat, iritkatriel |
2021-05-13 13:17:06 | taleinat | set | messageid: <1620911826.39.0.0347354211372.issue44123@roundup.psfhosted.org> |
2021-05-13 13:17:06 | taleinat | link | issue44123 messages |
2021-05-13 13:17:06 | taleinat | create | |
|