Commit Graph

12318 Commits

Author SHA1 Message Date
Yurii Karabas 96c4cbd96c
bpo-44353: Implement typing.NewType __call__ method in C (#27262)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Denis Laxalde <denis@laxalde.org>
2021-07-22 23:06:54 +02:00
Erlend Egeberg Aasland 4c0deb25ac
bpo-42064: Finalise establishing sqlite3 global state (GH-27155)
With this, all sqlite3 static globals have been moved to the global state.
There are a couple of global static strings left, but there should be no need for adding them to the state.

https://bugs.python.org/issue42064
2021-07-20 12:59:18 +02:00
Idan Moral 366fcbac18
bpo-44678: Separate error message for discontinuous padding in binascii.a2b_base64 strict mode (GH-27249)
* Renamed assertLeadingPadding function to match logic
* Added a separate error message for discontinuous padding
* Updated the tests for discontinuous padding
2021-07-19 15:42:19 -07:00
Idan Moral 35b98e38b6
bpo-43086: Add handling for out-of-spec data in a2b_base64 (GH-24402)
binascii.a2b_base64 gains a strict_mode= parameter. When enabled it will raise an
error on input that deviates from the base64 spec in any way.  The default remains
False for backward compatibility.

Code reviews and minor tweaks by: Gregory P. Smith <greg@krypto.org> [Google]
2021-07-18 17:45:19 -07:00
Erlend Egeberg Aasland 5007a4f23c
bpo-44641: Use vectorcall in sqlite3 collation callback (GH-27158) 2021-07-15 16:49:14 +01:00
Shane Harvey d59d7374a3
bpo-34932: Add socket.TCP_KEEPALIVE for macOS (GH-25079) 2021-07-14 23:53:15 +01:00
Erlend Egeberg Aasland 81b8c0a385
Fix docstring typo in sqlite3.Connection.executescript/sqlite3.Cursor.executescript (GH-27147)
Both `executescript` methods contain the same docstring typo:
_"Executes a multiple SQL statements at once."_ => _"Executes multiple SQL statements at once."_

Automerge-Triggered-By: GH:pablogsal
2021-07-14 14:54:37 -07:00
Erlend Egeberg Aasland 05162993fe
bpo-42064: Move `sqlite3` exceptions to global state, part 2 of 2 (GH-26884)
Automerge-Triggered-By: GH:encukou
2021-07-14 04:26:44 -07:00
Serhiy Storchaka f572cbf1fa
bpo-44608: Fix memory leak in _tkinter._flatten() (GH-27107)
if it is called with a sequence or set, but not list or tuple.
2021-07-14 08:19:18 +03:00
T. Wouters 0093876328
bpo-44630: Fix assertion errors in csv module (GH-27127)
Fix incorrect handling of exceptions when interpreting dialect objects in
the csv module. Not clearing exceptions between calls to
PyObject_GetAttrString() causes assertion failures in pydebug mode (or with
assertions enabled).

Add a minimal test that would've caught this (passing None as dialect, or
any object that isn't a csv.Dialect subclass, which the csv module allows
and caters to, even though it is not documented.) In pydebug mode, the test
triggers the assertion failure in the old code.

Contributed-By: T. Wouters [Google]
2021-07-13 15:56:45 -07:00
Filipe Laíns e14d5ae544
bpo-29753: revert 0d7ad9f (GH-19850) (GH-27085)
This reverts commit 0d7ad9fb38 as it has a regression.

See https://github.com/python/cpython/pull/19850#issuecomment-869410686
2021-07-11 17:43:50 +01:00
Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి) 7b21108445
Remove irrelevant comment which was added in 2a70a3a (GH-27044) 2021-07-08 21:57:25 -07:00
Steve Dower bbf2fb6c7a
bpo-44582: Accelerate mimetypes.init on Windows with a native accelerator (GH-27059) 2021-07-08 16:48:42 +01:00
Rupert Tombs 6bd3ecfc27
bpo-44558: Match countOf `is`/`==` treatment to c (GH-27007) 2021-07-07 22:28:09 +09:00
Serhiy Storchaka f64de53ff0
bpo-44563: Fix error handling in tee.fromiterable() (GH-27020)
In debug build failed tee.fromiterable() corrupted the linked list of all GC objects.
2021-07-05 23:19:35 +01:00
Ma Lin a9a69bb3ea
bpo-41486: zlib uses an UINT32_MAX sliding window for the output buffer (GH-26143)
* zlib uses an UINT32_MAX sliding window for the output buffer

