summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-40636: Clarify the zip built-in docstring. (GH-20118)Miss Islington (bot)2020-05-151-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | Clarify the zip built-in docstring. This puts much simpler text up front along with an example. As it was, the zip built-in docstring was technically correct. But too technical for the reader who shouldn't _need_ to know about `__next__` and `StopIteration` as most people do not need to understand the internal implementation details of the iterator protocol in their daily life. This is a documentation only change, intended to be backported to 3.8; it is only tangentially related to PEP-618 which might offer new behavior options in the future. Wording based a bit more on enumerate per Brandt's suggestion. This gets rid of the legacy wording paragraph which seems too tied to implementation details of the iterator protocol which isn't relevant here. Co-authored-by: Brandt Bucher <brandtbucher@gmail.com> (cherry picked from commit 6a5d3ff67644af42b1a781be2eacb2e82913441c) Co-authored-by: Gregory P. Smith <greg@krypto.org>
* [3.8] bpo-39562: Prevent collision of future and compiler flags (GH-19230) ↵Pablo Galindo2020-05-011-1/+1
| | | | | | | | | | | (GH-19835) The constant values of future flags in the __future__ module is updated in order to prevent collision with compiler flags. Previously PyCF_ALLOW_TOP_LEVEL_AWAIT was clashing with CO_FUTURE_DIVISION.. (cherry picked from commit 4454057269b995341b04d13f0bf97f96080f27d0) Co-authored-by: Batuhan Taşkaya <batuhanosmantaskaya@gmail.com>
* Correct signature of __build_class__ (GH-16735)Miss Islington (bot)2019-10-131-1/+1
| | | | | (cherry picked from commit e3babbd03cd2bcb3c85deabae3bc6976aa95a3c3) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-38237: Shorter docstring (GH-16322) (GH-16323)Miss Islington (bot)2019-09-211-2/+2
| | | | | (cherry picked from commit b104ecbbafc14f9ca0c8371963c45dca893f6b75) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
* bpo-38237: Let pow() support keyword arguments (GH-16302) (GH-16320)Miss Islington (bot)2019-09-211-8/+8
| | | Backported with release manager approval
* [3.8] bpo-37206: Unrepresentable default values no longer represented as ↵Serhiy Storchaka2019-09-141-3/+3
| | | | | | | | | | None. (GH-13933) (GH-16141) In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values (like in the optional third parameter of getattr). "None" should be used if None is accepted as argument and passing None has the same effect as not passing the argument at all. (cherry picked from commit 279f44678c8b84a183f9eeb85e0b086228154497) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.8] bpo-37994: Fix silencing all errors if an attribute lookup fails. ↵Serhiy Storchaka2019-09-011-6/+2
| | | | | | | (GH-15630) (GH-15635) Only AttributeError should be silenced. (cherry picked from commit 41c57b335330ff48af098d47e379e0f9ba09d233)
* bpo-37976: Prevent shadowing of TypeError in zip() (GH-15592) (GH-15608)Miss Islington (bot)2019-08-301-4/+0
| | | | | (cherry picked from commit 6a650aaf7735e30636db2721247f317064c2cfd4) Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
* Adjust builtins.zip() docstring to better communicate its signature (GH-14833)Miss Islington (bot)2019-07-191-1/+1
| | | | | (cherry picked from commit af2f5b1723b95e45e1f15b5bd52102b7de560f7c) Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
* bpo-37363: Add audit events for a range of modules (GH-14301)Miss Islington (bot)2019-06-241-0/+5
| | | | | (cherry picked from commit 60419a7e96577cf783b3b45bf3984f9fb0d7ddff) Co-authored-by: Steve Dower <steve.dower@python.org>
* bpo-37253: Add _PyCompilerFlags_INIT macro (GH-14018)Miss Islington (bot)2019-06-131-6/+3
| | | | | | | | Add a new _PyCompilerFlags_INIT macro to initialize PyCompilerFlags variables, rather than initializing cf_flags and cf_feature_version explicitly in each variable. (cherry picked from commit 37d66d7d4bc7dbac9809d69966a774ebb32563be) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-35766: compile(): rename feature_version parameter (GH-13994) (GH-14001)Victor Stinner2019-06-121-2/+3
| | | | | | | | Rename compile() feature_version parameter to _feature_version and convert it to a keyword-only parameter. Update also test_type_comments to pass feature_version as a tuple. (cherry picked from commit efdf6ca90f7702824e7aeee1ceca949e7c20288a)
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-6/+6
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-36974: implement PEP 590 (GH-13185)Jeroen Demeyer2019-05-291-2/+2
| | | | | Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be> Co-authored-by: Mark Shannon <mark@hotpy.org>
* bpo-37001: Makes symtable.symtable have parity with compile for input (#13483)Dino Viehland2019-05-281-52/+3
| | | | | | | * Makes symtable.symtable have parity for accepted datatypes for source code as compile() * Add NEWS blurb
* bpo-36763: Implement the PEP 587 (GH-13592)Victor Stinner2019-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a whole new documentation page: "Python Initialization Configuration" * PyWideStringList_Append() return type is now PyStatus, instead of int * PyInterpreterState_New() now calls PyConfig_Clear() if PyConfig_InitPythonConfig() fails. * Rename files: * Python/coreconfig.c => Python/initconfig.c * Include/cpython/coreconfig.h => Include/cpython/initconfig.h * Include/internal/: pycore_coreconfig.h => pycore_initconfig.h * Rename structures * _PyCoreConfig => PyConfig * _PyPreConfig => PyPreConfig * _PyInitError => PyStatus * _PyWstrList => PyWideStringList * Rename PyConfig fields: * use_module_search_paths => module_search_paths_set * module_search_path_env => pythonpath_env * Rename PyStatus field: _func => func * PyInterpreterState: rename core_config field to config * Rename macros and functions: * _PyCoreConfig_SetArgv() => PyConfig_SetBytesArgv() * _PyCoreConfig_SetWideArgv() => PyConfig_SetArgv() * _PyCoreConfig_DecodeLocale() => PyConfig_SetBytesString() * _PyInitError_Failed() => PyStatus_Exception() * _Py_INIT_ERROR_TYPE_xxx enums => _PyStatus_TYPE_xxx * _Py_UnixMain() => Py_BytesMain() * _Py_ExitInitError() => Py_ExitStatusException() * _Py_PreInitializeFromArgs() => Py_PreInitializeFromBytesArgs() * _Py_PreInitializeFromWideArgs() => Py_PreInitializeFromArgs() * _Py_PreInitialize() => Py_PreInitialize() * _Py_RunMain() => Py_RunMain() * _Py_InitializeFromConfig() => Py_InitializeFromConfig() * _Py_INIT_XXX() => _PyStatus_XXX() * _Py_INIT_FAILED() => _PyStatus_EXCEPTION() * Rename 'err' PyStatus variables to 'status' * Convert RUN_CODE() macro to config_run_code() static inline function * Remove functions: * _Py_InitializeFromArgs() * _Py_InitializeFromWideArgs() * _PyInterpreterState_GetCoreConfig()
* bpo-36842: Implement PEP 578 (GH-12613)Steve Dower2019-05-231-2/+28
| | | Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
* bpo-36791: Safer detection of integer overflow in sum(). (GH-13080)Serhiy Storchaka2019-05-051-3/+5
|
* bpo-35975: Support parsing earlier minor versions of Python 3 (GH-12086)Guido van Rossum2019-03-071-2/+9
| | | | | | | 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
* bpo-36030: Remove _PyStack_AsTuple() and _PyStack_AsTupleSlice() (GH-12032)Sergey Fedoseev2019-02-251-1/+2
|
* bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)Serhiy Storchaka2019-02-251-3/+14
|
* bpo-35766: Merge typed_ast back into CPython (GH-11645)Guido van Rossum2019-01-311-4/+16
|
* bpo-35582: Inline arguments tuple unpacking in handwritten code. (GH-11524)Serhiy Storchaka2019-01-121-13/+18
| | | | | Inline PyArg_UnpackTuple() and _PyArg_UnpackStack() in performance sensitive code in the builtins and operator modules.
* bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka2018-11-271-9/+9
| | | | | | 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-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-9/+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-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-34637: Make the *start* argument for *sum()* visible as a keyword ↵Raymond Hettinger2018-09-121-2/+2
| | | | argument. (GH-9208)
* bpo-34523: Use _PyCoreConfig instead of globals (GH-9005)Victor Stinner2018-08-291-1/+4
| | | | | Use the core configuration of the interpreter, rather than using global configuration variables. For example, replace Py_QuietFlag with core_config->quiet.
* 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-34170: Add Python/coreconfig.c for _PyCoreConfig (GH-8607)Victor Stinner2018-08-011-23/+0
| | | | | | | * 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
* 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-23722: Raise a RuntimeError for absent __classcell__. (GH-6931)Serhiy Storchaka2018-05-201-15/+4
| | | A DeprecationWarning was emitted in Python 3.6-3.7.
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-3/+3
| | | | | | | | | (GH-6030) METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 due to the argument mismatch. Fix this by adding a dummy unused argument.
* bpo-32674: Improve the docstring for __import__ (GH-5339)oldk2018-02-021-3/+3
| | | | | Clarify that the level argument is used to determine whether to perform absolute or relative imports: 0 is absolute, while a positive number is the number of parent directories to search relative to the current module.
* bpo-32571: Avoid raising unneeded AttributeError and silencing it in C code ↵Serhiy Storchaka2018-01-251-24/+13
| | | | | (GH-5222) Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
* bpo-9566: Fix size_t=>int downcast warnings (#5230)Victor Stinner2018-01-181-2/+2
| | | | * Use wider types (int => Py_ssize_t) to avoid integer overflows. * Fix gc.get_freeze_count(): use Py_ssize_t type rather than int, since gc_list_size() returns a Py_ssize_t.
* bpo-32544: Speed up hasattr() and getattr() (GH-5173)INADA Naoki2018-01-161-10/+11
| | | | | AttributeError was raised always when attribute is not found. This commit skip raising AttributeError when `tp_getattro` is `PyObject_GenericGetAttr`. It makes hasattr() and getattr() about 4x faster when attribute is not found.
* bpo-29240, bpo-32030: Py_Main() re-reads config if encoding changes (#4899)Victor Stinner2017-12-161-3/+4
| | | | | | | | | | | | | | | | | | bpo-29240, bpo-32030: If the encoding change (C locale coerced or UTF-8 Mode changed), Py_Main() now reads again the configuration with the new encoding. Changes: * Add _Py_UnixMain() called by main(). * Rename pymain_free_pymain() to pymain_clear_pymain(), it can now be called multipled times. * Rename pymain_parse_cmdline_envvars() to pymain_read_conf(). * Py_Main() now clears orig_argc and orig_argv at exit. * Remove argv_copy2, Py_Main() doesn't modify argv anymore. There is no need anymore to get two copies of the wchar_t** argv. * _PyCoreConfig: add coerce_c_locale and coerce_c_locale_warn. * Py_UTF8Mode is now initialized to -1. * Locale coercion (PEP 538) now respects -I and -E options.
* bpo-32240: Add the const qualifier to declarations of PyObject* array ↵Serhiy Storchaka2017-12-151-6/+6
| | | | arguments. (#4746)
* bpo-32226: Implementation of PEP 560 (core components) (#4732)Ivan Levkivskyi2017-12-141-3/+92
| | | | | This part of the PEP implementation adds support for __mro_entries__ and __class_getitem__ by updating __build_class__ and PyObject_GetItem.
* bpo-29240: PEP 540: Add a new UTF-8 Mode (#855)Victor Stinner2017-12-131-0/+3
| | | | | | | | | | | | | | | | | | | | | | * Add -X utf8 command line option, PYTHONUTF8 environment variable and a new sys.flags.utf8_mode flag. * If the LC_CTYPE locale is "C" at startup: enable automatically the UTF-8 mode. * Add _winapi.GetACP(). encodings._alias_mbcs() now calls _winapi.GetACP() to get the ANSI code page * locale.getpreferredencoding() now returns 'UTF-8' in the UTF-8 mode. As a side effect, open() now uses the UTF-8 encoding by default in this mode. * Py_DecodeLocale() and Py_EncodeLocale() now use the UTF-8 encoding in the UTF-8 Mode. * Update subprocess._args_from_interpreter_flags() to handle -X utf8 * Skip some tests relying on the current locale if the UTF-8 mode is enabled. * Add test_utf8mode.py. * _Py_DecodeUTF8_surrogateescape() gets a new optional parameter to return also the length (number of wide characters). * pymain_get_global_config() and pymain_set_global_config() now always copy flag values, rather than only copying if the new value is greater than the old value.
* bpo-30950: Convert round() to Argument Clinic. (#2740)Serhiy Storchaka2017-11-151-19/+16
|
* Add the const qualifier to "char *" variables that refer to literal strings. ↵Serhiy Storchaka2017-11-111-1/+1
| | | | (#4370)
* PEP 553 built-in breakpoint() function (bpo-31353) (#3355)Barry Warsaw2017-10-051-0/+23
| | | Implement PEP 553, built-in breakpoint() with support from sys.breakpointhook(), along with documentation and tests. Closes bpo-31353
* bpo-31588: Validate return value of __prepare__() methods (GH-3764)Oren Milman2017-09-271-0/+7
| | | | | | | | | | Class execution requires that __prepare__() methods return a proper execution namespace. Check for that immediately after calling __prepare__(), rather than passing it through to the code execution machinery and potentially triggering SystemError (in debug builds) or a cryptic TypeError (in release builds). Patch by Oren Milman.
* bpo-28411: Isolate PyInterpreterState.modules (#3575)Eric Snow2017-09-141-1/+1
| | | | | A bunch of code currently uses PyInterpreterState.modules directly instead of PyImport_GetModuleDict(). This complicates efforts to make changes relative to sys.modules. This patch switches to using PyImport_GetModuleDict() uniformly. Also, a number of related uses of sys.modules are updated for uniformity for the same reason. Note that this code was already reviewed and merged as part of #1638. I reverted that and am now splitting it up into more focused parts.
* bpo-31404: Revert "remove modules from Py_InterpreterState (#1638)" (#3565)Eric Snow2017-09-141-1/+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-28411: Remove "modules" field from Py_InterpreterState. (#1638)Eric Snow2017-09-041-1/+1
| | | sys.modules is the one true source.