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
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters