In the relevant code, is policy.mangle_from_ ever None?
That's impossible to know, since the initializer where this code originally appears puts no constraints on the value of 'policy', it's just assumed to have a 'mangle_from_' member... I would be paranoid and assume, yes, it can take on a value of None as there's nothing to indicate that it can't.
class Generator:
...
def __init__(self, outfp, mangle_from_=None, maxheaderlen=None, *,
policy=None):
...
if mangle_from_ is None:
mangle_from_ = True if policy is None else policy.mangle_from_
self._fp = outfp
self._mangle_from_ = mangle_from_