summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* Fix compiler warning for misleading guarding in the tkinter (GH-26244) ↵Miss Islington (bot)2021-05-191-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-26251) The newest gcc emmits this warning: ``` /Modules/_tkinter.c:272:9: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 272 | if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; } | ^~ /Modules/_tkinter.c:2869:5: note: in expansion of macro ‘LEAVE_PYTHON’ 2869 | LEAVE_PYTHON | ^~~~~~~~~~~~ /Modules/_tkinter.c:243:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 243 | (*(PyThreadState**)Tcl_GetThreadData(&state_key, sizeof(PyThreadState*))) | ^ /Modules/_tkinter.c:272:57: note: in expansion of macro ‘tcl_tstate’ 272 | if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; } | ^~~~~~~~~~ /Modules/_tkinter.c:2869:5: note: in expansion of macro ‘LEAVE_PYTHON’ 2869 | LEAVE_PYTHON ``` that's because the macro packs together two statements at the same level as the "if". The warning is misleading but is very noisy so it makes sense to fix it. (cherry picked from commit 95d04710c5fb0df5393b5add2c5c2de2412673eb) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* Fix compiler warning in the xml module (GH-26245) (GH-26249)Miss Islington (bot)2021-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The newest version of gcc complains about passing un-initialized arrays as constant pointers: ``` /Modules/expat/xmltok_ns.c: In function ‘findEncodingNS’: /Modules/expat/xmltok.h:272:10: warning: ‘buf’ may be used uninitialized [-Wmaybe-uninitialized] 272 | (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim)) | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Modules/expat/xmltok_ns.c:95:3: note: in expansion of macro ‘XmlUtf8Convert’ 95 | XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1); | ^~~~~~~~~~~~~~ /Modules/expat/xmltok.h:272:10: note: by argument 5 of type ‘const char *’ to ‘enum XML_Convert_Result(const ENCODING *, const char **, const char *, char **, const char *)’ {aka ‘enum XML_Convert_Result(const struct encoding *, const char **, const char *, char **, const char *)’} 272 | (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim)) | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Modules/expat/xmltok_ns.c:95:3: note: in expansion of macro ‘XmlUtf8Convert’ 95 | XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1); | ^~~~~~~~~~~~~~ In file included from /Modules/expat/xmltok.c:1657: /Modules/expat/xmltok_ns.c:92:8: note: ‘buf’ declared here 92 | char buf[ENCODING_MAX]; ``` (cherry picked from commit be93f81e58ba3742589259ef84325a95b547e424) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-44145: Release the GIL around HMAC_Update. (GH-26157)Miss Islington (bot)2021-05-171-2/+4
| | | | | | | | | It was always meant to be released for parallelization. This now matches the other similar code in the module. Thanks michaelforney for noticing! (cherry picked from commit c10392e7ddb3eafbd11e9ffe335c07648426715f) Co-authored-by: Gregory P. Smith <greg@krypto.org>
* bpo-44116: Add GC support to _csv heap types (GH-26074) (GH-26081)Miss Islington (bot)2021-05-121-30/+32
| | | (cherry picked from commit e5ba1fe995d4b4f3f6a089a7ec4dd186dd573830)
* bpo-40645: Fix ref leaks in _hashopenssl (GH-26079)Miss Islington (bot)2021-05-121-4/+9
| | | | | (cherry picked from commit 504ffdae4e0cb7775f3e584c3b1d20c262fdfd7e) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
* bpo-44089: Allow subclassing of ``csv.Error`` (GH-26008) (GH-26066)Miss Islington (bot)2021-05-121-1/+1
| | | | | | | | | | * fix subclass error * Update 2021-05-09-22-52-34.bpo-44089.IoANsN.rst (cherry picked from commit 2b458c1dba4058c808fde25226bb2d91c5a909ca) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-40943: Fix skipitem() didn't raise SystemError (GH-25937)Miss Islington (bot)2021-05-071-3/+20
| | | | | | | `convertitem()` raises `SystemError` when 'GH-' is used without `PY_SSIZE_T_CLEAN`. This commit makes `skipitem()` raise it too. (cherry picked from commit 4ebf4a6bfad4afcbab3baf9c0159c7767e2a64c0) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* bpo-36515: Disable unaligned memory access in _sha3 on ARM (GH-25927)Miss Islington (bot)2021-05-051-0/+5
| | | | | | | | Contributed-By: Matthias Klose Automerge-Triggered-By: GH:tiran (cherry picked from commit da5c808fb50d34bc2e180d9481706072f33025da) Co-authored-by: Gregory P. Smith <greg@krypto.org>
* Eliminate duplicated assignment in _randommodule.c (GH-25904) (GH-25909)Miss Islington (bot)2021-05-051-1/+1
|
* Add C-API tests (GH-25886) (#25887)Miss Islington (bot)2021-05-041-0/+21
| | | | | (cherry picked from commit 2f5baa17504feb9a7613bac32fdceed4894434de) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-38530: Refactor and improve AttributeError suggestions (GH-25776)Dennis Sweeney2021-05-031-0/+87
| | | | | | | | | | | | | | | | | | | | - Make case-swaps half the cost of any other edit - Refactor Levenshtein code to not use memory allocator, and to bail early on no match. - Add comments to Levenshtein distance code - Add test cases for Levenshtein distance behind a debug macro - Set threshold to `(name_size + item_size + 3) * MOVE_COST / 6`. - Reasoning: similar to `difflib.SequenceMatcher.ratio()` >= 2/3: ``` "Multiset Jaccard similarity" >= 2/3 matching letters / total letters >= 2/3 (name_size - distance + item_size - distance) / (name_size + item_size) >= 2/3 1 - (2*distance) / (name_size + item_size) >= 2/3 1/3 >= (2*distance) / (name_size + item_size) (name_size + item_size) / 6 >= distance With rounding: (name_size + item_size + 3) // 6 >= distance ``` Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-43916: Move the _PyStructSequence_InitType function to the internal API ↵Pablo Galindo2021-05-031-1/+1
| | | | (GH-25854)
* bpo-42725: Render annotations effectless on symbol table with PEP 563 (GH-25583)Batuhan Taskaya2021-05-031-1/+0
|
* bpo-43977: Make sure that tp_flags for pattern matching are inherited ↵Mark Shannon2021-05-021-2/+9
| | | | correctly. (GH-25813)
* bpo-43434: Clean up sqlite3.connect() after GH-25818 (GH-25823)Erlend Egeberg Aasland2021-05-021-8/+1
|
* bpo-43434: Move sqlite3.connect audit events to sqlite3.Connection.__init__ ↵Erlend Egeberg Aasland2021-05-022-9/+8
| | | | (GH-25818)
* bpo-32745: Fix a regression in the handling of ctypes' c_wchar_p type (#8721)Zackery Spytz2021-05-021-1/+2
| | | | | | Embedded nulls would cause a ValueError to be raised. Thanks go to Eryk Sun for their analysis. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-43908: Mark ssl, hash, and hmac types as immutable (GH-25792)Christian Heimes2021-05-0210-18/+18
| | | Signed-off-by: Christian Heimes <christian@python.org>
* bpo-43998: Default to TLS 1.2 and increase cipher suite security (GH-25778)Christian Heimes2021-05-011-5/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ssl module now has more secure default settings. Ciphers without forward secrecy or SHA-1 MAC are disabled by default. Security level 2 prohibits weak RSA, DH, and ECC keys with less than 112 bits of security. :class:`~ssl.SSLContext` defaults to minimum protocol version TLS 1.2. Settings are based on Hynek Schlawack's research. ``` $ openssl version OpenSSL 1.1.1k FIPS 25 Mar 2021 $ openssl ciphers -v '@SECLEVEL=2:ECDH+AESGCM:ECDH+CHACHA20:ECDH+AES:DHE+AES:!aNULL:!eNULL:!aDSS:!SHA1:!AESCCM' TLS_AES_256_GCM_SHA384 TLSv1.3 Kx=any Au=any Enc=AESGCM(256) Mac=AEAD TLS_CHACHA20_POLY1305_SHA256 TLSv1.3 Kx=any Au=any Enc=CHACHA20/POLY1305(256) Mac=AEAD TLS_AES_128_GCM_SHA256 TLSv1.3 Kx=any Au=any Enc=AESGCM(128) Mac=AEAD TLS_AES_128_CCM_SHA256 TLSv1.3 Kx=any Au=any Enc=AESCCM(128) Mac=AEAD ECDHE-ECDSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=ECDSA Enc=AESGCM(256) Mac=AEAD ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD ECDHE-ECDSA-AES128-GCM-SHA256 TLSv1.2 Kx=ECDH Au=ECDSA Enc=AESGCM(128) Mac=AEAD ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(128) Mac=AEAD ECDHE-ECDSA-CHACHA20-POLY1305 TLSv1.2 Kx=ECDH Au=ECDSA Enc=CHACHA20/POLY1305(256) Mac=AEAD ECDHE-RSA-CHACHA20-POLY1305 TLSv1.2 Kx=ECDH Au=RSA Enc=CHACHA20/POLY1305(256) Mac=AEAD ECDHE-ECDSA-AES256-SHA384 TLSv1.2 Kx=ECDH Au=ECDSA Enc=AES(256) Mac=SHA384 ECDHE-RSA-AES256-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AES(256) Mac=SHA384 ECDHE-ECDSA-AES128-SHA256 TLSv1.2 Kx=ECDH Au=ECDSA Enc=AES(128) Mac=SHA256 ECDHE-RSA-AES128-SHA256 TLSv1.2 Kx=ECDH Au=RSA Enc=AES(128) Mac=SHA256 DHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=DH Au=RSA Enc=AESGCM(256) Mac=AEAD DHE-RSA-AES128-GCM-SHA256 TLSv1.2 Kx=DH Au=RSA Enc=AESGCM(128) Mac=AEAD DHE-RSA-AES256-SHA256 TLSv1.2 Kx=DH Au=RSA Enc=AES(256) Mac=SHA256 DHE-RSA-AES128-SHA256 TLSv1.2 Kx=DH Au=RSA Enc=AES(128) Mac=SHA256 ``` Signed-off-by: Christian Heimes <christian@python.org>
* bpo-41486: Fix initial buffer size can't > UINT32_MAX in zlib module (GH-25738)Ma Lin2021-04-303-71/+77
| | | | | | | | | | | | | | | | * Fix initial buffer size can't > UINT32_MAX in zlib module After commit f9bedb630e8a0b7d94e1c7e609b20dfaa2b22231, in 64-bit build, if the initial buffer size > UINT32_MAX, ValueError will be raised. These two functions are affected: 1. zlib.decompress(data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE) 2. zlib.Decompress.flush([length]) This commit re-allows the size > UINT32_MAX. * adds curly braces per PEP 7. * Renames `Buffer_*` to `OutputBuffer_*` for clarity
* bpo-43916: _md5.md5 uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25753)Victor Stinner2021-04-304-7/+7
| | | | | | | | | | The following types use Py_TPFLAGS_DISALLOW_INSTANTIATION flag: * _md5.md5 * _sha1.sha1 * _sha256.sha224 * _sha256.sha256 * _sha512.sha384 * _sha512.sha512
* bpo-43916: select.devpoll uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25751)Victor Stinner2021-04-301-9/+1
|
* bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)Erlend Egeberg Aasland2021-04-3011-24/+29
| | | | | | | | | | | | | | | | | | | | | Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to the following types: * _dbm.dbm * _gdbm.gdbm * _multibytecodec.MultibyteCodec * _sre..SRE_Scanner * _thread._localdummy * _thread.lock * _winapi.Overlapped * array.arrayiterator * functools.KeyWrapper * functools._lru_list_elem * pyexpat.xmlparser * re.Match * re.Pattern * unicodedata.UCD * zlib.Compress * zlib.Decompress
* bpo-43916: select.poll uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25750)Erlend Egeberg Aasland2021-04-301-13/+4
|
* bpo-43916: Remove _disabled_new() function (GH-25745)Victor Stinner2021-04-302-27/+6
| | | | | posix and _hashlib use the new Py_TPFLAGS_DISALLOW_INSTANTIATION flag on their heap types, rather than using a custom tp_new function (_disabled_new).
* bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721)Victor Stinner2021-04-304-33/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new Py_TPFLAGS_DISALLOW_INSTANTIATION type flag to disallow creating type instances: set tp_new to NULL and don't create the "__new__" key in the type dictionary. The flag is set automatically on static types if tp_base is NULL or &PyBaseObject_Type and tp_new is NULL. Use the flag on the following types: * _curses.ncurses_version type * _curses_panel.panel * _tkinter.Tcl_Obj * _tkinter.tkapp * _tkinter.tktimertoken * _xxsubinterpretersmodule.ChannelID * sys.flags type * sys.getwindowsversion() type * sys.version_info type Update MyStr example in the C API documentation to use Py_TPFLAGS_DISALLOW_INSTANTIATION. Add _PyStructSequence_InitType() function to create a structseq type with the Py_TPFLAGS_DISALLOW_INSTANTIATION flag set. type_new() calls _PyType_CheckConsistency() at exit.
* bpo-43977: Use tp_flags for collection matching (GH-25723)Mark Shannon2021-04-303-2/+37
| | | | | | | | | | | | | * Add Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING, add to all relevant standard builtin classes. * Set relevant flags on collections.abc.Sequence and Mapping. * Use flags in MATCH_SEQUENCE and MATCH_MAPPING opcodes. * Inherit Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING. * Add NEWS * Remove interpreter-state map_abc and seq_abc fields.
* bpo-43908: Make array.array type immutable (GH-25696)Erlend Egeberg Aasland2021-04-291-1/+2
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-43908: Make re types immutable (GH-25697)Erlend Egeberg Aasland2021-04-291-3/+3
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-28254: _posixsubprocess uses PyGC_Enable/PyGC_Disable (GH-25693)Victor Stinner2021-04-281-111/+5
|
* bpo-28254: Add a C-API for controlling the GC state (GH-25687)scoder2021-04-282-6/+91
| | | | | | | | Add new C-API functions to control the state of the garbage collector: PyGC_Enable(), PyGC_Disable(), PyGC_IsEnabled(), corresponding to the functions in the gc module. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-41486: Faster bz2/lzma/zlib via new output buffering (GH-21740)Ma Lin2021-04-283-253/+332
| | | | | | | | | Faster bz2/lzma/zlib via new output buffering. Also adds .readall() function to _compression.DecompressReader class to take best advantage of this in the consume-all-output at once scenario. Often a 5-20% speedup in common scenarios due to less data copying. Contributed by Ma Lin.
* bpo-43963: Add _signal module state (GH-25676)Victor Stinner2021-04-281-84/+153
| | | | | | | | | | | | | * Add signal_state_t structure and signal_global_state variable. * Add a module state to the _signal module. * Move and rename variables: * DefaultHandler becomes state->default_handler * IgnoreHandler becomes state->ignore_handler * sigint_event becomes state->sigint_event * ItimerError becomes modstate->itimer_error * Rename SetHandler() to set_handler() to be consistent with get_handler().
* bpo-43963: Fix import _signal in subinterpreters (GH-25674)Victor Stinner2021-04-271-27/+41
| | | | | | | Importing the _signal module in a subinterpreter has no longer side effects. signal_module_exec() no longer modifies Handlers and no longer attempts to set SIGINT signal handler in subinterpreters.
* Fix thread locks in zlib module may go wrong in rare case. (#22126)Ma Lin2021-04-271-9/+10
| | | Setting `next_in` before acquiring the thread lock may mix up compress/decompress state in other threads.
* bpo-43762: Add audit events for loading of sqlite3 extensions (GH-25246)Erlend Egeberg Aasland2021-04-262-0/+17
|
* bpo-18233: Add internal methods to access peer chain (GH-25467)Christian Heimes2021-04-266-3/+487
| | | | | | | | | | | | The internal `_ssl._SSLSocket` object now provides methods to retrieve the peer cert chain and verified cert chain as a list of Certificate objects. Certificate objects have methods to convert the cert to a dict, PEM, or DER (ASN.1). These are private APIs for now. There is a slim chance to stabilize the approach and provide a public API for 3.10. Otherwise I'll provide a stable API in 3.11. Signed-off-by: Christian Heimes <christian@python.org>
* bpo-39529: Deprecate creating new event loop in asyncio.get_event_loop() ↵Serhiy Storchaka2021-04-252-4/+63
| | | | | | (GH-23554) asyncio.get_event_loop() emits now a deprecation warning when it creates a new event loop. In future releases it will became an alias of asyncio.get_running_loop().
* bpo-30555: Fix WindowsConsoleIO fails in the presence of fd redirection ↵Segev Finer2021-04-234-83/+78
| | | | | | | | (GH-1927) This works by not caching the handle and instead getting the handle from the file descriptor each time, so that if the actual handle changes by fd redirection closing/opening the console handle beneath our feet, we will keep working correctly.
* bpo-43538: Add extra arguments to os.startfile (GH-25538)Steve Dower2021-04-232-19/+93
|
* bpo-35114: Make ssl.RAND_status() return a bool (GH-20063)Zackery Spytz2021-04-232-5/+5
|
* bpo-43920: Make load_verify_locations(cadata) error message consistent ↵Christian Heimes2021-04-231-7/+16
| | | | | (GH-25554) Signed-off-by: Christian Heimes <christian@python.org>
* bpo-43852: Improve tuple creation in sqlite3 (GH-25421)Erlend Egeberg Aasland2021-04-232-18/+10
|
* bpo-38222: Check specifically for a drive, not just a colon (GH-25540)Steve Dower2021-04-221-2/+2
|
* bpo-38822: Fixed os.stat failing on inaccessible directories. (GH-25527)Steve Dower2021-04-221-2/+21
| | | It would just fail if the path was inaccessible and had a trailing slash. It should fall back to the parent directory's metadata.
* bpo-43475: Fix worst case collision behavior for NaN instances (GH-25493)Raymond Hettinger2021-04-221-4/+1
|
* bpo-26227: Fixes decoding of host names on Windows from ANSI instead of ↵Steve Dower2021-04-211-1/+1
| | | | UTF-8 (GH-25510)
* bpo-40137: Add pycore_moduleobject.h internal header (GH-25507)Victor Stinner2021-04-2113-25/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add pycore_moduleobject.h internal header file with static inline functions to access module members: * _PyModule_GetDict() * _PyModule_GetDef() * _PyModule_GetState() These functions don't check at runtime if their argument has a valid type and can be inlined even if Python is not built with LTO. _PyType_GetModuleByDef() uses _PyModule_GetDef(). Replace PyModule_GetState() with _PyModule_GetState() in the extension modules, considered as performance sensitive: * _abc * _functools * _operator * _pickle * _queue * _random * _sre * _struct * _thread * _winapi * array * posix The following extensions are now built with the Py_BUILD_CORE_MODULE macro defined, to be able to use the internal pycore_moduleobject.h header: _abc, array, _operator, _queue, _sre, _struct.
* bpo-43472: Ensure PyInterpreterState_New audit events are raised when called ↵Steve Dower2021-04-211-1/+1
| | | | through _xxsubinterpreters module (GH-25506)
* bpo-40137: Move state lookups out of the critical path (GH-25492)Raymond Hettinger2021-04-211-28/+36
|