◐ Shell
clean mode source ↗

bpo-43901: Lazy-create an empty annotations dict in all unannotated user classes and modules by larryhastings · Pull Request #25623 · python/cpython

@larryhastings

I copied some code from module_dir into module_{get|set}_annotations().
It seemed like it had a minor flaw: if the module dict failed a
PyDict_Check(), it wanted to raise an exception.  But to raise the
exception, it wanted the name of the module, and if getting the name
failed it skipped raising the exception.  It turns out, if getting
the name of the module fails, *that* raises an exception too.  So,
rather than stomp on that exception, we should do the same thing
module_dir() does: leave that exception alone and return an error.