summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35975: Support parsing earlier minor versions of Python 3 (GH-12086)Guido van Rossum2019-03-071-0/+6
| | | | | | | This adds a `feature_version` flag to `ast.parse()` (documented) and `compile()` (hidden) that allow tweaking the parser to support older versions of the grammar. In particular if `feature_version` is 5 or 6, the hacks for the `async` and `await` keyword from PEP 492 are reinstated. (For 7 or higher, these are unconditionally treated as keywords, but they are still special tokens rather than `NAME` tokens that the parser driver recognizes.) https://bugs.python.org/issue35975
* Re-init _Py_UnhandledKeyboardInterrupt before run. (GH-11963)Gregory P. Smith2019-02-211-0/+11
| | | | | | | | | | Explicitly reinitialize this every eval *just in case* someone is calling into an embedded Python where they don't care about an uncaught KeyboardInterrupt exception (why didn't they leave `config.install_signal_handlers` set to `0`?!?) but then later call `Py_Main()` itself (which *checks* this flag and dies with a signal after its interpreter exits). We don't want a previous embedded interpreter's uncaught exception to trigger an unexplained signal exit from a future `Py_Main()` based one.
* bpo-1054041: Exit properly after an uncaught ^C. (#11862)Gregory P. Smith2019-02-161-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bpo-1054041: Exit properly by a signal after a ^C. An uncaught KeyboardInterrupt exception means the user pressed ^C and our code did not handle it. Programs that install SIGINT handlers are supposed to reraise the SIGINT signal to the SIG_DFL handler in order to exit in a manner that their calling process can detect that they died due to a Ctrl-C. https://www.cons.org/cracauer/sigint.html After this change on POSIX systems while true; do python -c 'import time; time.sleep(23)'; done can be stopped via a simple Ctrl-C instead of the shell infinitely restarting a new python process. What to do on Windows, or if anything needs to be done there has not yet been determined. That belongs in its own PR. TODO(gpshead): A unittest for this behavior is still needed. * Do the unhandled ^C check after pymain_free. * Return STATUS_CONTROL_C_EXIT on Windows. * Fix ifdef around unistd.h include. * 📜🤖 Added by blurb_it. * Add STATUS_CTRL_C_EXIT to the os module on Windows * Add unittests. * Don't send CTRL_C_EVENT in the Windows test. It was causing CI systems to bail out of the entire test suite. See https://dev.azure.com/Python/cpython/_build/results?buildId=37980 for example. * Correct posix test (fail on macOS?) check. * STATUS_CONTROL_C_EXIT must be unsigned. * Improve the error message. * test typo :) * Skip if the bash version is too old. ...and rename the windows test to reflect what it does. * min bash version is 4.4, detect no bash. * restore a blank line i didn't mean to delete. * PyErr_Occurred() before the Py_DECREF(co); * Don't add os.STATUS_CONTROL_C_EXIT as a constant. * Update the Windows test comment. * Refactor common logic into a run_eval_code_obj fn.
* bpo-35766: Merge typed_ast back into CPython (GH-11645)Guido van Rossum2019-01-311-0/+2
|
* bpo-30167: Remove __cached__ from __main__ when removing __file__ (GH-7415)INADA Naoki2018-11-291-2/+8
|
* bpo-35177, Python-ast.h: Fix "Yield" compiler warning (GH-10664)Victor Stinner2018-11-221-0/+1
| | | | | | | | Partially revert commit 5f2df88b63e50d23914e97ec778861a52abdeaad: add "#undef Yield" to .c files after including Python-ast.h. Fix the warning: winbase.h(102): warning C4005: 'Yield': macro redefinition
* bpo-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-121-1/+1
| | | | | | | | | | | | | | Rename Include/internal/ headers: * pycore_hash.h -> pycore_pyhash.h * pycore_lifecycle.h -> pycore_pylifecycle.h * pycore_mem.h -> pycore_pymem.h * pycore_state.h -> pycore_pystate.h Add missing headers to Makefile.pre.in and PCbuild: * pycore_condvar.h. * pycore_hamt.h * pycore_pyhash.h
* bpo-35177: Add dependencies between header files (GH-10361)Victor Stinner2018-11-111-1/+0
| | | | | | | | | | | | | | * ast.h now includes Python-ast.h and node.h * parsetok.h now includes node.h and grammar.h * symtable.h now includes Python-ast.h * Modify asdl_c.py to enhance Python-ast.h: * Add #ifndef/#define Py_PYTHON_AST_H to be able to include the header twice * Add "extern { ... }" for C++ * Undefine "Yield" macro conflicting with winbase.h * Remove "#undef Yield" from C files, it's now done in Python-ast.h * Remove now useless includes in C files
* bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | * Rename Include/internal/ header files: * pyatomic.h -> pycore_atomic.h * ceval.h -> pycore_ceval.h * condvar.h -> pycore_condvar.h * context.h -> pycore_context.h * pygetopt.h -> pycore_getopt.h * gil.h -> pycore_gil.h * hamt.h -> pycore_hamt.h * hash.h -> pycore_hash.h * mem.h -> pycore_mem.h * pystate.h -> pycore_state.h * warnings.h -> pycore_warnings.h * PCbuild project, Makefile.pre.in, Modules/Setup: add the Include/internal/ directory to the search paths of header files. * Update includes. For example, replace #include "internal/mem.h" with #include "pycore_mem.h".
* bpo-34653: Removed unused function PyParser_SimpleParseStringFilename. (GH-9260)Eric V. Smith2018-09-131-6/+0
| | | | | | This function was not in any .h file and was not used by Python, so removing it is safe. https://bugs.python.org/issue34653
* closes bpo-34646: Remove PyAPI_* macros from declarations. (GH-9218)Benjamin Peterson2018-09-121-16/+16
|
* bpo-34301: Add _PyInterpreterState_Get() helper function (GH-8592)Victor Stinner2018-08-031-6/+2
| | | | sys_setcheckinterval() now uses a local variable to parse arguments, before writing into interp->check_interval.
* bpo-34084: Fix setting an error message for the "Barry as BDFL" easter egg. ↵Serhiy Storchaka2018-07-231-0/+4
| | | | (GH-8262)
* bpo-34080: Fix a memory leak in the compiler. (GH-8222)Serhiy Storchaka2018-07-111-1/+1
|
* bpo-24596: Decref module in PyRun_SimpleFileExFlags() on SystemExit (GH-7918)Zackery Spytz2018-07-031-1/+2
| | | | PyErr_Print() will not return when the exception is a SystemExit, so decref the __main__ module object in that case.
* bpo-33451: Close pyc files before calling PyEval_EvalCode() (GH-7884)Zackery Spytz2018-06-241-6/+9
| | | Directly executed pyc files were being kept open longer than necessary.
* bpo-33818: PyExceptionClass_Name() will now return "const char *". (GH-7581)Serhiy Storchaka2018-06-151-2/+2
|
* closes bpo-31650: PEP 552 (Deterministic pycs) implementation (#4575)Benjamin Peterson2017-12-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Python now supports checking bytecode cache up-to-dateness with a hash of the source contents rather than volatile source metadata. See the PEP for details. While a fairly straightforward idea, quite a lot of code had to be modified due to the pervasiveness of pyc implementation details in the codebase. Changes in this commit include: - The core changes to importlib to understand how to read, validate, and regenerate hash-based pycs. - Support for generating hash-based pycs in py_compile and compileall. - Modifications to our siphash implementation to support passing a custom key. We then expose it to importlib through _imp. - Updates to all places in the interpreter, standard library, and tests that manually generate or parse pyc files to grok the new format. - Support in the interpreter command line code for long options like --check-hash-based-pycs. - Tests and documentation for all of the above.
* bpo-32030: Add more options to _PyCoreConfig (#4485)Victor Stinner2017-11-211-1/+5
| | | | | | Py_Main() now handles two more -X options: * -X showrefcount: new _PyCoreConfig.show_ref_count field * -X showalloccount: new _PyCoreConfig.show_alloc_count field
* bpo-30696: Fix the REPL looping endlessly when no memory (GH-4160)xdegaye2017-11-121-18/+42
|
* Add the const qualifier to "char *" variables that refer to literal strings. ↵Serhiy Storchaka2017-11-111-1/+1
| | | | (#4370)
* bpo-30817: Fix PyErr_PrintEx() when no memory (#2526)xdegaye2017-10-231-3/+9
|
* bpo-28603: Fix formatting tracebacks for unhashable exceptions (#4014)Zane Bitter2017-10-171-3/+18
|
* bpo-30860: Fix a refleak. (#3567)Eric Snow2017-09-141-1/+4
| | | | | Resolves bpo-31420. (This was accidentally reverted when in #3565.)
* bpo-31404: Revert "remove modules from Py_InterpreterState (#1638)" (#3565)Eric Snow2017-09-141-4/+1
| | | PR #1638, for bpo-28411, causes problems in some (very) edge cases. Until that gets sorted out, we're reverting the merge. PR #3506, a fix on top of #1638, is also getting reverted.
* bpo-30860: Fix a refleak. (#3506)Eric Snow2017-09-121-1/+4
| | | | | | | | | | | | | | * Drop warnoptions from PyInterpreterState. * Drop xoptions from PyInterpreterState. * Don't set warnoptions and _xoptions again. * Decref after adding to sys.__dict__. * Drop an unused macro. * Check sys.xoptions *before* we delete it.
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-0/+1
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* bpo-22257: Private C-API for main interpreter initialization (PEP 432). (#1729)Eric Snow2017-05-241-2/+8
| | | (patch by Nick Coghlan)
* bpo-29556: Remove unused #include <langinfo.h> (#98)Yen Chi Hsuan2017-02-151-4/+0
| | | | | | bltinmodule.c: Added in b744ba1 and no longer necessary since d64e8a7 posixmodule.c: Added in d1cd4d4 and no longer necessary since efb00c0 pythonrun.c: Added in 73d538b and no longer necessary since d600951 sysmodule.c: Added in 5467d4c and no longer necessary since a2c17c5
* Issue #25677: Merge SyntaxError caret positioning from 3.6Martin Panter2016-12-191-1/+1
|\
| * Issue #25677: Merge SyntaxError caret positioning from 3.5Martin Panter2016-12-191-1/+1
| |\
| | * Issue #25677: Correct syntax error caret for indented blocks.Martin Panter2016-12-111-1/+1
| | | | | | | | | | | | Based on patch by Michael Layzell.
* | | Added the const qualifier to char* variables that refer to readonly internalSerhiy Storchaka2016-11-201-3/+3
|/ / | | | | | | UTF-8 represenatation of Unicode objects.
* | Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSizeSerhiy Storchaka2016-11-201-4/+4
| | | | | | | | with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
* | Issue #28701: Replace _PyUnicode_CompareWithId with _PyUnicode_EqualToASCIIId.Serhiy Storchaka2016-11-161-1/+1
|\ \ | |/ | | | | | | | | The latter function is more readable, faster and doesn't raise exceptions. Based on patch by Xiang Zhang.
| * Issue #28701: Replace _PyUnicode_CompareWithId with _PyUnicode_EqualToASCIIId.Serhiy Storchaka2016-11-161-1/+1
| | | | | | | | | | | | The latter function is more readable, faster and doesn't raise exceptions. Based on patch by Xiang Zhang.
* | Avoid calling functions with an empty string as format stringVictor Stinner2016-09-061-2/+2
| | | | | | | | Directly pass NULL rather than an empty string.
* | Rename _PyObject_FastCall() to _PyObject_FastCallDict()Victor Stinner2016-08-221-1/+1
| | | | | | | | | | | | | | | | Issue #27809: * Rename _PyObject_FastCall() function to _PyObject_FastCallDict() * Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1() macros calling _PyObject_FastCallDict()
* | PyErr_PrintEx() now uses fast callVictor Stinner2016-08-191-3/+7
| | | | | | | | Issue #27128.
* | Issue #27076: Merge spelling from 3.5Martin Panter2016-05-261-1/+1
|\ \ | |/
| * Issue #27076: Doc, comment and tests spelling fixesMartin Panter2016-05-261-1/+1
| | | | | | | | Most fixes to Doc/ and Lib/ directories by Ville Skyttä.
* | Issue #22836: Merge exception reporting from 3.5Martin Panter2016-02-281-1/+7
|\ \ | |/
| * Issue #22836: Keep exception reports sensible despite errorsMartin Panter2016-02-281-1/+7
| |
* | Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-4/+4
| | | | | | | | private functions.
* | Issue #25923: Added the const qualifier to static constant arrays.Serhiy Storchaka2015-12-251-2/+2
| |
* | Issue #15989: Fixed some scarcely probable integer overflows.Serhiy Storchaka2015-09-061-5/+5
|/ | | | It is very unlikely that they can occur in real code for now.
* Issue #23911: Move path-based bootstrap code to a separate frozen module.Eric Snow2015-05-031-2/+7
|
* Issue #23731: Implement PEP 488.Brett Cannon2015-04-131-4/+1
| | | | | | The concept of .pyo files no longer exists. Now .pyc files have an optional `opt-` tag which specifies if any extra optimizations beyond the peepholer were applied.
* Issue #19428: Handle PyMarshal_Read*() errors in run_pyc_file()Victor Stinner2015-03-181-2/+6
| | | | Detect also earlier PyMarshal_Read*() errors in zipimport.
* Closes #22869: Move PyOS_CheckStack back to pythonrun.cZachary Ware2014-11-221-0/+37
|