-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-142349: Implement PEP 810 #142351
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
base: main
Are you sure you want to change the base?
gh-142349: Implement PEP 810 #142351
Conversation
…s on bad usage of lazy
Highlight lazy imports in the new REPL
* Update example to add missing import * Add link to lazy keyword * Update documentation
* PEP-7 for import.c * re-order imports * fix tests * some final nits * alter other file * alter sysmodule.c
…ces, and prefer using `//` for comments instead of `/* */`.
…ariable names in lazy_import_new
Remove `get_lazy_modules` from docs
| .. c:function:: int PyImport_SetLazyImportsMode(PyImport_LazyImportsMode mode) | ||
| Similar to :c:func:`PyImport_ImportModuleAttr`, but names are UTF-8 encoded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy-paste error? This seems unrelated to the function being described.
|
|
||
| print('json' in sys.modules) # True - now loaded | ||
|
|
||
| If an error occurs during module loading (such as :exc:`ImportError` or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps also document that ImportCycleError may be raised?
| 1 LOAD_SMALL_INT 0 | ||
| LOAD_CONST 1 (('*',)) | ||
| IMPORT_NAME 0 (math) | ||
| IMPORT_NAME 2 (math + eager) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding more tests for the new logic in dis.py.
| try: | ||
| lazy import os | ||
| except: | ||
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about putting it in the except:?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a commit to address
lazy import within an except block. Also removed unused var.
📚 Documentation preview 📚: https://cpython-previews--142351.org.readthedocs.build/