[proxy] github.com← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

bpo-32176: Set CO_NOFREE in the code object constructor by ncoghlan · Pull Request #4675 · python/cpython

the-knights-who-say-ni

Previously, CO_NOFREE was set in the compiler, which meant
it could end up being set incorrectly when code objects
were created directly. Setting it in the constructor based
on freevars and cellvars ensures it is always accurate,
regardless of how the code object is defined.

- use a non-dunder name for the injected function
- remove some code branches not actually needed for the test
- transform the value to ensure the injected method is running
- don't print anything as a side effect of running the test
- print the code flags as hex if the test assertion fails

ncoghlan added a commit to ncoghlan/cpython that referenced this pull request

Dec 3, 2017

…GH-4675)

Previously, CO_NOFREE was set in the compiler, which meant
it could end up being set incorrectly when code objects
were created directly. Setting it in the constructor based
on freevars and cellvars ensures it is always accurate,
regardless of how the code object is defined..
(cherry picked from commit 078f181)

ncoghlan deleted the issue-32176-class-cell-injection branch

March 30, 2018 07:52