GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||
GeezerVison is showing github.com — bpo-43901: Lazy-create an empty annotations dict in all unannotated user classes and modules by larryhastings · Pull Request #25623 · python/cpython Conversation
|
|
I've marked it as draft because it's not ready for merging. In particular, it needs unit tests for this new behavior. I uploaded the PR so we might get a head start on reviewing the changes. In its current state it does pass the unit test suite. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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.
Added a test to ensure that the new C getsetdef for __annotations__ doesn't interfere with classes (or metaclasses!) redefining __annotations__ using the descriptor protocol.
|
I think this is ready for review. I have test coverage for all the new lines of code. Everything seems to work. It's as good as I can make it without adult supervision. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@larryhastings: Please replace |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.