On Tue, 12 May 2026 at 09:52, Rob Cliffe <[email protected]> wrote:
> Do I need to install Python 3.15 to try it?
> I did try it (before posting) with Python 3.13, using the outline
> implementation from the PEP;
> it allowed me to create 2 sentinels but  failed when I tried
> pickle.dumps on the first one with
> _pickle.PicklingError: Can't pickle MISSING: attribute lookup MISSING on
> __main__ failed
> Even when I just create one sentinel:
>
> MISSING1 = sentinel("MISSING")
> D1 = pickle.dumps(MISSING1)
>
> I get the same error.

Correct. If you don't match the name, it is not picklable. The error
message makes this clear: if it's not available as that attribute of
that module, it cannot be pickled.

> Maybe it would be different with Python 3.15.
> Are you telling me that trying to create 2 sentinels with an identical
> string would raise an Exception in 3.15?

No, but they won't be picklable. Though I wouldn't recommend ever
doing this, as they will have the same repr and will cause confusion.

ChrisA
-- 
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to