-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Add a method to importlib.abc.SourceLoader for converting source to a code object #59832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A classmethod called importlib.abc.SourceLoader.source_to_code(source_bytes, path) would return a code object. By default it would be equivalent to |
Might name this compile_source() instead. |
Though I haven't been able to get to this, I do have a demo of sorts that I've been using elsewhere: https://bitbucket.org/ericsnowcurrently/pylt/src/default/pylt/_importing.py?at=default#cl-225 |
We might want an keyword-only 'optimize' argument that maps to the compile() function's 'optimize' argument. |
New changeset e30bcce5c634 by Brett Cannon in branch 'default': |
Sorry, just now digging out of a massive backlog here. The originally proposed name of "source_to_code()" might be more appropriate than compile_source(). The relationship to compilation is not compulsory and the name/docstring/docs might imply that. If you're not opposed, Brett, I can make the change. Regardless, glad to see this in. :) |
It might not be compulsory, but how else are you going to get a code object? Then again, get_code() kind of codifies the use of the word "code" for methods that return a code object. So if you want to do the work to change the name then go ahead. |
New changeset 7caab48f171e by Eric Snow in branch 'default': |
The first commit does something fishy with tests: http://hg.python.org/cpython/rev/e30bcce5c634#l3.1 |
It cleans up the run_unittest() call. You can check the file and see that the "missing" classes are actually not in the module anymore. |
Ah, okay. I can’t wait for the time when unittest.main() is used everywhere and we delete run_unittest :) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: