On Thu, Aug 2, 2018 at 10:06 PM Alexandre Brault <abrault@mapgears.com> wrote:
I would make the opposite argument and claim that since when policy is None mangle_from_ is initialised to True and not None, None is likely not a potential value for policy.mangle_from_. Looking at Lib/email/_policybase.py where the abstract policy class in question is defined, policies default their mangle_from_ to False, which gives additional credence to the notion that policy.mangle_from_ is not meant to be None.

After looking at the code a bit more, I agree, we've uncovered a bug in the stdlib and the null coalescing version actually fixes it.

So yes, *strictly speaking* the two chunks of code are not exactly the same. In practice, they'll act the same way given sensible inputs.

But!  We are not here to talk about bugs in the email package, this discussion is about PEP 505, which means to me that the example is a bug in the PEP.  In my view, the before and after examples should have identical results, unless there is some very clear and thorough discussion accompanying the example as to why they are different and more importantly, why the "after" version is better or worse.  In this light, the example certainly needs a lot of work.