Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...REPL loop. To change the way the interpreter prints interactively entered expressions, users will have to rebind sys.displayhook to a callable object. The result of calling this object with the result of the interactively entered expression should be print-able, and this is what will be printed on sys.stdout. Solution The bytecode PRINT_EXPR will call sys.displayhook(POP()). A displayhook() will be added to the sys builtin module, which is equivalent to: import __builtin__ def displayhook(o):...
...REPL Shell Everything works the same inside Python's interactive REPL shell, except for module annotations in the interactive module (__main__) itself. Since that module is never "finished", there's no specific point where we can compile the __co_annotations__ function. For the sake of simplicity, in this case we forego delayed evaluation. Module-level annotations in the REPL shell will continue to work exactly as they do today, evaluating immediately and setting the result directly inside the ...
...REPL), then no changes are needed beyond those in this PEP. Interactive shell implementations which use a namespace other than __main__ will need to add their own filter. For example, IPython uses the following command ([8]) to set up a suitable filter: warnings.filterwarnings("default", category=DeprecationWarning, module=self.user_ns.get("__name__")) Other documentation updates The current reference documentation for the warnings system is relatively shor...
...replace() to make a modified copy: >>> def foo() -> None: ... pass >>> sig = signature(foo) >>> new_sig = sig.replace(return_annotation="new return annotation") >>> new_sig is not sig True >>> new_sig.return_annotation != sig.return_annotation True >>> new_sig.parameters == sig.parameters True >>> new_sig = new_sig.replace(return_annotation=new_sig.empty) >>> new_sig.return_annotation is Signature.empty True There...
...REPL set during runtime init, then treated as immutable mutable, protected by some global lock mutable, atomic Note that currently the allocators (see Objects/obmalloc.c) are shared between all interpreters, protected by the GIL. They will need to move to each interpreter (or a global lock will be needed). This is the highest risk part of the work to isolate interpreters and may require more than just moving fields down from _PyRuntimeState. Some of the complexity is reduced if CPython switc...
...REPL, "-m", and "-c". Just as the interpreter's state is not ever reset, the "__main__" module is never reset. You can imagine concatenating the code from each "run()" call into one long script. This is the same as how the REPL operates. Supported code: source text. Uncaught Exceptions Regarding uncaught exceptions in Interpreter.run(), we noted that they are "effectively" propagated into the code where run() was called. To prevent leaking exceptions (and tra...
...replace what have already been pushed. Not a problem until commits are in a public or shared repository. Undo Whatever you do, don't panic. Almost anything in git can be undone. git checkout: restore file's content git checkout, for example, can be used to restore the content of file(s) to that one of a commit. Like this: git checkout HEAD~ README The commands restores the contents of README file to the last but one commit in the current branch. By default the commit ID is simply HEAD; i.e....
...reply(reply): match reply: case (HttpStatus.OK, MimeType.TEXT, body): process_text(body) case (HttpStatus.OK, MimeType.APPL_ZIP, body): text = deflate(body) process_text(text) case (HttpStatus.MOVED_PERMANENTLY, new_URI): resend_request(new_URI) case (HttpStatus.NOT_FOUND): raise ResourceNotFound() Group Patterns Allowing users to explicitly specify the grouping is particularly helpful in case of O...
...Replace all macros with functions. Replace PyPreConfig_INIT and PyConfig_INIT macros with functions: PyPreConfig_InitIsolatedConfig(), PyConfig_InitIsolatedConfig() PyPreConfig_InitPythonConfig(), PyConfig_InitPythonConfig() PyPreConfig no longer uses dynamic memory, the allocator field type becomes an int, add configure_locale and parse_argv field. PyConfig: rename module_search_path_env to pythonpath_env, rename use_module_search_paths to module_search_paths_set, remove program and dll_path....