summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35444: Fix error handling when fail to look up builtin "getattr". ↵Serhiy Storchaka2018-12-111-0/+14
| | | | | (GH-11047) (GH-11107) (cherry picked from commit bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d)
* bpo-35454: Fix miscellaneous minor issues in error handling. (GH-11077)Miss Islington (bot)2018-12-115-6/+18
| | | | | | | | * bpo-35454: Fix miscellaneous minor issues in error handling. * Fix a null pointer dereference. (cherry picked from commit 8905fcc85a6fc3ac394bc89b0bbf40897e9497a6) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-35452: Make PySys_HasWarnOptions() never raising an exception. (GH-11075)Miss Islington (bot)2018-12-101-1/+2
| | | | | (cherry picked from commit dffccc6b594951fc798973e521da205785823f0f) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-35451: Fix reference counting for sys.warnoptions and sys._xoptions. ↵Miss Islington (bot)2018-12-101-2/+0
| | | | | | | (GH-11063) (cherry picked from commit 72ff7b4c000f7b8199231a0eb1ca4b119fab40a5) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-35441: Remove dead and buggy code related to PyList_SetItem(). (GH-11033)Miss Islington (bot)2018-12-082-3/+3
| | | | | | | | | | | | In _localemodule.c and selectmodule.c, remove dead code that would cause double decrefs if run. In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases where a new list is populated and there is no possibility of an error. In addition, check if the list changed size in the loop in array_array_fromlist(). (cherry picked from commit 99d56b53560b3867844472ae381fb3f858760621) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. ↵Zackery Spytz2018-12-073-3/+12
| | | | | (GH-11015) (GH-11020) (cherry picked from commit 4c49da0cb7434c676d70b9ccf38aca82ac0d64a9)
* bpo-35414: Add a missing Py_INCREF(Py_None) in PyState_RemoveModule(). ↵Miss Islington (bot)2018-12-051-0/+1
| | | | | | | (GH-10914) (cherry picked from commit 2a893430c9c8378cbdfac95895a64fa07aaff9ed) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* bpo-33015: Fix UB in pthread PyThread_start_new_thread (GH-6008)Miss Islington (bot)2018-11-301-4/+36
| | | | | | | | | | Fix an undefined behaviour in the pthread implementation of PyThread_start_new_thread(): add a function wrapper to always return NULL. Add pythread_callback struct and pythread_wrapper() to thread_pthread.h. (cherry picked from commit 9eea6eaf23067880f4af3a130e3f67c9812e2f30) Co-authored-by: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
* bpo-33029: Fix signatures of getter and setter functions. (GH-10746)Miss Islington (bot)2018-11-272-3/+4
| | | | | | Fix also return type for few other functions (clear, releasebuffer). (cherry picked from commit d4f9cf5545d6d8844e0726552ef2e366f5cc3abd) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-33954: Fix _PyUnicode_InsertThousandsGrouping() (GH-10623) (GH-10718)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. Rewrite _PyUnicode_InsertThousandsGrouping(): it now requires a _PyUnicodeWriter object for the buffer and a Python str object for digits. (cherry picked from commit 59423e3ddd736387cef8f7632c71954c1859bed0)
* bpo-34523: Fix C locale coercion on FreeBSD CURRENT (GH-10672) (GH-10673)Victor Stinner2018-11-232-4/+19
| | | | | | | | | | 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. (cherry picked from commit 353933e712b6c7f7ba9a9a50bd5bd472db7c35d0)
* Revert "bpo-35239: _PySys_EndInit() copies module_search_path (GH-10532)" ↵Victor Stinner2018-11-222-25/+5
| | | | | (GH-10660) This reverts commit d2be9a5c13221fb84c2221bbfd93efac6111e697.
* bpo-28604: Fix localeconv() for different LC_MONETARY (GH-10606) (GH-10619)Victor Stinner2018-11-202-4/+17
| | | | | | | | | | | | | | | 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(). (cherry picked from commit 02e6bf7f2025cddcbde6432f6b6396198ab313f4)
* bpo-34725: Adds _Py_SetProgramFullPath so embedders may override ↵Steve Dower2018-11-181-0/+21
| | | | sys.executable (GH-9861)
* Add a missed PyErr_NoMemory() in symtable_new(). (GH-10576)Miss Islington (bot)2018-11-161-1/+3
| | | | | | | This missed PyErr_NoMemory() could cause a SystemError when calling _symtable.symtable(). (cherry picked from commit ad65f15581173542f1d2a9968a63bee272510ce3) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* bpo-35239: _PySys_EndInit() copies module_search_path (GH-10532)Miss Islington (bot)2018-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. (cherry picked from commit 37cd982df02795905886ab36a2378ed557cb6f60) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-35214: Add _Py_ prefix to MEMORY_SANITIZER def. (GH-10503)Miss Islington (bot)2018-11-132-3/+3
| | | | | | | Rename our new MEMORY_SANITIZER define to _Py_MEMORY_SANITIZER. Project based C Preprocessor namespacing at its finest. :P (cherry picked from commit 3015fb8ce4d25603434b9b44bb7effb98a481532) Co-authored-by: Gregory P. Smith <greg@krypto.org>
* [3.7] bpo-35214: Initial clang MemorySanitizer support (GH-10479) (GH-10492)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. (cherry picked from commit 1584a0081500d35dc93ff88e5836df35faf3e3e2) Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
* bpo-35193: Fix an off by one error in the RETURN_VALUE case. (GH-10418)Miss Islington (bot)2018-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/7db3c488335168993689ddae5914a28e16188447GH-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. (cherry picked from commit 49fa4a9f1ef387e16596f271414c855339eadf09) Co-authored-by: Gregory P. Smith <greg@krypto.org>
* bpo-35133: Fix mistakes when concatenate string literals on different lines. ↵Miss Islington (bot)2018-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. (cherry picked from commit 34fd4c20198dea6ab2fe8dc6d32d744d9bde868d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-26558: Fix Py_FatalError() with GIL released (GH-10267)Miss Islington (bot)2018-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. (cherry picked from commit 3a228ab17c2a9cffd1a2f15f30d6209768de20a6) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-34403: Always implement _Py_GetForceASCII() (GH-10235)Victor Stinner2018-10-301-0/+6
| | | | Compilation fails on macOS because _Py_GetForceASCII() wasn't define: always implement implement (default implementation: just return 0).
* bpo-34403: Fix initfsencoding() for ASCII (GH-10233)Victor Stinner2018-10-302-0/+16
| | | | | * Add _Py_GetForceASCII(): check if Python forces the usage of ASCII in Py_DecodeLocale() and Py_EncodeLocale(). * initfsencoding() now uses ASCII if _Py_GetForceASCII() is true.
* bpo-24658: Fix read/write greater than 2 GiB on macOS (GH-1705)Miss Islington (bot)2018-10-181-19/+5
| | | | | | On macOS, fix reading from and writing into a file with a size larger than 2 GiB. (cherry picked from commit 74a8b6ea7e0a8508b13a1c75ec9b91febd8b5557) Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
* Fix an incorrect check in compiler_try_except(). (GH-9810)Miss Islington (bot)2018-10-121-1/+2
| | | | | (cherry picked from commit 53ebf4b0709f431b7262aa5daccef7eafde7383e) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* Fix a possible decref of a borrowed reference in symtable.c. (GH-9786)Miss Islington (bot)2018-10-111-2/+4
| | | | | (cherry picked from commit fc439d20de32b0ebccca79a96e31f83b85ec4eaf) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* closes bpo-34868: Improve error message with '_' is combined with an invalid ↵Miss Islington (bot)2018-10-021-8/+9
| | | | | | | type specifier. (GH-9666) (cherry picked from commit cbda8fc5d76b10bcbb92d927537576c229143836) Co-authored-by: Benjamin Peterson <benjamin@python.org>
* bpo-34854: Fix compiling string annotations containing lambdas. (GH-9645)Miss Islington (bot)2018-09-301-4/+7
| | | | | | | | | | | | * Compiling a string annotation containing a lambda with keyword-only argument without default value caused a crash. * Remove the final "*" (it is incorrect syntax) in the representation of lambda without *args and keyword-only arguments when compile from AST. * Improve the representation of lambda without arguments. (cherry picked from commit 2a2940e5c3e6d92f4fac5e9d361a1e224bb2f12e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Drop confusing commented out code in pystrtod.c (GH-6072) (GH-9586)Victor Stinner2018-09-261-2/+0
| | | | | | | | | Fix the following warning: Python/pystrtod.c: In function 'format_float_short': Python/pystrtod.c:1007:13: warning: 'strncpy' output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation] strncpy(p, "ERR", 3); (cherry picked from commit 9fb84157595a385f15799e5d0729c1e1b0ba9d38)
* bpo-34762: Fix contextvars C API to use PyObject* pointer types. (GH-9473)Miss Islington (bot)2018-09-211-23/+62
| | | | | (cherry picked from commit 2ec872b31e25cee1f983fe07991fb53f3fd1cbac) Co-authored-by: Yury Selivanov <yury@magic.io>
* Revert "[3.7] bpo-34589: Add -X coerce_c_locale option; C locale coercion ↵Victor Stinner2018-09-191-2/+2
| | | | | off by default (GH-9379)" (GH-9416) This reverts commit 144f1e2c6f4a24bd288c045986842c65cc289684.
* [3.7] bpo-34589: Add -X coerce_c_locale option; C locale coercion off by ↵Victor Stinner2018-09-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | default (GH-9379) * bpo-34589: Make _PyCoreConfig.coerce_c_locale private (GH-9371) _PyCoreConfig: * Rename coerce_c_locale to _coerce_c_locale * Rename coerce_c_locale_warn to _coerce_c_locale_warn These fields are now private (name prefixed by "_"). (cherry picked from commit 188ebfa475a6f6aa2d0ea14ca8e1fbe7865b6d27) * bpo-34589: C locale coercion off by default (GH-9073) Py_Initialize() and Py_Main() cannot enable the C locale coercion (PEP 538) anymore: it is always disabled. It can now only be enabled by the Python program ("python3). test_embed: get_filesystem_encoding() doesn't have to set PYTHONUTF8 nor PYTHONCOERCECLOCALE, these variables are already set in the parent. (cherry picked from commit 7a0791b6992d420dc52536257f2f093851ed7215) * bpo-34589: Add -X coerce_c_locale command line option (GH-9378) Add a new -X coerce_c_locale command line option to control C locale coercion (PEP 538). (cherry picked from commit dbdee0073cf0b88fe541980ace1f650900f455cc)
* Make sure the line comes from the same node as the col offset. (GH-9189)Miss Islington (bot)2018-09-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Followup to 90fc8980bbcc5c7dcced3627fe172b0bfd193a3b. <!-- Thanks for your contribution! Please read this comment in its entirety. It's quite important. GH- 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. GH- 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`. --> (cherry picked from commit d13e59c1b512069d90efe7ee9b613d3913e79c56) Co-authored-by: Benjamin Peterson <benjamin@python.org>
* closes bpo-31902: Fix the col_offset attribute for ast.Async* nodes to point ↵Miss Islington (bot)2018-09-111-18/+21
| | | | | | | | to the "async" keyword. (GH-4175) Previously, col_offset points to the keyword after "async". (cherry picked from commit 90fc8980bbcc5c7dcced3627fe172b0bfd193a3b) Co-authored-by: guoci <zguoci@gmail.com>
* bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077)Miss Islington (bot)2018-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. (cherry picked from commit d545869d084e70d4838310e79b52a25a72a1ca56) Co-authored-by: Benjamin Peterson <benjamin@python.org>
* _Py_CoerceLegacyLocale() restores LC_CTYPE on fail (GH-9044) (GH-9046)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. (cherry picked from commit 8ea09110d413829f71d979d8c7073008cb87fb03)
* [3.7] bpo-34485: stdout uses surrogateescape on POSIX locale (GH-8986) (GH-8987)Victor Stinner2018-08-291-12/+34
| | | | | | | | | | | | | | | * bpo-34485: stdout uses surrogateescape on POSIX locale (GH-8986) 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. Fix the error handler of standard streams like sys.stdout: PYTHONIOENCODING=":" is now ignored instead of setting the error handler to "strict". (cherry picked from commit 315877dc361d554bec34b4b62c270479ad36a1be)
* bpo-34485: Fix _Py_InitializeCore() for C locale coercion (GH-8979) (GH-8981)Victor Stinner2018-08-281-4/+6
| | | | | | | | | | * _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. (cherry picked from commit 2c8ddcf4f14f3e4c87a6fe6678ab5ad09130c6ab)
* bpo-34527: POSIX locale enables the UTF-8 Mode (GH-8972) (GH-8974)Victor Stinner2018-08-281-1/+1
| | | | | | | | | | | | * 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. (cherry picked from commit 5cb258950ce9b69b1f65646431c464c0c17b1510)
* bpo-34503: Fix refleak in PyErr_SetObject() (GH-8934)Miss Islington (bot)2018-08-261-0/+1
| | | | | (cherry picked from commit a2eefa67542c25617a58c03a27c17fd48e2a0856) Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
* closes bpo-34474: Python/bltinmodule.c: Add missing NULL check in ↵Miss Islington (bot)2018-08-241-0/+5
| | | | | | | | builtin_sum_impl() (GH-8872) Reported by Svace static analyzer. (cherry picked from commit 2b824b2538c4a5f9f520c5de8a1eae5a0c181a94) Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
* bpo-34457: Python/ast.c: Add missing NULL check to alias_for_import_name(). ↵Miss Islington (bot)2018-08-221-0/+2
| | | | | | | | (GH-8852) Reported by Svace static analyzer. (cherry picked from commit 28853a249b1d0c890b7e9ca345290bb8c1756446) Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
* [3.7] bpo-34247: Fix Python 3.7 initialization (#8659)Victor Stinner2018-08-051-46/+110
| | | | | | | | | | | | | | | | | * -X dev: it is now possible to override the memory allocator using PYTHONMALLOC even if the developer mode is enabled. * Add _Py_InitializeFromConfig() * Add _Py_Initialize_ReadEnvVars() to set global configuration variables from environment variables * Fix the code to initialize Python: Py_Initialize() now also reads environment variables * _Py_InitializeCore() can now be called twice: the second call only replaces the configuration. * Write unit tests on Py_Initialize() and the different ways to configure Python * The isolated mode now always sets Py_IgnoreEnvironmentFlag and Py_NoUserSiteDirectory to 1. * pymain_read_conf() now saves/restores the configuration if the encoding changed
* bpo-34084: Fix setting an error message for the "Barry as BDFL" easter egg. ↵Miss Islington (bot)2018-07-231-0/+4
| | | | | | | (GH-8262) (GH-8423) (cherry picked from commit aba24ff3601ddc86b85e01880a8be596fb799287) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-34190: Fix reference leak in call_function() (GH-8413) (GH-8418)Miss Islington (bot)2018-07-231-5/+8
| | | | | (cherry picked from commit 147d95511f59cfdd2d522f9d736f2335457bae20) Co-authored-by: jdemeyer <jdemeyer@cage.ugent.be>
* bpo-34126: Fix crashes while profiling invalid calls. (GH-8300) (GH-8371)Miss Islington (bot)2018-07-211-4/+10
| | | | | (cherry picked from commit 56868f940e0cc0b35d33c0070107ff3bed2d8766) Co-authored-by: jdemeyer <jdemeyer@cage.ugent.be>
* bpo-34008: Allow to call Py_Main() after Py_Initialize() (GH-8043) (GH-8352)Miss Islington (bot)2018-07-211-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. (cherry picked from commit fb47bca9ee2d07ce96df94b4e4abafd11826eb01) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-34087: Fix buffer overflow in int(s) and similar functions (GH-8274)Miss Islington (bot)2018-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. (cherry picked from commit 16dfca4d829e45f36e71bf43f83226659ce49315) Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
* bpo-34080: Fix a memory leak in the compiler. (GH-8222)Miss Islington (bot)2018-07-111-1/+1
| | | | | (cherry picked from commit 993030aac576710a46b3dd0b4864f819d4a94145) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192)Miss Islington (bot)2018-07-111-1/+3
| | | | | (cherry picked from commit 504373c59b48f1ea12132d515459022730db6047) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>