Workaround Python3.9 limitations in test_jit_py3#51088
Conversation
💊 CI failures summary and remediationsAs of commit ff8869c (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
In Python-3.9 and above `inspect.getsource` of a local class does not work if it was marked as default, see https://bugs.python.org/issue42666 #49617 Workaround by defining `make_global` function that programmatically acomplishes the same
79391d9 to
ff8869c
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Looks good to me, thank you! At the risk of pointing out the obvious: An alternative to changing the how to make global could be to re-implement the old inspect way of finding the source code. This could be advantageous for users that run into this, but I wouldn't know if it is common. Finding class source code is superhacky in Python... |
100% agree with you here, sounds like a good enhancement on the |
|
The @t-vi: can you point me to the "old way" of doing inspect? |
Yes - we call |
|
The change that breaks our tests appears to be python/cpython#10307 Now, I will grant them that the old way of "just match a regexp" is far from ideal, either. I didn't try but now that I look more closely, maybe the correct solution would be to augment the When I tried to propose Python adding source file information to classes (for the benefit of Jupyter), some people on the mailing list suggested exposing the code object defining classes or so, which would give filename + line numbers. Having the file + line numbers would, of course, make this robust and trivial. The technical aspects of getting Python to have proper source annotations for their classes aren't hard, but the process of getting that type of thing into Python heavy-handed enough to make me give up: you'd need a PEP with performance considerations, breakage opportunities (someone's code will assume that anything with a code object is a function etc.). |
Summary: In Python-3.9 and above `inspect.getsource` of a local class does not work if it was marked as default, see https://bugs.python.org/issue42666 #49617 Workaround by defining `make_global` function that programmatically accomplishes the same Partially addresses issue raised in #49617 Pull Request resolved: #51088 Reviewed By: gmagogsfm Differential Revision: D26069189 Pulled By: malfet fbshipit-source-id: 7cf14b88ae5d2b95d2b0fd852717a9202b86356e
Summary: In Python-3.9 and above `inspect.getsource` of a local class does not work if it was marked as default, see https://bugs.python.org/issue42666 pytorch#49617 Workaround by defining `make_global` function that programmatically accomplishes the same Partially addresses issue raised in pytorch#49617 Pull Request resolved: pytorch#51088 Reviewed By: gmagogsfm Differential Revision: D26069189 Pulled By: malfet fbshipit-source-id: 7cf14b88ae5d2b95d2b0fd852717a9202b86356e
In Python-3.9 and above
inspect.getsourceof a local class does not work if it was marked as default, see https://bugs.python.org/issue42666 #49617Workaround by defining
make_globalfunction that programmatically accomplishes the samePartially addresses issue raised in #49617