summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* Make sure the line comes from the same node as the col offset. (GH-9189)Benjamin Peterson2018-09-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Followup to 90fc8980bbcc5c7dcced3627fe172b0bfd193a3b. <!-- Thanks for your contribution! Please read this comment in its entirety. It's quite important. # Pull Request title It should be in the following format: ``` bpo-NNNN: Summary of the changes made ``` Where: bpo-NNNN refers to the issue number in the https://bugs.python.org. Most PRs will require an issue number. Trivial changes, like fixing a typo, do not need an issue. # Backport Pull Request title If this is a backport PR (PR made against branches other than `master`), please ensure that the PR title is in the following format: ``` [X.Y] <title from the original PR> (GH-NNNN) ``` Where: [X.Y] is the branch name, e.g. [3.6]. GH-NNNN refers to the PR number from `master`. -->
* Initialize a variable to make the compiler happy. (GH-9153)Benjamin Peterson2018-09-111-1/+1
| | | | | | | | | | | GCC complains: Python/pylifecycle.c: In function ‘_Py_InitializeFromConfig’: Python/pylifecycle.c:900:13: warning: ‘interp’ may be used uninitialized in this function [-Wmaybe-uninitialized] err = _Py_InitializeMainInterpreter(interp, &main_config); ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This seems spurious since &interp is passed to _Py_InitializeCore. Anyway, we can easily initialize to quiet the warning.
* closes bpo-31902: Fix the col_offset attribute for ast.Async* nodes to point ↵guoci2018-09-111-18/+21
| | | | | | to the "async" keyword. (GH-4175) Previously, col_offset points to the keyword after "async".
* bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077)Benjamin Peterson2018-09-101-14/+16
| | | | | | | | The recursive frame pruning code always undercounted the number of elided frames by one. That is, in the "[Previous line repeated N more times]" message, N would always be one too few. Near the recursive pruning cutoff, one frame could be silently dropped. That situation is demonstrated in the OP of the bug report. The fix is to start the identical frame counter at 1.
* _Py_CoerceLegacyLocale() restores LC_CTYPE on fail (GH-9044)Victor Stinner2018-09-031-1/+13
| | | | bpo-34544: If _Py_CoerceLegacyLocale() fails to coerce the C locale, restore the LC_CTYPE locale to the its previous value.
* bpo-34408: Prevent a null pointer dereference and resource leakage in ↵Pablo Galindo2018-08-311-6/+10
| | | | | | | `PyInterpreterState_New()` (GH-8767) * A pointer in `PyInterpreterState_New()` could have been `NULL` when being dereferenced. * Memory was leaked in `PyInterpreterState_New()` when taking some error-handling code path.
* bpo-34523: Use _PyCoreConfig instead of globals (GH-9005)Victor Stinner2018-08-293-28/+34
| | | | | Use the core configuration of the interpreter, rather than using global configuration variables. For example, replace Py_QuietFlag with core_config->quiet.
* bpo-34523: Py_FileSystemDefaultEncoding NULL by default (GH-9003)Victor Stinner2018-08-291-18/+6
| | | | | | | | * Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors default value is now NULL: initfsencoding() set them during Python initialization. * Document how Python chooses the filesystem encoding and error handler. * Add an assertion to _PyCoreConfig_Read().
* bpo-34485: Emit C locale coercion warning later (GH-9002)Victor Stinner2018-08-291-8/+7
| | | | PYTHONCOERCELOCALE=warn warning is now emitted later and written into sys.stderr, rather than being written into the C stderr stream.
* bpo-34523: Support surrogatepass in locale codecs (GH-8995)Victor Stinner2018-08-291-25/+87
| | | | | | | | | | | | | | | | | | | | Add support for the "surrogatepass" error handler in PyUnicode_DecodeFSDefault() and PyUnicode_EncodeFSDefault() for the UTF-8 encoding. Changes: * _Py_DecodeUTF8Ex() and _Py_EncodeUTF8Ex() now support the surrogatepass error handler (_Py_ERROR_SURROGATEPASS). * _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx() now use the _Py_error_handler enum instead of "int surrogateescape" to pass the error handler. These functions now return -3 if the error handler is unknown. * Add unit tests on _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx() in test_codecs. * Rename get_error_handler() to _Py_GetErrorHandler() and expose it as a private function. * _freeze_importlib doesn't need config.filesystem_errors="strict" workaround anymore.
* bpo-34523: Py_DecodeLocale() use UTF-8 on Windows (GH-8998)Victor Stinner2018-08-291-4/+12
| | | | | | | Py_DecodeLocale() and Py_EncodeLocale() now use the UTF-8 encoding on Windows if Py_LegacyWindowsFSEncodingFlag is zero. pymain_read_conf() now sets Py_LegacyWindowsFSEncodingFlag in its loop, but restore its value at exit.
* bpo-34523: Fix config_init_fs_encoding() (GH-8991)Victor Stinner2018-08-291-1/+1
| | | | Call config_init_fs_encoding() if filesystem_errors is not NULL but filesystem_encoding is NULL.
* bpo-34523: Add _PyCoreConfig.filesystem_encoding (GH-8963)Victor Stinner2018-08-293-71/+196
| | | | | | | | | | | | | | | | | | | | | | | _PyCoreConfig_Read() is now responsible to choose the filesystem encoding and error handler. Using Py_Main(), the encoding is now chosen even before calling Py_Initialize(). _PyCoreConfig.filesystem_encoding is now the reference, instead of Py_FileSystemDefaultEncoding, for the Python filesystem encoding. Changes: * Add filesystem_encoding and filesystem_errors to _PyCoreConfig * _PyCoreConfig_Read() now reads the locale encoding for the file system encoding. * PyUnicode_EncodeFSDefault() and PyUnicode_DecodeFSDefaultAndSize() now use the interpreter configuration rather than Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors global configuration variables. * Add _Py_SetFileSystemEncoding() and _Py_ClearFileSystemEncoding() private functions to only modify Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors in coreconfig.c. * _Py_CoerceLegacyLocale() now takes an int rather than _PyCoreConfig for the warning.
* bpo-34485: Add _PyCoreConfig.stdio_encoding (GH-8881)Victor Stinner2018-08-292-132/+209
| | | | * Add stdio_encoding and stdio_errors fields to _PyCoreConfig. * Add unit tests on stdio_encoding and stdio_errors.
* bpo-34485, Windows: LC_CTYPE set to user preference (GH-8988)Victor Stinner2018-08-291-4/+6
| | | | | | | | | | | | | | On Windows, the LC_CTYPE is now set to the user preferred locale at startup: _Py_SetLocaleFromEnv(LC_CTYPE) is now called during the Python initialization. Previously, the LC_CTYPE locale was "C" at startup, but changed when calling setlocale(LC_CTYPE, "") or setlocale(LC_ALL, ""). pymain_read_conf() now also calls _Py_SetLocaleFromEnv(LC_CTYPE) to behave as _Py_InitializeCore(). Moreover, it doesn't save/restore the LC_ALL anymore. On Windows, standard streams like sys.stdout now always use surrogateescape error handler by default (ignore the locale).
* bpo-34485: stdout uses surrogateescape on POSIX locale (GH-8986)Victor Stinner2018-08-291-9/+22
| | | | | | | Standard streams like sys.stdout now use the "surrogateescape" error handler, instead of "strict", on the POSIX locale (when the C locale is not coerced and the UTF-8 Mode is disabled). Add tests on sys.stdout.errors with LC_ALL=POSIX.
* bpo-34485: Add _Py_ClearStandardStreamEncoding() (GH-8982)Victor Stinner2018-08-282-96/+104
| | | | | | | | | | * Move Py_SetStandardStreamEncoding() from pylifecycle.c to coreconfig.c * Add _Py_ClearStandardStreamEncoding() private function. * pymain_free() now calls _Py_ClearStandardStreamEncoding(). * Add assertions add the end of _PyCoreConfig_Read() * _PyCoreConfig_Copy(): rename COPY_STR_ATTR() macro to COPY_WSTR_ATTR(). * Fix get_stdio_errors() indentation.
* bpo-34485: Fix _Py_InitializeCore() for C locale coercion (GH-8979)Victor Stinner2018-08-282-12/+16
| | | | | | | | * _Py_InitializeCore() now sets the LC_CTYPE locale to the user preferred locale before checking if the C locale should be coerced or not in _PyCoreConfig_Read(). * Fix pymain_read_conf(): remember if the C locale has been coerced when the configuration should be read again if the encoding has changed.
* bpo-34485: Enhance init_sys_streams() (GH-8978)Victor Stinner2018-08-281-23/+63
| | | | | | | | | | | | | | | Python now gets the locale encoding with C code to initialize the encoding of standard streams like sys.stdout. Moreover, the encoding is now initialized to the Python codec name to get a normalized encoding name and to ensure that the codec is loaded. The change avoids importing _bootlocale and _locale modules at startup by default. When the PYTHONIOENCODING environment variable only contains an encoding, the error handler is now is now set explicitly to "strict". Rename also get_default_standard_stream_error_handler() to get_stdio_errors(). Reduce the buffer to format the "cpXXX" string (Windows locale encoding).
* bpo-34403: On HP-UX, force ASCII for C locale (GH-8969)Victor Stinner2018-08-283-52/+97
| | | | | | | | On HP-UX with C or POSIX locale, sys.getfilesystemencoding() now returns "ascii" instead of "roman8" (when the UTF-8 Mode is disabled and the C locale is not coerced). nl_langinfo(CODESET) announces "roman8" whereas it uses the Latin1 encoding in practice.
* bpo-34527: POSIX locale enables the UTF-8 Mode (GH-8972)Victor Stinner2018-08-282-5/+13
| | | | | | | | | | * The UTF-8 Mode is now also enabled by the "POSIX" locale, not only by the "C" locale. * On FreeBSD, Py_DecodeLocale() and Py_EncodeLocale() now also forces the ASCII encoding if the LC_CTYPE locale is "POSIX", not only if the LC_CTYPE locale is "C". * test_utf8_mode.test_cmd_line() checks also that the command line arguments are decoded from UTF-8 when the the UTF-8 Mode is enabled with POSIX locale or C locale.
* bpo-34503: Fix refleak in PyErr_SetObject() (GH-8934)Alexey Izbyshev2018-08-261-0/+1
|
* bpo-34492: Python/coreconfig.c: Fix _Py_wstrlist_copy() (GH-8910)Alexey Izbyshev2018-08-241-1/+4
| | | | | | | bpo-34492: Python/coreconfig.c: Add missing NULL check to _Py_wstrlist_copy(). Fix _Py_wstrlist_clear() call on a wrong list. Reported by Svace static analyzer.
* closes bpo-34474: Python/bltinmodule.c: Add missing NULL check in ↵Alexey Izbyshev2018-08-241-0/+5
| | | | | builtin_sum_impl() (GH-8872) Reported by Svace static analyzer.
* bpo-34457: Python/ast.c: Add missing NULL check to alias_for_import_name(). ↵Alexey Izbyshev2018-08-221-0/+2
| | | | | (GH-8852) Reported by Svace static analyzer.
* bpo-34170: _PyCoreConfig_Read() don't replace coerce_c_locale (GH-8658)Victor Stinner2018-08-032-17/+17
| | | | If coerce_c_locale is already set (>= 0), use its value: don't override it.
* bpo-34301: Add _PyInterpreterState_Get() helper function (GH-8592)Victor Stinner2018-08-0310-67/+75
| | | | sys_setcheckinterval() now uses a local variable to parse arguments, before writing into interp->check_interval.
* bpo-31650: Remove _Py_CheckHashBasedPycsMode global config var (GH-8608)Victor Stinner2018-08-012-12/+2
| | | | | | | | bpo-31650, bpo-34170: Replace _Py_CheckHashBasedPycsMode with _PyCoreConfig._check_hash_pycs_mode. Modify PyInit__imp() and zipimport to get the parameter from the current interpreter core configuration. Remove Include/internal/import.h file.
* bpo-34170: Add Python/coreconfig.c for _PyCoreConfig (GH-8607)Victor Stinner2018-08-015-76/+964
| | | | | | | * Add Include/coreconfig.h * Move config_*() and _PyCoreConfig_*() functions from Modules/main.c to a new Python/coreconfig.c file. * Inline _Py_ReadHashSeed() into config_init_hash_seed() * Move global configuration variables to coreconfig.c
* Define _Py_NO_RETURN for Microsoft C compiler (GH-8606)Victor Stinner2018-08-011-1/+1
|
* bpo-34170: Add _PyCoreConfig._frozen parameter (GH-8591)Victor Stinner2018-08-011-2/+10
| | | Modify frozenmain.c to use _Py_InitializeFromConfig().
* bpo-34113: Fix a crash when using LLTRACE is on (GH-8517)costypetrisor2018-07-311-17/+27
| | | Fix a crash on negative STACKADJ() when Low-Level trace (LLTRACE) is enabled.
* Add docstrings to public methods from context.c (GH-8531)Peter Lamut2018-07-302-17/+79
|
* bpo-34170: Add _Py_InitializeFromConfig() (GH-8454)Victor Stinner2018-07-252-68/+159
| | | | | | | | | | | | | | * If _Py_InitializeCore() is called twice, the second call now copies and apply (partially) the new configuration. * Rename _Py_CommandLineDetails to _PyCmdline * Move more code into pymain_init(). The core configuration created by Py_Main() is new destroyed before running Python to reduce the memory footprint. * _Py_InitializeCore() now returns the created interpreter. _Py_InitializeMainInterpreter() now expects an interpreter. * Remove _Py_InitializeEx_Private(): _freeze_importlib now uses _Py_InitializeFromConfig() * _PyCoreConfig_InitPathConfig() now only computes the path configuration if needed.
* bpo-34170: Add _PyCoreConfig.bytes_warning (GH-8447)Victor Stinner2018-07-241-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add more fields to _PyCoreConfig: * _check_hash_pycs_mode * bytes_warning * debug * inspect * interactive * legacy_windows_fs_encoding * legacy_windows_stdio * optimization_level * quiet * unbuffered_stdio * user_site_directory * verbose * write_bytecode Changes: * Remove pymain_get_global_config() and pymain_set_global_config() which became useless. These functions have been replaced by _PyCoreConfig_GetGlobalConfig() and _PyCoreConfig_SetGlobalConfig(). * sys.flags.dont_write_bytecode value is now restricted to 1 even if -B option is specified multiple times on the command line. * PyThreadState_Clear() now uses the config from the current interpreter rather than using global Py_VerboseFlag
* bpo-34170: Add _PyCoreConfig.isolated (GH-8417)Victor Stinner2018-07-242-43/+33
| | | | | | | | | | | | | | | * _PyCoreConfig: add isolated and site_import attributes * Replace Py_IgnoreEnvironment with config->ignore_environment when reading the current configuration * _PyCoreConfig_Read() now sets ignore_environment, utf8_mode, isolated and site_import from Py_IgnoreEnvironment, Py_UTF8Mode, Py_IsolatedFlag and Py_NoSiteFlag * _Py_InitializeCore() now sets Py_xxx flags from the configuration * pymain_read_conf() now uses _PyCoreConfig_Copy() to save/restore the configuration. * Rename _disable_importlib of _PyCoreConfig to _install_importlib * _PyCoreConfig_SetGlobalConfig() now also set Py_HashRandomizationFlag * Replace !Py_NoSiteFlag with core_config->site_import
* bpo-33720: Refactor marshalling/unmarshalling floats. (GH-8071)Serhiy Storchaka2018-07-241-109/+72
|
* bpo-34149: Behavior of the min/max with key=None (GH-8328)Alexander Marshalov2018-07-241-0/+4
| | | Improve consistency with the signature for sorted(), heapq.nsmallest(), heapq.nlargest(), and itertools.groupby().
* bpo-34084: Fix setting an error message for the "Barry as BDFL" easter egg. ↵Serhiy Storchaka2018-07-231-0/+4
| | | | (GH-8262)
* bpo-34190: Fix reference leak in call_function() (GH-8413)jdemeyer2018-07-231-5/+8
|
* bpo-34127: Fix grammar in error message with respect to argument count (GH-8395)Xtreak2018-07-221-4/+4
|
* bpo-34126: Fix crashes while profiling invalid calls. (GH-8300)jdemeyer2018-07-211-4/+10
|
* bpo-34170: _PyCoreConfig_Read() leaves Py_IsolatedFlag unchanged (GH-8361)Victor Stinner2018-07-212-12/+15
| | | | | | | | | | * _PyCoreConfig_Read() no longer directly modifies Py_IsolatedFlag and Py_NoSiteFlag global configuration flags. The function now requires two pointers to integer, so these flags can be set later, to avoid side effets in _PyCoreConfig_Read(). * pathconfig_global_init() now leaves Py_IsolatedFlag and Py_NoSiteFlag unchanged. * Fix pathconfig_global_init(): avoid computing the path configuration twice, use _PyCoreConfig_SetPathConfig().
* bpo-34170: Rework _PyCoreConfig_Read() to avoid side effect (GH-8353)Victor Stinner2018-07-212-28/+311
| | | | | | | | | | | | | | | | | | | | | | | | | Rework _PyCoreConfig_Read() function which *reads* core configuration to not *modify* the path configuration. A new _PyCoreConfig_SetPathConfig() function now recreates the path configuration from the core configuration. This function is now called very late in _Py_InitializeCore(), just before calling initimport(). Changes: * Add _PyCoreConfig.dll_path * Py_SetPath() now fails with a fatal python error on memory allocation failure. * Rename _PyPathConfig_Calculate() to _PyPathConfig_Calculate_impl() * Replace _PyPathConfig_Init() with _PyPathConfig_Calculate(): the function now requires a _PyPathConfig * Add _PyPathConfig_SetGlobal() to set the _Py_path_config global variable. * Add _PyCoreConfig_InitPathConfig(): compute the path configuration * Add _PyCoreConfig_SetPathConfig(): set path configuration from core configuration * Rename wstrlist_append() to _Py_wstrlist_append() * _Py_wstrlist_append() now handles integer overflow.
* bpo-34008: Allow to call Py_Main() after Py_Initialize() (GH-8043)Victor Stinner2018-07-201-3/+20
| | | | | Py_Main() can again be called after Py_Initialize(), as in Python 3.6. The new configuration is ignored, except of _PyMainInterpreterConfig.argv which is used to update sys.argv.
* bpo-34087: Fix buffer overflow in int(s) and similar functions (GH-8274)INADA Naoki2018-07-141-0/+2
| | | | | | `_PyUnicode_TransformDecimalAndSpaceToASCII()` missed trailing NUL char. It caused buffer overflow in `_Py_string_to_number_with_underscores()`. This bug is introduced in 9b6c60cb.
* bpo-34080: Fix a memory leak in the compiler. (GH-8222)Serhiy Storchaka2018-07-111-1/+1
|
* bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192)Serhiy Storchaka2018-07-111-1/+3
|
* bpo-22689: Copy the result of getenv() in sys_breakpointhook(). (GH-8194)Serhiy Storchaka2018-07-091-1/+14
|
* bpo-34066: Disabled interruption before SETUP_WITH and BEFORE_ASYNC_WITH. ↵Serhiy Storchaka2018-07-091-4/+11
| | | | | | | (GH-8159) This will prevent emitting a resource warning when the execution was interrupted by Ctrl-C between calling open() and entering a 'with' block in "with open()".