summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35336: Fix PYTHONCOERCECLOCALE=1 (GH-10806)Victor Stinner2018-11-301-2/+8
| | | | Fix PYTHONCOERCECLOCALE=1 environment variable: only coerce the C locale if the LC_CTYPE locale is "C".
* bpo-30167: Remove __cached__ from __main__ when removing __file__ (GH-7415)INADA Naoki2018-11-291-2/+8
|
* bpo-34100: compile: Re-enable frozenset merging (GH-10760)INADA Naoki2018-11-281-2/+57
| | | This reverts commit 1005c84535191a72ebb7587d8c5636a065b7ed79.
* bpo-33029: Fix signatures of getter and setter functions. (GH-10746)Serhiy Storchaka2018-11-272-3/+4
| | | Fix also return type for few other functions (clear, releasebuffer).
* bpo-34100: Partially revert merge_consts_recursive() (GH-10743)Victor Stinner2018-11-271-50/+0
| | | | | Partically revert commit c2e1607a51d7a17f143b5a34e8cff7c6fc58a091 to fix a reference leak.
* bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka2018-11-274-14/+14
| | | | | | Fix invalid function cast warnings with gcc 8 for method conventions different from METH_NOARGS, METH_O and METH_VARARGS excluding Argument Clinic generated code.
* bpo-33012: Fix invalid function cast warnings with gcc 8 in Argument Clinic. ↵Serhiy Storchaka2018-11-276-29/+29
| | | | | | | | (GH-6748) Fix invalid function cast warnings with gcc 8 for method conventions different from METH_NOARGS, METH_O and METH_VARARGS in Argument Clinic generated code.
* bpo-31241: Fix AST node position for list and generator comprehensions. ↵Serhiy Storchaka2018-11-272-218/+233
| | | | | | | | (GH-10633) The lineno and col_offset attributes of AST nodes for list comprehensions, generator expressions and tuples are now point to the opening parenthesis or square brace. For tuples without parenthesis they point to the position of the first item.
* bpo-33954: Fix _PyUnicode_InsertThousandsGrouping() (GH-10623)Victor Stinner2018-11-261-18/+22
| | | | | | | | | | | | Fix str.format(), float.__format__() and complex.__format__() methods for non-ASCII decimal point when using the "n" formatter. Changes: * Rewrite _PyUnicode_InsertThousandsGrouping(): it now requires a _PyUnicodeWriter object for the buffer and a Python str object for digits. * Rename FILL() macro to unicode_fill(), convert it to static inline function, add "assert(0 <= start);" and rework its code.
* bpo-34100: Merge constants recursively (GH-8341)INADA Naoki2018-11-264-4594/+4680
| | | | | | | There are some same consts in a module. This commit merges them into single instance. It reduces number of objects in memory after loading modules. https://bugs.python.org/issue34100
* bpo-35081: Add Include/internal/pycore_tupleobject.h (GH-10705)Victor Stinner2018-11-252-0/+2
| | | | Move _PyTuple_ITEMS() to a new header file: Include/internal/pycore_tupleobject.h
* bpo-34523: Fix C locale coercion on FreeBSD CURRENT (GH-10672)Victor Stinner2018-11-232-4/+21
| | | | | | | | bpo-34523, bpo-35290: C locale coercion now resets the Python internal "force ASCII" mode. This change fix the filesystem encoding on FreeBSD CURRENT, which has a new "C.UTF-8" locale, when the UTF-8 mode is disabled. Add _Py_ResetForceASCII(): _Py_SetLocaleFromEnv() now calls it.
* bpo-35177, Python-ast.h: Fix "Yield" compiler warning (GH-10664)Victor Stinner2018-11-225-0/+5
| | | | | | | | 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-18407: ast.c uses Py_ssize_t for asdl_seq_LEN() iterator (GH-10655)Victor Stinner2018-11-221-9/+9
| | | | | | | When iterating using asdl_seq_LEN(), use 'Py_ssize_t' type instead of 'int' for the iterator variable, to avoid downcast on 64-bit platforms. _Py_asdl_int_seq_new() now also ensures that the index is greater than or equal to 0.
* bpo-18407: win32_urandom() uses PY_DWORD_MAX (GH-10656)Victor Stinner2018-11-221-4/+2
| | | | | | CryptGenRandom() maximum size is PY_DWORD_MAX, not INT_MAX. Use DWORD type for the 'chunk' variable Co-Authored-By: Jeremy Kloth <jeremy.kloth@gmail.com>
* bpo-35059: Cast void* to PyObject* (GH-10650)Victor Stinner2018-11-221-3/+4
| | | Don't pass void* to Python macros: use _PyObject_CAST().
* bpo-35081: Add Include/internal/pycore_object.h (GH-10640)Victor Stinner2018-11-213-4/+7
| | | | Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from Include/objimpl.h to Include/internal/pycore_object.h.
* bpo-35169: Improve error messages for forbidden assignments. (GH-10342)Serhiy Storchaka2018-11-201-60/+46
|
* bpo-28604: Fix localeconv() for different LC_MONETARY (GH-10606)Victor Stinner2018-11-202-34/+39
| | | | | | | | | | | | | | | | | | | | | locale.localeconv() now sets temporarily the LC_CTYPE locale to the LC_MONETARY locale if the two locales are different and monetary strings are non-ASCII. This temporary change affects other threads. Changes: * locale.localeconv() can now set LC_CTYPE to LC_MONETARY to decode monetary fields. * Add LocaleInfo.grouping_buffer: copy localeconv() grouping string since it can be replaced anytime if a different thread calls localeconv(). * _Py_GetLocaleconvNumeric() now requires a "struct lconv *" structure, so locale.localeconv() now longer calls localeconv() twice. Moreover, the function now requires all arguments to be non-NULL. * Rename STATIC_LOCALE_INFO_INIT to LocaleInfo_STATIC_INIT. * Move _Py_GetLocaleconvNumeric() definition from fileutils.h to pycore_fileutils.h. pycore_fileutils.h now includes locale.h. * The _locale module is now built with Py_BUILD_CORE defined.
* bpo-34725: Adds _Py_SetProgramFullPath so embedders may override ↵Steve Dower2018-11-182-24/+57
| | | | sys.executable (GH-9860)
* bpo-28401: prevent Py_DEBUG builds from trying to import limited ABI modules ↵Stefano Rivera2018-11-161-0/+2
| | | | | | | | (GH-1766) [Issue 28401](https://bugs.python.org/issue28401): Don't attempt to import the stable API extensions, they are not supported in PyDEBUG builds (which don't implement that ABI). https://bugs.python.org/issue28401
* Add a missed PyErr_NoMemory() in symtable_new(). (GH-10576)Zackery Spytz2018-11-161-1/+3
| | | | This missed PyErr_NoMemory() could cause a SystemError when calling _symtable.symtable().
* bpo-35239: _PySys_EndInit() copies module_search_path (GH-10532)Victor Stinner2018-11-162-5/+25
| | | | | | | | | | | * The _PySys_EndInit() function now copies the config->module_search_path list, so config is longer modified when sys.path is updated. * config->warnoptions list and config->xoptions dict are also copied * test_embed: InitConfigTests now also tests main_config['module_search_path'] * Fix _Py_InitializeMainInterpreter(): don't use config->warnoptions but sys.warnoptions to decide if the warnings module should be imported at startup.
* bpo-35233: InitConfigTests tests more config vars (GH-10541)Victor Stinner2018-11-141-115/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test_embed.InitConfigTests tests more configuration variables. Changes: * InitConfigTests tests more core configuration variables: * base_exec_prefix * base_prefix * exec_prefix * home * legacy_windows_fs_encoding * legacy_windows_stdio * module_search_path_env * prefix * "_testembed init_from_config" tests more variables: * argv * warnoptions * xoptions * InitConfigTests: add check_global_config(), check_core_config() and check_main_config() subfunctions to cleanup the code. Move also constants at the class level (ex: COPY_MAIN_CONFIG). * Fix _PyCoreConfig_AsDict(): don't set stdio_encoding twice * Use more macros in _PyCoreConfig_AsDict() and _PyMainInterpreterConfig_AsDict() to reduce code duplication. * Other minor cleanups.
* bpo-35233: Rewrite test_embed.InitConfigTests (GH-10524)Victor Stinner2018-11-131-0/+75
| | | | | | | | | | | | * Fix _PyCoreConfig_SetGlobalConfig(): set also Py_FrozenFlag * Fix _PyCoreConfig_AsDict(): export also xoptions * Add _Py_GetGlobalVariablesAsDict() and _testcapi.get_global_config() * test.pythoninfo: dump also global configuration variables * _testembed now serializes global, core and main configurations using JSON to reuse _Py_GetGlobalVariablesAsDict(), _PyCoreConfig_AsDict() and _PyMainInterpreterConfig_AsDict(), rather than duplicating code. * test_embed.InitConfigTests now test much more configuration variables
* bpo-35214: Add _Py_ prefix to MEMORY_SANITIZER def. (GH-10503)Gregory P. Smith2018-11-132-3/+3
| | | | Rename our new MEMORY_SANITIZER define to _Py_MEMORY_SANITIZER. Project based C Preprocessor namespacing at its finest. :P
* bpo-35214: Initial clang MemorySanitizer support (GH-10479)Gregory P. Smith2018-11-122-1/+12
| | | | | | | | | | Adds configure flags for msan and ubsan builds to make it easier to enable. These also encode the detail that address sanitizer and memory sanitizer should disable pymalloc. Define MEMORY_SANITIZER when appropriate at build time and adds workarounds to existing code to mark things as initialized where the sanitizer is otherwise unable to determine that. This lets our build succeed under the memory sanitizer. not all tests pass without sanitizer failures yet but we're in pretty good shape after this.
* bpo-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-1219-30/+30
| | | | | | | | | | | | | | 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-117-19/+2
| | | | | | | | | | | | | | * 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-35199: Add an internal _PyTuple_ITEMS() macro (GH-10434)Victor Stinner2018-11-092-4/+4
| | | | | | | * _PyTuple_ITEMS() gives access to the tuple->ob_item field and cast the first argument to PyTupleObject*. This internal macro is only usable if Py_BUILD_CORE is defined. * Replace &PyTuple_GET_ITEM(ob, 0) with _PyTuple_ITEMS(ob). * Replace PyTuple_GET_ITEM(op, 1) with &_PyTuple_ITEMS(ob)[1].
* bpo-35193: Fix an off by one error in the RETURN_VALUE case. (GH-10418)Gregory P. Smith2018-11-091-10/+12
| | | | | | | | | | | | Fix an off by one error in the peephole optimizer when checking for unreachable code beyond a return. Do a bounds check within find_op so it can return before going past the end as a safety measure. https://github.com/python/cpython/commit/7db3c488335168993689ddae5914a28e16188447#diff-a33329ae6ae0bb295d742f0caf93c137 introduced this off by one error while fixing another one nearby. This bug was shipped in all Python 3.6 and 3.7 releases. The included unittest won't fail unless you do a clang msan build.
* bpo-34726: Fix handling of hash-based pycs in zipimport. (GH-10327)Elvis Pranskevichus2018-11-071-1018/+1055
| | | | | | | | Current support for hash-based bytecode files in `zipimport` is rather sparse, which leads to test failures when the test suite is ran with the ``SOURCE_DATE_EPOCH`` environment variable set. This teaches zipimport to handle hash-based pycs properly.
* bpo-35081: Add pycore_fileutils.h (GH-10371)Victor Stinner2018-11-063-0/+3
| | | | Move Py_BUILD_CORE code from Include/fileutils.h to a new Include/internal/pycore_fileutils.h file.
* bpo-35081: Add _PyCoreConfig_AsDict() (GH-10362)Victor Stinner2018-11-061-0/+152
| | | | | | | | | | | | _testcapimodule.c must not include pycore_pathconfig.h, since it's an internal header files. Changes: * Add _PyCoreConfig_AsDict() function to coreconfig.c. * Remove pycore_pathconfig.h include from _testcapimodule.h. * pycore_pathconfig.h now requires Py_BUILD_CORE to be defined. * _testcapimodule.c compilation now fails if it's built with Py_BUILD_CORE defined.
* bpo-35133: Fix mistakes when concatenate string literals on different lines. ↵Serhiy Storchaka2018-11-051-1/+1
| | | | | | | | | | (GH-10284) Two kind of mistakes: 1. Missed space. After concatenating there is no space between words. 2. Missed comma. Causes unintentional concatenating in a list of strings.
* Simplify sys.breakpointhook implementation (#9519)Anthony Sottile2018-11-011-9/+1
|
* bpo-35081: And pycore_lifecycle.h and pycore_pathconfig.h (GH-10273)Victor Stinner2018-11-015-16/+10
| | | | | | | | | | * And pycore_lifecycle.h and pycore_pathconfig.h headers to Include/internal/ * Move Py_BUILD_CORE specific code from coreconfig.h and pylifecycle.h to pycore_pathconfig.h and pycore_lifecycle.h * Move _Py_wstrlist_XXX() definitions and _PyPathConfig code from pycore_state.h to pycore_pathconfig.h * Move "Init" and "Fini" function definitions from pylifecycle.c to pycore_lifecycle.h.
* bpo-35081: Add _PyThreadState_GET() internal macro (GH-10266)Victor Stinner2018-11-0110-65/+65
| | | | | | | | | | | | | | | | | | | | | | | | | If Py_BUILD_CORE is defined, the PyThreadState_GET() macro access _PyRuntime which comes from the internal pycore_state.h header. Public headers must not require internal headers. Move PyThreadState_GET() and _PyInterpreterState_GET_UNSAFE() from Include/pystate.h to Include/internal/pycore_state.h, and rename PyThreadState_GET() to _PyThreadState_GET() there. The PyThreadState_GET() macro of pystate.h is now redefined when pycore_state.h is included, to use the fast _PyThreadState_GET(). Changes: * Add _PyThreadState_GET() macro * Replace "PyThreadState_GET()->interp" with _PyInterpreterState_GET_UNSAFE() * Replace PyThreadState_GET() with _PyThreadState_GET() in internal C files (compiled with Py_BUILD_CORE defined), but keep PyThreadState_GET() in the public header files. * _testcapimodule.c: replace PyThreadState_GET() with PyThreadState_Get(); the module is not compiled with Py_BUILD_CORE defined. * pycore_state.h now requires Py_BUILD_CORE to be defined.
* bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-10-3122-34/+34
| | | | | | | | | | | | | | | | | | | | * 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-26558: Fix Py_FatalError() with GIL released (GH-10267)Victor Stinner2018-10-311-10/+25
| | | | | Don't call _Py_FatalError_PrintExc() nor flush_std_files() if the current thread doesn't hold the GIL, or if the current thread has no Python state thread.
* bpo-35081: Move Py_BUILD_CORE code to internal/mem.h (GH-10249)Victor Stinner2018-10-316-0/+6
| | | | | * Add #include "internal/mem.h" to C files using _PyMem_SetDefaultAllocator(). * Include/internal/mem.h now requires Py_BUILD_CORE to be defined.
* bpo-35081: Move Include/pyatomic.c to Include/internal/ (GH-10239)Victor Stinner2018-10-301-0/+1
| | | Add pyatomic.h to the VS project (it wasn't referenced).
* bpo-35081: Cleanup pystate.c and pystate.h (GH-10240)Victor Stinner2018-10-302-25/+21
| | | | | | | | | | | | * Remove _PyThreadState_Current * Replace GET_TSTATE() with PyThreadState_GET() * Replace GET_INTERP_STATE() with _PyInterpreterState_GET_UNSAFE() * Replace direct access to _PyThreadState_Current with PyThreadState_GET() * Replace _PyThreadState_Current with _PyRuntime.gilstate.tstate_current * Rename SET_TSTATE() to _PyThreadState_SET(), name more consistent with _PyThreadState_GET() * Update outdated comments
* bpo-32030: Make _PySys_AddXOptionWithError() private (GH-10236)Victor Stinner2018-10-301-3/+8
| | | | | | | | Make _PySys_AddXOptionWithError() and _PySys_AddWarnOptionWithError() functions private again. They are no longer needed to initialize Python: _PySys_EndInit() is now responsible to add these options instead. Moreover, PySys_AddWarnOptionUnicode() now clears the exception on failure if possible.
* bpo-34523: Fix config_init_fs_encoding() for ASCII (GH-10232)Victor Stinner2018-10-301-20/+22
| | | | | | | * bpo-34523, bpo-34403: Fix config_init_fs_encoding(): it now uses ASCII if _Py_GetForceASCII() is true. * Fix a regression of commit b2457efc78b74a1d6d1b77d11a939e886b8a4e2c. * Fix also a memory leak: get_locale_encoding() already allocates memory, no need to duplicate the string.
* bpo-33237: Improve AttributeError message for partially initialized module. ↵Serhiy Storchaka2018-10-301-21/+9
| | | | (GH-6398)
* bpo-34876: Change the lineno of the AST for decorated function and class. ↵Serhiy Storchaka2018-10-304-2489/+2496
| | | | | | | (GH-9731) It was overridden by the lineno of the first decorator. Now it is the lineno of 'def' or 'class'.
* bpo-33331: Clean modules in the reversed order in PyImport_Cleanup(). (GH-6565)Serhiy Storchaka2018-10-292-1789/+1750
| | | | | | Modules imported last are now cleared first at interpreter shutdown. A newly imported module is moved to the end of sys.modules, behind modules on which it depends.
* bpo-35064 prefix smelly symbols that appear with COUNT_ALLOCS with _Py_ ↵Pablo Galindo2018-10-282-4/+4
| | | | | | | (GH-10152) Configuring python with ./configure --with-pydebug CFLAGS="-D COUNT_ALLOCS -O0" makes "make smelly" fail as some symbols were being exported without the "Py_" or "_Py" prefixes.
* bpo-35024: Remove redundant and possibly incorrect verbose message after ↵Quentin Agren2018-10-261-1345/+1343
| | | | | | | | | writing '.pyc' (GH-9998) Since `SourceFileLoader.set_data()` catches exceptions raised by `_write_atomic()` and logs an informative message consequently, always logging successful outcome in 'SourceLoader.get_code()' seems redundant. https://bugs.python.org/issue35024