summaryrefslogtreecommitdiff
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* Fix indentation of many ast_error() callsGuido van Rossum2019-03-051-11/+11
|
* Check flags isn't NULL before dereferencing (this broke regen-importlib)Guido van Rossum2019-03-051-1/+1
|
* Complete feature_version implementation (except loose ends)Guido van Rossum2019-03-053-117/+120
| | | | | | | | This adds: - Add ASYNC/AWAIT tokens back to Grammar and regenerate - Recognize async/await keywords conditionally if feature_version < 7 - Reject await expressions if feature_version < 5 - Docs for ASYNC/AWAIT tokens and for ast.parse(..., feature_version=N)
* Implement further restrictions on feature_versionGuido van Rossum2019-03-051-1/+54
| | | | | | | | | | | | | | | This is everything currently in typeshed except await expressions (but it does reject async functions etc.): - Reject async functions and async for/with in minor versions < 5 - Reject async comprehensions in minor versions < 6 - Reject underscores in numeric literals in minor versions < 6 - Reject variable annotations in minor versions < 6 - Reject `X @= Y` in minor versions < 5
* Work towards feature_version supportGuido van Rossum2019-03-056-12/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Visible behavior: - Issue error for `X @ Y` (matrix multiply) if c_feature_version < 5 - Add optional feature_version kw arg to ast.parse() (default -1 which implies PY_MINOR_VERSION) - Add feature_version: int = -1 to compile() (via Argument Clinic); this sets cf_feature_version to the given value if >= 0, else defaults to PY_MINOR_VERSION Implementation: - Add PyAST_obj2mod_ex(): like PyAST_obj2mod() but with feature_version arg; the latter calls the former with PY_MINOR_VERSION - Add cf_feature_version to PyCompilerFlags structure; initialized to PY_MINOR_VERSION everywhere - Add c_feature_version to struct compiling; initialize from cf_feature_version - Add 'c' argument to get_operator() - In builtin eval() and exec(), default to PY_MINOR_VERSION TODO: - Put version-dependent ASYNC/AWAIT keyword scanning back - Reject async functions, await expressions, and async for/with in minor versions < 5 - Reject async comprehensions in minor versions < 6 - Reject underscores in numeric literals in minor versions < 6 - Reject variable annotations in minor versions < 6 - Reject `X @= Y` in minor versions < 5
* bpo-36187: Remove NamedStore. (GH-12167)Serhiy Storchaka2019-03-054-141/+97
| | | | | NamedStore has been replaced with Store. The difference between NamedStore and Store is handled when precess the NamedExpr node one level upper.
* bpo-36142: Add _PyPreConfig.allocator (GH-12181)Victor Stinner2019-03-054-23/+72
| | | | | | * Move 'allocator' and 'dev_mode' fields from _PyCoreConfig to _PyPreConfig. * Fix InitConfigTests of test_embed: dev_mode sets allocator to "debug", add a new tests for env vars with dev mode enabled.
* bpo-36142: Add _PyPreConfig.utf8_mode (GH-12174)Victor Stinner2019-03-054-341/+417
| | | | | | | | | | | | * Move following fields from _PyCoreConfig to _PyPreConfig: * coerce_c_locale * coerce_c_locale_warn * legacy_windows_stdio * utf8_mode * _PyPreConfig_ReadFromArgv() is now responsible to choose the filesystem encoding * _PyPreConfig_Write() now sets the LC_CTYPE locale
* bpo-36142: Add _PyPreConfig_ReadFromArgv() (GH-12173)Victor Stinner2019-03-055-40/+168
| | | | The new function is now responsible to parse -E and -I command line arguments.
* bpo-36142: Add _PyPreConfig structure (GH-12172)Victor Stinner2019-03-054-34/+151
| | | | | | * Add _PyPreConfig structure * Move 'ignored' and 'use_environment' fields from _PyCoreConfig to _PyPreConfig * Add a new "_PyPreConfig preconfig;" field to _PyCoreConfig
* Revert: bpo-33608: Factor out a private, per-interpreter ↵Victor Stinner2019-03-044-231/+151
| | | | | | | | | | | | | | | | | | | _Py_AddPendingCall(). (GH-11617) (GH-12159) * Revert "bpo-36097: Use only public C-API in the_xxsubinterpreters module (adding as necessary). (#12003)" This reverts commit bcfa450f210074e16feb761ae5b3e966a2532fcf. * Revert "bpo-33608: Simplify ceval's DISPATCH by hoisting eval_breaker ahead of time. (gh-12062)" This reverts commit bda918bf65a88560ec453aaba0758a9c0d49b449. * Revert "bpo-33608: Use _Py_AddPendingCall() in _PyCrossInterpreterData_Release(). (gh-12024)" This reverts commit b05b711a2cef6c6c381e01069dedac372e0b9fb2. * Revert "bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). (GH-11617)" This reverts commit ef4ac967e2f3a9a18330cc6abe14adb4bc3d0465.
* bpo-31904: Add encoding support for VxWorks RTOS (GH-12051)pxinwr2019-03-042-4/+4
| | | | | | | | Use UTF-8 as the system encoding on VxWorks. The main reason are: 1. The locale is frequently misconfigured. 2. Missing some functions to deal with locale in VxWorks C library.
* bpo-36097: Use only public C-API in the_xxsubinterpreters module (adding as ↵Eric Snow2019-03-011-2/+24
| | | | necessary). (#12003)
* bpo-35808: Retire pgen and use pgen2 to generate the parser (GH-11814)Pablo Galindo2019-03-011-846/+832
| | | | | Pgen is the oldest piece of technology in the CPython repository, building it requires various #if[n]def PGEN hacks in other parts of the code and it also depends more and more on CPython internals. This commit removes the old pgen C code and replaces it for a new version implemented in pure Python. This is a modified and adapted version of lib2to3/pgen2 that can generate grammar files compatibles with the current parser. This commit also eliminates all the #ifdef and code branches related to pgen, simplifying the code and making it more maintainable. The regen-grammar step now uses $(PYTHON_FOR_REGEN) that can be any version of the interpreter, so the new pgen code maintains compatibility with older versions of the interpreter (this also allows regenerating the grammar with the current CI solution that uses Python3.5). The new pgen Python module also makes use of the Grammar/Tokens file that holds the token specification, so is always kept in sync and avoids having to maintain duplicate token definitions.
* bpo-33608: Simplify ceval's DISPATCH by hoisting eval_breaker ahead of time. ↵Eric Snow2019-03-011-2/+3
| | | | | (gh-12062) This includes fixes to various _Py_atomic_* macros.
* bpo-33608: Use _Py_AddPendingCall() in _PyCrossInterpreterData_Release(). ↵Eric Snow2019-03-011-39/+42
| | | | | | (gh-12024)
* bpo-36142: Add preconfig.c (GH-12128)Victor Stinner2019-03-012-80/+95
| | | | | * Add _PyArgv_Decode() function * Move _Py_ClearFileSystemEncoding() and _Py_SetFileSystemEncoding() to preconfig.c.
* bpo-36142: Move command line parsing to coreconfig.c (GH-12123)Victor Stinner2019-03-011-20/+955
| | | | | | | | | | | | | | | * Add _PyCoreConfig_ReadFromArgv() function which parses command line options: move code from main.c to coreconfig.c. * Add _PyCoreConfig_Write() to write the new configuration: coerce the LC_CTYPE locale, set Py_xxx global configuration variables, etc. * _PyCoreConfig_ReadFromArgv() now only changes the LC_CTYPE locale temporarily. _PyCoreConfig_Write() becomes responsible to set the LC_CTYPE locale. * Add _Py_SetArgcArgv() and _Py_ClearArgcArgv() functions * Rename many "pymain_xxx()" functions * Add "const" to some function parameters * Reorganize main.c to declare functions in the order in which they are called.
* bpo-36142: Remove _PyMain structure (GH-12120)Victor Stinner2019-03-011-0/+8
| | | | | | | | | | | | | * Move fields from _PyMain to _PyCoreConfig: * skip_first_line * run_command * run_module * run_filename * Replace _PyMain.stdin_is_interactive with a new stdin_is_interactive(config) function * Rename _PyMain to _PyArgv. Add "const _PyArgv *args" field to _PyCmdline.
* bpo-36142: Rework error reporting in pymain_main() (GH-12113)Victor Stinner2019-03-013-9/+14
| | | | | | | | | | | Add a new _Py_INIT_EXIT() macro to be able to exit Python with an exitcode using _PyInitError API. Rewrite function calls by pymain_main() to use _PyInitError. Changes: * Remove _PyMain.err and _PyMain.status field * Add _Py_INIT_EXIT() macro and _PyInitError.exitcode field. * Rename _Py_FatalInitError() to _Py_ExitInitError().
* bpo-36142: Exclude coreconfig.h from Py_LIMITED_API (GH-12111)Victor Stinner2019-03-014-0/+4
| | | | | | | | | The whole coreconfig.h header is now excluded from Py_LIMITED_API. Move functions definitions into a new internal pycore_coreconfig.h header. * Move Include/coreconfig.h to Include/cpython/coreconfig.h * coreconfig.h header is now excluded from Py_LIMITED_API * Move functions to pycore_coreconfig.h
* bpo-36030: Remove _PyStack_AsTuple() and _PyStack_AsTupleSlice() (GH-12032)Sergey Fedoseev2019-02-251-1/+2
|
* bpo-36030: Add _PyTuple_FromArray() function (GH-11954)Sergey Fedoseev2019-02-251-6/+1
|
* bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)Serhiy Storchaka2019-02-258-66/+174
|
* bpo-36048: Use __index__() instead of __int__() for implicit conversion if ↵Serhiy Storchaka2019-02-251-1/+3
| | | | | | available. (GH-11952) Deprecate using the __int__() method in implicit conversions of Python numbers to C integers.
* bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). ↵Eric Snow2019-02-244-111/+165
| | | | | | | (GH-11617) This involves moving the global "pending calls" state to PyInterpreterState. https://bugs.python.org/issue33608
* bpo-36101: remove non-ascii characters in docstring (GH-12018)animalize2019-02-252-4/+4
| | | | | * remove non-ascii characters in docstring * clinic.py emits a warning when docstring has non-ascii character
* bpo-35724: Explicitly require the main interpreter for signal-handling. ↵Eric Snow2019-02-231-1/+8
| | | | | | | (GH-11530) Ensure that the main interpreter is active (in the main thread) for signal-handling operations. This is increasingly relevant as people use subinterpreters more. https://bugs.python.org/issue35724
* bpo-35886: Make PyInterpreterState an opaque type in the public API. (GH-11731)Eric Snow2019-02-231-0/+11
| | | Move PyInterpreterState into the "internal" header files.
* bpo-36052: Raise a SyntaxError when assigning a value to __debug__ with := ↵Stéphane Wirtel2019-02-211-1/+1
| | | | | | | (GH-11958) Trying to assign a value to __debug__ using the assignment operator is supposed to fail, but a missing check for forbidden names when setting the context in the ast was preventing this behaviour.
* Re-init _Py_UnhandledKeyboardInterrupt before run. (GH-11963)Gregory P. Smith2019-02-201-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-35993: Fix _PyInterpreterState_DeleteExceptMain() (GH-11852)Stéphane Wirtel2019-02-201-2/+5
| | | Fix a crash on fork when using subinterpreters.
* bpo-12822: use monotonic clock for condvar if possible (GH-11723)Inada Naoki2019-02-203-47/+75
|
* bpo-36049: Fix compiler warning in Python/ast.c (GH-11949)Pablo Galindo2019-02-191-1/+1
|
* bpo-1054041: Exit properly after an uncaught ^C. (#11862)Gregory P. Smith2019-02-162-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-35798: Fix duplicate SyntaxWarning: "is" with a literal. (GH-11639)Serhiy Storchaka2019-02-161-3/+3
|
* bpo-15248: Emit a compiler warning when missed a comma before tuple or list. ↵Serhiy Storchaka2019-02-161-6/+140
| | | | (GH-11757)
* bpo-35972: _xxsubinterpreters: Fix potential integer truncation on 32-bit in ↵Alexey Izbyshev2019-02-121-2/+6
| | | | channel_send() (gh-11822)
* Complete switch cases in symtable.c; fixes bpo-35963 (GH-11821)Guido van Rossum2019-02-111-0/+4
|
* bpo-35766 follow-up: Add an error check to new_type_comment() (#11766)Guido van Rossum2019-02-111-0/+2
| | | | If PyUnicode_DecodeUTF8() returns NULL, PyArena_AddPyObject() would crash. Found by @msullivan for https://github.com/python/typed_ast/pull/93.
* Fix compiler warning about non initialised variable (GH-11806)Pablo Galindo2019-02-101-2/+2
|
* Fix compiler warnings about end_col_offset and end_lineno (GH-11735)Ivan Levkivskyi2019-02-101-5/+2
|
* bpo-35321: Set the spec origin to frozen in frozen modules (#11732)Nina Zakharenko2019-02-041-656/+657
| | | | | | | | | | * bpo-35321: Set the spec origin to frozen in frozen modules This fix correctly sets the spec origin to "frozen" for the _frozen_importlib module. Note that the origin was already correctly set in _frozen_importlib_external. * 📜🤖 Added by blurb_it.
* bpo-35890 : Fix some API calling consistency (GH-11742)Minmin Gong2019-02-022-6/+12
| | | | Unicode version of Windows APIs are used in places, but not for GetVersionEx in Python/sysmodule.c The wcstok_s is called on Windows in Modules/main.c and PC/launcher.c, but not in Python/pathconfig.c
* bpo-33895: Relase GIL while calling functions that acquire Windows loader ↵Tony Roberts2019-02-022-0/+8
| | | | | lock (GH-7789) LoadLibrary, GetProcAddress, FreeLibrary and GetModuleHandle acquire the system loader lock. Calling these while holding the GIL will cause a deadlock on the rare occasion that another thread is detaching and needs to destroy its thread state at the same time.
* bpo-33316: PyThread_release_lock always fails (GH-6541)native-api2019-02-021-2/+3
| | | Use correct interpretation of return value from APIs.
* bpo-35879: Fix type comment leaks (GH-11728)Guido van Rossum2019-02-011-3/+8
| | | | | * Fix leak for # type: ignore * Fix the type comment leak
* bpo-35877: Make parenthesis optional for named expression in while statement ↵Xtreak2019-02-011-1/+1
| | | | | | | | (GH-11724) * Add parenthesis optional in named expressions for while statement * Add NEWS entry
* bpo-35766 follow-up: Kill half-support for FunctionType in PyAST_obj2mod ↵Guido van Rossum2019-02-011-3/+2
| | | | | | | (#11714) See https://github.com/python/cpython/pull/11645/files/229874c612df868e7ae3e997e159915f49d16542#r252631862 https://bugs.python.org/issue35766
* bpo-35766: Merge typed_ast back into CPython (GH-11645)Guido van Rossum2019-01-315-520/+1343
|