These funtions have an initial output buffer size parameter:
- zlib.decompress(data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE)
- zlib.Decompress.flush([length])

If the initial size > UINT32_MAX, use an UINT32_MAX sliding window, instead of clamping to UINT32_MAX.
Speed up when (the initial size == the actual size).

This fixes a memory consumption and copying performance regression in earlier 3.10 beta releases if someone used an output buffer larger than 4GiB with zlib.decompress.

Reviewed-by: Gregory P. Smith
2021-07-04 18:10:44 -07:00
Victor Stinner 48e3a1d95a
bpo-44434: Remove useless calls to PyThread_exit_thread() (GH-26943)
Remove useless calls to PyThread_exit_thread() in two unit tests of
_testcapi and _testembed modules.

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2021-06-29 02:03:30 +02:00
Brandt Bucher ca2009d72a
bpo-43977: Properly update the tp_flags of existing subclasses when their parents are registered (GH-26864) 2021-06-25 08:20:43 -07:00
Samuel Marks 19459f8ce6
bpo-44321: Adds `os.EX_OK` for Windows (GH-26559) 2021-06-24 17:45:18 +01:00
Erlend Egeberg Aasland b19f455339
bpo-44491: Allow clearing the sqlite3 authoriser callback (GH-26863) 2021-06-24 15:35:57 +01:00
Erlend Egeberg Aasland a50e28377b
bpo-42064: Move `sqlite3` exceptions to global state, part 1 of 2 (GH-26745)
Also adds a test to verify the (borrowed) exceptions in `sqlite3.Connection`.
2021-06-23 05:56:40 -07:00
Erlend Egeberg Aasland 019ad62afd
bpo-42064: Remove stale extern declarations in `sqlite3` headers (GH-26840) 2021-06-23 21:06:53 +09:00
Dennis Sweeney d1ae57027f
bpo-41621: Document defaultdict's default_factory parameter (GH-21945)
It defaults to None and is positional only.
2021-06-22 10:19:24 -04:00
Victor Stinner 45a78f906d
bpo-44434: Don't call PyThread_exit_thread() explicitly (GH-26758)
_thread.start_new_thread() no longer calls PyThread_exit_thread()
explicitly at the thread exit, the call was redundant.

On Linux with the glibc, pthread_cancel() loads dynamically the
libgcc_s.so.1 library. dlopen() can fail if there is no more
available file descriptor to open the file. In this case, the process
aborts with the error message:

"libgcc_s.so.1 must be installed for pthread_cancel to work"

pthread_cancel() unwinds back to the thread's wrapping function that
calls the thread entry point.

The unwind function is dynamically loaded from the libgcc_s library
since it is tightly coupled to the C compiler (GCC). The unwinder
depends on DWARF, the compiler generates DWARF, so the unwinder
belongs to the compiler.

Thanks Florian Weimer and Carlos O'Donell for their help on
investigating this issue.
2021-06-21 13:16:18 +02:00
Georg Sauthoff a317778fd5
bpo-44077: Expose IP_RECVTOS in the socket module (GH-25992)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2021-06-20 21:08:07 +01:00
Erlend Egeberg Aasland 7d0a47e1af
bpo-44087: Disallow instantiation of sqlite3.Statement (GH-26567) 2021-06-20 20:24:32 +01:00
Erlend Egeberg Aasland 185ecdc146
bpo-40956: Convert sqlite3.connect and sqlite3.Connection.__init__ to AC (GH-24421) 2021-06-20 20:24:00 +01:00
Erlend Egeberg Aasland 00710e6346
bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351)
* Make functools types immutable

* Multibyte codec types are now immutable

* pyexpat.xmlparser is now immutable

* array.arrayiterator is now immutable

* _thread types are now immutable

* _csv types are now immutable

* _queue.SimpleQueue is now immutable

* mmap.mmap is now immutable

* unicodedata.UCD is now immutable

* sqlite3 types are now immutable

* _lsprof.Profiler is now immutable

* _overlapped.Overlapped is now immutable

* _operator types are now immutable

* winapi__overlapped.Overlapped is now immutable

* _lzma types are now immutable

* _bz2 types are now immutable

