Erlend Egeberg Aasland
8994e9c2cd
bpo-42972: Fully implement GC protocol for functools keywrapper and partial types (GH-26363)
2021-05-28 10:41:16 +02:00
Inada Naoki
28be3191a9
bpo-44256: Do not expose _functools._list_elem_type (GH-26416)
...
It is internal use only type.
2021-05-28 14:09:32 +09:00
Erlend Egeberg Aasland
f4b70c22c8
bpo-42972: Fully support GC protocol for _operator heap types (GH-26371)
2021-05-27 22:59:07 +02:00
Erlend Egeberg Aasland
fba42d1188
bpo-42972: Fully implement GC protocol for re types (GH-26368)
2021-05-27 19:23:07 +02:00
Erlend Egeberg Aasland
318adeba78
bpo-42972: Fully support GC for mmap heap types (GH-26373)
2021-05-27 17:53:59 +02:00
Erlend Egeberg Aasland
4d7f8f9f7f
bpo-42972: Fully support GC protocol for _queue.SimpleQueue (GH-26372)
2021-05-27 17:50:12 +02:00
Erlend Egeberg Aasland
dcb8786a98
bpo-42972: Fully implement GC protocol for ssl heap types (GH-26370)
2021-05-27 09:50:09 +02:00
Erlend Egeberg Aasland
6ef5ba391d
bpo-42972: Fully support GC for hashlib heap types (GH-26374)
2021-05-27 09:48:19 +02:00
Erlend Egeberg Aasland
59af59c2df
bpo-42972: Fully support GC for pyexpat, unicodedata, and dbm/gdbm heap types (GH-26376)
...
* bpo-42972: pyexpat
* bpo-42972: unicodedata
* bpo-42972: dbm/gdbm
2021-05-27 17:29:00 +10:00
Victor Stinner
3e7ee02327
bpo-42161: mathmodule.c: move _PyLong_GetOne() loop invariant (GH-26391)
...
Move _PyLong_GetZero() and _PyLong_GetOne() loop invariants outside
loops in functions:
* math.comb()
* math.gcd()
* math.lcm()
* math.perm()
2021-05-27 00:51:07 +02:00
Gabriele N. Tornetta
90a6c07cb2
bpo-43879: Add native_thread_id field to PyThreadState (GH-25458)
2021-05-26 16:40:14 +02:00
Erlend Egeberg Aasland
bd404ccac0
bpo-42972: Fully implement GC protocol for arraymodule types (GH-26114)
2021-05-25 19:26:44 +01:00
Erlend Egeberg Aasland
d3c277a59c
bpo-42972: Fully implement GC protocol for sqlite3 heap types (GH-26104)
2021-05-25 18:43:56 +01:00
Zackery Spytz
6cc8ac9499
bpo-40736: Improve the error message for re.search() TypeError (GH-23312)
...
Include the invalid type in the error message.
2021-05-21 22:02:42 +01:00
Pablo Galindo
95d04710c5
Fix compiler warning for misleading guarding in the tkinter (GH-26244)
...
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.
2021-05-19 19:10:23 +01:00
Pablo Galindo
be93f81e58
Fix compiler warning in the xml module (GH-26245)
...
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];
```
2021-05-19 19:05:40 +01:00
Gregory P. Smith
c10392e7dd
bpo-44145: Release the GIL around HMAC_Update. (GH-26157)
...
It was always meant to be released for parallelization.
This now matches the other similar code in the module.
Thanks michaelforney for noticing!
2021-05-17 00:35:16 -07:00
Dong-hee Na
a0ccc404ca
bpo-44113: Update __xxtestfuzz not to use Py_SetProgramName (GH-26083)
2021-05-13 08:22:18 +09:00
Erlend Egeberg Aasland
504ffdae4e
bpo-40645: Fix ref leaks in _hashopenssl (GH-26079)
2021-05-12 19:20:41 +01:00
Erlend Egeberg Aasland
e5ba1fe995
bpo-44116: Add GC support to _csv heap types (GH-26074)
2021-05-12 19:18:58 +01:00
Petr Viktorin
3611db53f5
bpo-40645: Fix reference leak in the _hashopenssl extension (GH-26072)
...
The `PyModule_AddObjectRef` function doesn't steal a reference, so an extra `Py_DECREF` is needed.
Automerge-Triggered-By: GH:tiran
2021-05-12 09:04:34 -07:00
Dong-hee Na
9b06e4b535
Use get_binascii_state instead of PyModule_GetState (GH-26069)
2021-05-13 00:09:30 +09:00
Ken Jin
2b458c1dba
bpo-44089: Allow subclassing of ``csv.Error`` (GH-26008)
...
* fix subclass error
* Update 2021-05-09-22-52-34.bpo-44089.IoANsN.rst
2021-05-12 06:47:11 -07:00
Inada Naoki
4d4be47705
Do not use Py_ssize_clean_t (GH-25940)
2021-05-08 10:17:37 +09:00
Mark Shannon
adcd220556
bpo-40222: "Zero cost" exception handling (GH-25729)
...
"Zero cost" exception handling.
* Uses a lookup table to determine how to handle exceptions.
* Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements.
* Reduces the size of the frame object by about 60%.
2021-05-07 15:19:19 +01:00
Erlend Egeberg Aasland
0988ed09b4
bpo-44047: Remove unused argument to _pysqlite_seterror (GH-25915)
2021-05-07 16:15:01 +03:00
Inada Naoki
9ad8f109ac
bpo-44029: Remove Py_UNICODE APIs (GH-25881)
...
Remove deprecated `Py_UNICODE` APIs: `PyUnicode_Encode`,
`PyUnicode_EncodeUTF7`, `PyUnicode_EncodeUTF8`,
`PyUnicode_EncodeUTF16`, `PyUnicode_EncodeUTF32`,
`PyUnicode_EncodeLatin1`, `PyUnicode_EncodeMBCS`,
`PyUnicode_EncodeDecimal`, `PyUnicode_EncodeRawUnicodeEscape`,
`PyUnicode_EncodeCharmap`, `PyUnicode_EncodeUnicodeEscape`,
`PyUnicode_TransformDecimalToASCII`, `PyUnicode_TranslateCharmap`,
`PyUnicodeEncodeError_Create`, `PyUnicodeTranslateError_Create`.
See :pep:`393` and :pep:`624` for reference.
2021-05-07 15:58:29 +09:00
Inada Naoki
4ebf4a6bfa
bpo-40943: Fix skipitem() didn't raise SystemError (GH-25937)
...
`convertitem()` raises `SystemError` when '#' is used without `PY_SSIZE_T_CLEAN`.
This commit makes `skipitem()` raise it too.
2021-05-07 11:56:48 +09:00
Gregory P. Smith
da5c808fb5
bpo-36515: Disable unaligned memory access in _sha3 on ARM (GH-25927)
...
Contributed-By: Matthias Klose
Automerge-Triggered-By: GH:tiran
2021-05-05 13:55:33 -07:00
Brad Larsen
23362f8c30
Eliminate duplicated assignment in _randommodule.c (GH-25904)
2021-05-04 20:41:11 -07:00
Raymond Hettinger
6fdc4d37f3
bpo-40521: Convert deque freelist from global vars to instance vars (GH-25906)
2021-05-04 17:08:31 -07:00
Ken Jin
2f5baa1750
Add C-API tests ( #25886 )
2021-05-04 13:07:31 +02:00
Dennis Sweeney
80a2a4ed7d
bpo-38530: Refactor and improve AttributeError suggestions (GH-25776)
...
- 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>
2021-05-03 16:47:27 +01:00
Pablo Galindo
c2931d31f8
bpo-43916: Move the _PyStructSequence_InitType function to the internal API (GH-25854)
2021-05-03 15:50:24 +01:00
Batuhan Taskaya
ad106c68eb
bpo-42725: Render annotations effectless on symbol table with PEP 563 (GH-25583)
2021-05-03 10:43:00 +03:00
Mark Shannon
33ec88ac81
bpo-43977: Make sure that tp_flags for pattern matching are inherited correctly. (GH-25813)
2021-05-03 00:38:22 +01:00
Erlend Egeberg Aasland
cbb7b9ed4a
bpo-43434: Clean up sqlite3.connect() after GH-25818 (GH-25823)
2021-05-02 23:10:51 +01:00
Erlend Egeberg Aasland
c96cc089f6
bpo-43434: Move sqlite3.connect audit events to sqlite3.Connection.__init__ (GH-25818)
2021-05-02 22:25:17 +01:00
Zackery Spytz
73766b0341
bpo-32745: Fix a regression in the handling of ctypes' c_wchar_p type ( #8721 )
...
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>
2021-05-02 12:40:01 +02:00
Christian Heimes
91554e4c5c
bpo-43908: Mark ssl, hash, and hmac types as immutable (GH-25792)
...
Signed-off-by: Christian Heimes <christian@python.org>
2021-05-02 09:47:45 +02:00
Christian Heimes
e983252b51
bpo-43998: Default to TLS 1.2 and increase cipher suite security (GH-25778)
...
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>
2021-05-01 20:53:10 +02:00
Ma Lin
251ffa9d2b
bpo-41486: Fix initial buffer size can't > UINT32_MAX in zlib module (GH-25738)
...
* Fix initial buffer size can't > UINT32_MAX in zlib module
After commit f9bedb630e
, 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
2021-04-30 16:32:49 -07:00
Victor Stinner
665c7746fc
bpo-43916: _md5.md5 uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25753)
...
The following types use Py_TPFLAGS_DISALLOW_INSTANTIATION flag:
* _md5.md5
* _sha1.sha1
* _sha256.sha224
* _sha256.sha256
* _sha512.sha384
* _sha512.sha512
2021-04-30 18:40:30 +02:00
Victor Stinner
7dcf0f6db3
bpo-43916: select.devpoll uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25751)
2021-04-30 18:19:57 +02:00
Erlend Egeberg Aasland
9746cda705
bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)
...
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
2021-04-30 16:04:57 +02:00
Erlend Egeberg Aasland
387397f8a4
bpo-43916: select.poll uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25750)
2021-04-30 15:49:17 +02:00
Victor Stinner
0cad068ec1
bpo-43916: Remove _disabled_new() function (GH-25745)
...
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).
2021-04-30 14:06:49 +02:00
Victor Stinner
3bb09947ec
bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721)
...
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.
2021-04-30 12:46:15 +02:00
Mark Shannon
069e81ab3d
bpo-43977: Use tp_flags for collection matching (GH-25723)
...
* 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.
2021-04-30 09:50:28 +01:00
Erlend Egeberg Aasland
c6ad03fddf
bpo-43908: Make array.array type immutable (GH-25696)
...
Co-authored-by: Victor Stinner <vstinner@python.org>
2021-04-29 08:47:48 +02:00