pytest icon indicating copy to clipboard operation
pytest copied to clipboard

Implement PEP 302 optional get_code loader method

Open P403n1x87 opened this issue 8 months ago • 3 comments

We implement the optional get_code loader method. This increases compatibility with other tools/libraries that need to manipulate the code object of a module before it is executed.

P403n1x87 avatar Mar 20 '25 11:03 P403n1x87

unless there is a compelling example where this helps im opposed to the change as it introduces fragile state just to introduce one optional old method

RonnyPfannschmidt avatar Mar 20 '25 13:03 RonnyPfannschmidt

unless there is a compelling example where this helps

Here's one concrete example where we have to work around this https://github.com/DataDog/dd-trace-py/pull/12812

optional old method

I'm not sure I understand the meaning of "old" here 🤔 . I think implementing this method is good courtesy to other libraries that might have the need to interact with the code object. Here pytest is making the assumption that it is the only tool to manipulate code object, and therefore feels no need to implement get_code.

P403n1x87 avatar Mar 20 '25 13:03 P403n1x87

please understand that composing a PR about a import behavior changes in the github ux that adds state that may be fragile in multiple steps wit errors and without providing background for the need creates a bias

RonnyPfannschmidt avatar Mar 20 '25 13:03 RonnyPfannschmidt