* _dbm.dbm and _gdbm.gdbm are now immutable
2021-06-17 11:06:09 +01:00
Joe c544393b89
bpo-44389: Fix typo in ssl deprecation warning message (GH-26754)
`ssl.SSL_NO_TLS` should be `ssl.OP_NO_TLS`.
2021-06-17 02:39:57 -07:00
Victor Stinner 1cd3d859a4
bpo-42972: _thread.RLock implements the GH protocol (GH-26734)
The _thread.RLock type now fully implement the GC protocol: add a
traverse function and the Py_TPFLAGS_HAVE_GC flag.
2021-06-15 15:09:24 +02:00
Erlend Egeberg Aasland 10a5c806d4
bpo-42064: Move sqlite3 types to global state (GH-26537)
* Move connection type to global state
* Move cursor type to global state
* Move prepare protocol type to global state
* Move row type to global state
* Move statement type to global state
* ADD_TYPE takes a pointer
* pysqlite_get_state is now static inline
2021-06-15 14:47:34 +02:00
Christian Heimes bf527277d4
bpo-44389: Fix deprecation of OP_NO_TLSv1_3 (GH-26700)
Signed-off-by: Christian Heimes <christian@python.org>
2021-06-13 13:46:07 +02:00
Erlend Egeberg Aasland cb7230c7a7
bpo-44389: Remove duplicate SSL_OP_NO_TLSv1_2 flag (GH-26680) 2021-06-12 17:17:58 -03:00
Serhiy Storchaka be8b631b7a
Add more const modifiers. (GH-26691) 2021-06-12 16:11:59 +03:00
Mark Dickinson 4a42cebf6d
bpo-44339: Fix math.pow corner case to comply with IEEE 754 (GH-26606)
Change the behaviour of `math.pow(0.0, -math.inf)` and `math.pow(-0.0, -math.inf)` to return positive infinity instead of raising `ValueError`. This makes `math.pow` consistent with the built-in `pow` (and the `**` operator) for this particular special case, and brings the `math.pow` special-case handling into compliance with IEEE 754.
2021-06-12 10:23:02 +01:00
Christian Heimes e26014f1c4
bpo-44362: ssl: improve deprecation warnings and docs (GH-26646)
Signed-off-by: Christian Heimes <christian@python.org>
2021-06-11 09:15:48 +02:00
Ajith Ramachandran ac867f10b4
bpo-44357:Add `math.cbrt()` function: Cube Root (GH-26622)
* Add math.cbrt() function: Cube Root

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2021-06-10 17:42:09 +01:00
Mark Shannon 31aa0dbff4
bpo-44363: Get test_capi passing with address sanitizer (GH-26639) 2021-06-10 12:37:22 +01:00
Erlend Egeberg Aasland 1c02655fb0
bpo-44329: Refactor sqlite3 statement creation (GH-26566)
Call SQLite API's first, and return early in case of error. At the end,
allocate the object and initialise members. We now avoid unneeded
alloc/dealloc's in case the statement creation fails.
2021-06-08 16:00:56 +01:00
Pablo Galindo 781dc76577
Fix compiler errors for unused variables (GH-26601) 2021-06-08 13:16:24 +01:00
Pablo Galindo 6d518bb3a1
bpo-44348: Revert "bpo-39573: Py_TYPE becomes a static inline function (GH-26493)" (GH-26596)
This reverts commit f3fa63ec75 as is
causing crashes in some Windows tests in the buildbots.
2021-06-08 12:24:40 +01:00
Erlend Egeberg Aasland 0d12f24552
bpo-44326: Remove unused members from pysqlite_Statement (GH-26564)
* Remove unused db member of pysqlite_Statement

* Remove unused sql method from statement object
2021-06-06 23:12:07 +01:00
Erlend Egeberg Aasland 505624e917
bpo-44327: Remove unused members from pysqlite_Connection (GH-26565)
* Remove timeout_started

* Remove timeout member
2021-06-06 23:11:44 +01:00
hrchu 18e9edb7b3
Update bisect docstrings (GH-26548) 2021-06-06 11:22:48 -07:00
Pablo Galindo 6e3b7cf3af
bpo-44304: Ensure the sqlite3 destructor callback is always called with the GIL held (GH-26551) 2021-06-05 23:41:11 +01:00
Pablo Galindo fa106a685c
bpo-44304: Fix crash in the sqlite3 module when the GC clears Statement objects (GH-26545) 2021-06-05 03:50:39 +01:00
Kazantcev Andrey 2780df4781
Align comment for better readability. (GH-26192) 2021-06-04 18:41:23 -03:00
Erlend Egeberg Aasland 7459208de1
bpo-44315: Remove unused connection argument from pysqlite_step() (GH-26535) 2021-06-04 21:42:20 +01:00
Erlend Egeberg Aasland 006fd869e4
bpo-43853: Handle sqlite3_value_text() errors (GH-25422) 2021-06-04 19:34:00 +01:00
Erlend Egeberg Aasland 3446516ffa
bpo-44042: Optimize sqlite3 begin transaction (GH-25908) 2021-06-03 22:24:25 +01:00
Erlend Egeberg Aasland f461a7fc3f
bpo-42862: Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module (GH-24203)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2021-06-03 20:59:26 +01:00
Victor Stinner f3fa63ec75
bpo-39573: Py_TYPE becomes a static inline function (GH-26493)
Convert the Py_TYPE() and Py_SIZE() macros to static inline
functions. The Py_SET_TYPE() and Py_SET_SIZE() functions must now be
used to set an object type and size.
2021-06-03 18:42:59 +02:00
Erlend Egeberg Aasland d88b47b5a3
bpo-42213: Remove redundant cyclic GC hack in sqlite3 (GH-26517)
The sqlite3 module now fully implements the GC protocol, so there's no
need for this workaround anymore.

- Add and use managed resource helper for connections using TESTFN
- Sort test imports
- Split open-tests into their own test case

Automerge-Triggered-By: GH:vstinner
2021-06-03 09:38:19 -07:00
Erlend Egeberg Aasland 82ad22a97d
bpo-42213: Check connection in sqlite3.Connection.__enter__ (GH-26512)
Try to harden connection close:

- add tests that exercise stuff against a closed database
- add wrapper for sqlite3_close_v2()
- check connection on __enter__
- explicitly free pending statements before close()
- sqlite3_close_v2() always returns SQLITE_OK
2021-06-03 17:53:47 +02:00
stratakis bdb56902a3
bpo-44285: getpath.c: Assert that env_file is NULL during an error check (GH-26486)
This was flagged by a static analyzer, but the logic of why this is NULL on error is hard to follow for humans as well.
2021-06-02 16:54:33 +02:00
Erlend Egeberg Aasland fbf25b8c0d
bpo-44165: pysqlite_statement_create now returns a Py object, not an int (GH-26484)
GH-26206 was broken by GH-26475.
2021-06-02 14:22:15 +01:00
Erlend Egeberg Aasland a384b6c040
bpo-44165: Optimise sqlite3 statement preparation by passing string size (GH-26206) 2021-06-02 13:26:06 +01:00
Erlend Egeberg Aasland fffa0f92ad
bpo-42972: Track sqlite3 statement objects (GH-26475)
Allocate and track statement objects in pysqlite_statement_create.

By allocating and tracking creation of statement object in
pysqlite_statement_create(), the caller does not need to worry about GC
syncronization, and eliminates the possibility of getting a badly
created object. All related fault handling is moved to
pysqlite_statement_create().

Co-authored-by: Victor Stinner <vstinner@python.org>
2021-06-01 12:47:37 +02:00
Serhiy Storchaka a6a2065881
bpo-44260: Do not read system entropy without need in Random() (GH-26455) 2021-05-31 23:24:20 +03:00
Victor Stinner 142e5c5445
bpo-44263: Fix _decimal and _testcapi GC protocol (GH-26464)
* _testcapi.heapgctype: implement a traverse function since the type
  is defined with Py_TPFLAGS_HAVE_GC.
* _decimal: PyDecSignalDictMixin_Type is no longer defined with
  Py_TPFLAGS_HAVE_GC since it has no traverse function.
2021-05-31 13:10:31 +02:00
Erlend Egeberg Aasland d1124b09e8
bpo-42972: Fix sqlite3 traverse/clear functions (GH-26452) 2021-05-31 10:24:56 +02:00
Hai Shi 4b20f2574d
bpo-42972: Fully implement GC protocol for xxlimited (GH-26451) 2021-05-31 09:51:19 +02:00
Pablo Galindo 8b4312b909
bpo-44252: Correctly implement gc support for SSLError objects (GH-26439) 2021-05-29 00:29:52 +01:00
Ken Jin 490b638e63
bpo-42972: Fix GC assertion error in _winapi by untracking Overlapped earlier (GH(26429) 2021-05-28 18:29:19 +02:00
Ken Jin 0fa282c55f
bpo-42972: Fully support GC for _winapi.Overlapped (GH-26381) 2021-05-28 11:06:46 +02:00
Erlend Egeberg Aasland 3f8d332527
bpo-42972: Fully implement GC protocol for functools LRU cache (GH-26423) 2021-05-28 11:02:42 +02:00
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