Commit Graph

12735 Commits

Author SHA1 Message Date
Serhiy Storchaka 492d4109f4
bpo-42885: Optimize search for regular expressions starting with "\A" or "^" (GH-32021)
Affected functions are re.search(), re.split(), re.findall(), re.finditer()
and re.sub().
2022-03-22 17:27:55 +02:00
Mark Shannon 49daf6dba8
bpo-47045: Remove `f_state` field (GH-31963)
* Remove the f_state field from _PyInterpreterFrame

*  Make ownership of the frame explicit, replacing the is_generator field with an owner field.
2022-03-22 12:57:19 +00:00
Serhiy Storchaka 345b390ed6
bpo-433030: Add support of atomic grouping in regular expressions (GH-31982)
* Atomic grouping: (?>...).
* Possessive quantifiers: x++, x*+, x?+, x{m,n}+.
  Equivalent to (?>x+), (?>x*), (?>x?), (?>x{m,n}).

Co-authored-by: Jeffrey C. Jacobs <timehorse@users.sourceforge.net>
2022-03-21 18:28:22 +02:00
Serhiy Storchaka 08eb754d84
bpo-23691: Protect the re.finditer() iterator from re-entering (GH-32012) 2022-03-21 13:00:43 +02:00
Gregory P. Smith 9d1c4d69db
bpo-38256: Fix binascii.crc32() when inputs are 4+GiB (GH-32000)
When compiled with `USE_ZLIB_CRC32` defined (`configure` sets this on POSIX systems), `binascii.crc32(...)` failed to compute the correct value when the input data was >= 4GiB. Because the zlib crc32 API is limited to a 32-bit length.

This lines it up with the `zlib.crc32(...)` implementation that doesn't have that flaw.

**Performance:** This also adopts the same GIL releasing for larger inputs logic that `zlib.crc32` has, and causes the Windows build to always use zlib's crc32 instead of our slow C code as zlib is a required build dependency on Windows.
2022-03-20 12:28:15 -07:00
Ma Lin b3f2d4c8ba
bpo-47040: improve document of checksum functions (gh-31955)
Clarifies a versionchanged note on crc32 & adler32 docs that the workaround is only needed for Python 2 and earlier.
Also cleans up an unnecessary intermediate variable in the implementation.

Authored-By: Ma Lin / animalize
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2022-03-19 14:42:04 -07:00
Andrew Svetlov 0a8b8e0d26
bpo-47057: Use FASTCALL convention for FutureIter.throw() (GH-31973)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-03-19 14:01:46 +02:00
Pablo Galindo Salgado 8e3fde728f
bpo-46968: Check for 'sys/auxv.h' in the configure script (GH-31961) 2022-03-18 05:03:22 -07:00
David CARLIER 33698e8ff4
bpo-46030: socket module add couple of FreeBSD constants. (GH-30018)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-17 22:40:00 +02:00
Serhiy Storchaka c2e3c06139
bpo-46996: Remove support of Tcl/Tk < 8.5.12 (GH-31839) 2022-03-17 13:05:52 +02:00
Erlend Egeberg Aasland 4674fd4e93
bpo-44859: Raise more accurate exceptions in `sqlite3` (GH-27695)
* Improve exception compliance with PEP 249
* Raise InterfaceError instead of ProgrammingError for SQLITE_MISUSE.
  If SQLITE_MISUSE is raised, it is a sqlite3 module bug. Users of the
  sqlite3 module are not responsible for using the SQLite C API correctly.
* Don't overwrite BufferError with ValueError when conversion to BLOB fails.
* Raise ProgrammingError instead of Warning if user tries to execute() more
  than one SQL statement.
* Raise ProgrammingError instead of ValueError if an SQL query contains null characters.
* Make sure `_pysqlite_set_result` raises an exception if it returns -1.
2022-03-16 22:58:25 -07:00
Andrew Svetlov 30b5d41fab
bpo-47039: Normalize repr() of asyncio future and task objects (GH-31950) 2022-03-17 03:03:09 +02:00
Christian Heimes a4674f0194
bpo-40280: Detect presence of time.tzset and thread_time clock (GH-31898) 2022-03-15 21:55:35 +01:00
Oleg Iarygin 13b0412223
bpo-46920: Remove code that has explainers why it was disabled (GH-31813) 2022-03-14 17:04:22 +01:00
Oleg Iarygin e885ac3d5f
bpo-46920: Remove code that has no explainer why it was disabled (GH-31814) 2022-03-14 17:02:32 +01:00
Christian Heimes f00ced8396
bpo-40280: select: Use NULL for empty fdset (GH-31865)
wasm32-emscripten does not support exceptfds and requires NULL. Python
now passes NULL instead of a fdset pointer when the input list is empty.
This works fine on all platforms and might even be a tiny bit faster.
2022-03-14 14:40:28 +01:00
Andrew Svetlov 9523c0d84f
bpo-46994: Accept explicit contextvars.Context in asyncio create_task() API (GH-31837) 2022-03-14 13:54:13 +02:00
Andrew Svetlov 690490e4de
bpo-47003: Cleanup _overlapped module (GH-31848) 2022-03-13 23:28:45 +02:00
Alex Grönholm 9f04ee569c
bpo-46805: Add low level UDP socket functions to asyncio (GH-31455) 2022-03-13 18:42:29 +02:00
Victor Stinner 882d8096c2
bpo-46906: Add PyFloat_Pack8() to the C API (GH-31657)
Add new functions to pack and unpack C double (serialize and
deserialize):

* PyFloat_Pack2(), PyFloat_Pack4(), PyFloat_Pack8()
* PyFloat_Unpack2(), PyFloat_Unpack4(), PyFloat_Unpack8()

Document these functions and add unit tests.

Rename private functions and move them from the internal C API
to the public C API:

* _PyFloat_Pack2() => PyFloat_Pack2()
* _PyFloat_Pack4() => PyFloat_Pack4()
* _PyFloat_Pack8() => PyFloat_Pack8()
* _PyFloat_Unpack2() => PyFloat_Unpack2()
* _PyFloat_Unpack4() => PyFloat_Unpack4()
* _PyFloat_Unpack8() => PyFloat_Unpack8()

Replace the "unsigned char*" type with "char*" which is more common
and easy to use.
2022-03-12 00:10:02 +01:00
Christian Heimes ecfff63e06
bpo-40280: Disable AF_UNIX, AF_PACKET, SO_REUSE* on Emscripten (#31829)
Emscripten's socket emulation is limited. AF_UNIX, AF_PACKET, setsockopt(), and most SO_* constants are not supported.
2022-03-11 23:25:14 +01:00
Oleksandr Pavlyk 3b128c0548
bpo-46968: Fix faulthandler for Sapphire Rapids Xeon (GH-31789)
In Linux kernel 5.14 one can dynamically request size of altstacksize
based on hardware capabilities with getauxval(AT_MINSIGSTKSZ).

This changes allows for Python extension's request to Linux kernel
to use AMX_TILE instruction set on Sapphire Rapids Xeon processor
to succeed, unblocking use of the ISA in frameworks.

Introduced HAVE_LINUX_AUXVEC_H in configure.ac and pyconfig.h.in
Used cpython_autoconf:269 docker container to generate configure.
2022-03-11 23:19:35 +01:00
Victor Stinner dc374ac7b0
bpo-46968: Add os.sysconf_names['SC_MINSIGSTKSZ'] (GH-31824) 2022-03-11 23:01:40 +01:00
Oleg Iarygin f84c867dd7
Remove an old, elementtree-specific leak detector (GH-31811) 2022-03-11 09:47:42 -05:00
Erlend Egeberg Aasland 2d5835a019
sqlite3: normalise pre-acronym determiners (GH-31772)
For consistency, replace "a SQL" with "an SQL".
2022-03-10 17:52:47 -08:00
Erlend Egeberg Aasland e801e88744
bpo-45138: Revert GH-28240: Expand traced SQL statements (GH-31788)
This reverts commit d1777515f9.

Automerge-Triggered-By: GH:JelleZijlstra
2022-03-09 09:39:49 -08:00
Erlend Egeberg Aasland d1777515f9
bpo-45138: Expand traced SQL statements in `sqlite3` trace callback (GH-28240) 2022-03-08 18:46:40 -08:00
Erlend Egeberg Aasland b33a1ae703
Docstring: replace pysqlite with sqlite3 (GH-31758)
Replace two instances of "pysqlite" with "sqlite3" in sqlite3
docstrings. Also reword "is a no-op" to "does nothing" for clarity.
2022-03-08 18:45:48 -08:00
Christian Heimes c8a47e76a3
bpo-23325: Fix SIG_IGN and SIG_DFL int comparison in signal module (GH-31759) 2022-03-08 10:22:32 -08:00
Erlend Egeberg Aasland 4d95fa1ac5
bpo-46878: Purge 'non-standard' from sqlite3 docstrings (GH-31612) 2022-03-07 20:18:41 -08:00
Steve Dower 176835c3d5
bpo-46932: Update bundled libexpat to 2.4.7 (GH-31736) 2022-03-07 21:46:18 +00:00
Christian Heimes ca9689f8da
bpo-46933: Make pwd module optional (GH-31700)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2022-03-07 13:36:47 +01:00
Kumar Aditya 5c06dba21b
bpo-46937: convert remaining functions to AC in _weakref (GH-31705) 2022-03-07 18:57:45 +09:00
Christian Heimes 55a5e17d19
bpo-45582: Don't fail if ENV_PATH is None in getpath.py (GH-31699) 2022-03-06 20:49:27 +01:00
Serhiy Storchaka 6927632492
Remove trailing spaces (GH-31695) 2022-03-05 17:47:00 +02:00
slateny cedd2473a9
bpo-25415: Remove confusing sentence from IOBase docstrings (PR-31631) 2022-03-04 12:35:52 -05:00
Dong-hee Na d168c728f7
bpo-46541: Remove usage of _Py_IDENTIFIER from lzma module (GH-31683) 2022-03-05 01:38:56 +09:00
Victor Stinner 65b92ccdec
bpo-46913: Fix test_faulthandler.test_read_null() on UBSan (GH31672)
Disable undefined behavior sanitizer (UBSan) on
faulthandler._read_null().
2022-03-04 00:25:03 +01:00
Victor Stinner 4173d677a1
bpo-46913: Fix test_faulthandler.test_sigfpe() on UBSAN (GH-31662)
Disable undefined behavior sanitizer (UBSAN) on
faulthandler_sigfpe().
2022-03-03 21:45:01 +01:00
Erlend Egeberg Aasland 88567a9970
bpo-46874: Speed up sqlite3 user-defined aggregate 'step' method (GH-31604) 2022-03-03 22:54:36 +09:00
Victor Stinner b6b711a1aa
bpo-46848: Move _PyBytes_Find() to internal C API (GH-31642)
Move _PyBytes_Find() and _PyBytes_ReverseFind() functions to the
internal C API.

bytesobject.c now includes pycore_bytesobject.h.
2022-03-02 14:15:26 +01:00
Dennis Sweeney 6ddb09f35b
bpo-46848: Use stringlib/fastsearch in mmap (GH-31625)
Speed up mmap.find(). Add _PyBytes_Find() and _PyBytes_ReverseFind().
2022-03-01 23:46:30 -05:00
Kumar Aditya e91b0a7139
bpo-46541: remove usage of _Py_IDENTIFIER from _ssl module (GH-31599) 2022-03-02 00:38:21 +09:00
Dong-hee Na 0cc6364185
bpo-46541: Remove usage of _Py_IDENTIFIER from multibytecodec (GH-31475) 2022-03-01 23:35:43 +09:00
Guido van Rossum 7d611b4cab
bpo-46771: Remove two controversial lines from Task.cancel() (GH-31623)
Also from the _asyncio C accelerator module,
and adjust one test that the change caused to fail.

For more discussion see the discussion starting here:
https://github.com/python/cpython/pull/31394#issuecomment-1053545331

(Basically, @asvetlov proposed to return False from cancel()
when there is already a pending cancellation, and I went along,
even though it wasn't necessary for the task group implementation,
and @agronholm has come up with a counterexample that fails
because of this change.  So now I'm changing it back to the old
semantics (but still bumping the counter) until we can have a
proper discussion about this.)
2022-02-28 15:15:56 -08:00
Erlend Egeberg Aasland c32aef4853
bpo-46541: Remove unneeded visits from sqlite3 (GH-31609) 2022-02-28 18:07:40 +09:00
Dong-hee Na 088dd76dba
bpo-46541: Remove unnecessary Py_VISIT (GH-31608) 2022-02-28 08:06:58 +01:00
Victor Stinner e02c47528b
bpo-46606: os.getgroups() doesn't overallocate (GH-31569) 2022-02-27 00:14:28 +01:00
Victor Stinner 87af12bff3
bpo-46836: Rename InterpreterFrame to _PyInterpreterFrame (GH-31583)
Rename also struct _interpreter_frame to struct _PyInterpreterFrame.

Reduce risk of name conflicts if a project includes pycore_frame.h.
2022-02-25 16:22:00 +01:00
Petr Viktorin 2c228a7b8f
bpo-46748: Don't import <stdbool.h> in public headers (GH-31553)
<stdbool.h> is the standard/modern way to define embedd/extends Python free to define bool, true and false, but there are existing applications that use slightly different redefinitions, which fail if the header is included.

It's OK to use stdbool outside the public headers, though.

https://bugs.python.org/issue46748
2022-02-25 09:25:54 +01:00
Inada Naoki ad6c7003e3
bpo-46606: Remove redundant +1. (GH-31561) 2022-02-25 14:13:14 +09:00
Victor Stinner 1b2611eb02
bpo-46656: Remove Py_NO_NAN macro (GH-31160)
Building Python now requires support for floating point Not-a-Number
(NaN): remove the Py_NO_NAN macro.
2022-02-25 01:32:57 +01:00
Christian Heimes 38f331d465
bpo-45898: Remove duplicate symbols from _ctypes/cfield.c (GH-29791) 2022-02-24 20:51:57 +01:00
Tin Tvrtković 7fce1063b6
bpo-46771: Implement task cancel requests counter (GH-31513)
This changes cancelling() and uncancel() to return the count of pending cancellations.

This can be used to avoid bugs in certain edge cases (e.g. two timeouts going off at the same time).
2022-02-23 18:17:00 -08:00
Victor Stinner 9bbdde2180
bpo-45412: Add _PY_SHORT_FLOAT_REPR macro (GH-31171)
Remove the HAVE_PY_SET_53BIT_PRECISION macro (moved to the internal
C API).

* Move HAVE_PY_SET_53BIT_PRECISION macro to pycore_pymath.h.
* Replace PY_NO_SHORT_FLOAT_REPR macro with _PY_SHORT_FLOAT_REPR
  macro which is always defined. gcc -Wundef emits a warning when
  using _PY_SHORT_FLOAT_REPR but the macro is not defined, if
  pycore_pymath.h include was forgotten.
2022-02-23 18:16:23 +01:00
Dong-hee Na 1935e1cc28
bpo-46794: Bump up the libexpat version into 2.4.6 (GH-31487) 2022-02-23 10:40:30 +09:00
Eric Snow 1f455361ec
bpo-46765: Replace Locally Cached Strings with Statically Initialized Objects (gh-31366)
https://bugs.python.org/issue46765
2022-02-22 17:23:51 -07:00
Inada Naoki 74127b89a8
bpo-46606: Reduce stack usage of getgroups and setgroups (GH-31073)
NGROUPS_MAX was 32 before Linux 2.6.4 but 65536 since Linux 2.6.4.
2022-02-22 11:59:27 +09:00
Andrew Svetlov 4140bcb1cd
bpo-45390: Propagate CancelledError's message from cancelled task to its awaiter (GH-31383)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-02-21 22:59:04 +02:00
Dong-hee Na 2b86616456
bpo-46541: Remove usage of _Py_IDENTIFIER from pyexpat (GH-31468) 2022-02-21 23:46:52 +09:00
Christian Heimes be095f6c32
bpo-46232: Fix parsing of certs with bit string in DN (GH-30351) 2022-02-20 21:42:31 +01:00
Yilei "Dolee" Yang 6312c1052c
bpo-46784: Add newly exported expat symbols to the namespace. (GH-31397)
The libexpat 2.4.1 upgrade from  introduced the following new exported symbols:

* `testingAccountingGetCountBytesDirect`
* `testingAccountingGetCountBytesIndirect`
* `unsignedCharToPrintable`
* `XML_SetBillionLaughsAttackProtectionActivationThreshold`
* `XML_SetBillionLaughsAttackProtectionMaximumAmplification`

We need to adjust [Modules/expat/pyexpatns.h](https://github.com/python/cpython/blob/master/Modules/expat/pyexpatns.h)

(The newer libexpat upgrade  has no new symbols).

Automerge-Triggered-By: GH:gpshead
2022-02-18 14:33:06 -08:00
Dong-hee Na 8cb5f707a8
bpo-46541: Remove usage of _Py_IDENTIFIER from array module (GH-31376) 2022-02-17 13:02:17 +09:00
Dong-hee Na e8a19b092f
bpo-46541: Remove usage of _Py_IDENTIFIER from mmap module (GH-31375) 2022-02-17 01:04:38 +09:00
Erlend Egeberg Aasland b2077117d1
bpo-46541: Replace _Py_IDENTIFIER with _Py_ID in sqlite3 (GH-31351) 2022-02-17 00:24:44 +09:00
Dong-hee Na d64f3caebe
bpo-46541: Remove usage of _Py_IDENTIFIER from csv module (GH-31372) 2022-02-17 00:24:03 +09:00
Dong-hee Na e59309b9d0
bpo-46541: Remove usage of _Py_IDENTIFIER from dbms modules (GH-31358) 2022-02-16 18:57:28 +09:00
Guido van Rossum 602630ac18
bpo-46752: Add TaskGroup; add Task..cancelled(),.uncancel() (GH-31270)
asyncio/taskgroups.py is an adaptation of taskgroup.py from EdgeDb, with the following key changes:

- Allow creating new tasks as long as the last task hasn't finished
- Raise [Base]ExceptionGroup (directly) rather than TaskGroupError deriving from MultiError
- Instead of monkey-patching the parent task's cancel() method,
  add a new public API to Task

The Task class has a new internal flag, `_cancel_requested`, which is set when `.cancel()` is called successfully. The `.cancelling()` method returns the value of this flag. Further `.cancel()` calls while this flag is set return False. To reset this flag, call `.uncancel()`.

Thus, a Task that catches and ignores `CancelledError` should call `.uncancel()` if it wants to be cancellable again; until it does so, it is deemed to be busy with uninterruptible cleanup.

This new Task API helps solve the problem where TaskGroup needs to distinguish between whether the parent task being cancelled "from the outside" vs. "from inside".

Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-02-15 15:42:04 -08:00
DongGeon Lee 278fdd3e3a
bpo-46728: fix docstring of combinations_with_replacement for consistency (GH-31293) 2022-02-15 09:02:21 +09:00
Cyril Jouve 8aaaf7e182
bpo-46400: Update libexpat from 2.4.1 to 2.4.4 (GH-31022) 2022-02-13 00:29:41 +09:00
Jacob Walls 168fd6453b
bpo-45948: Remove constructor discrepancy in C version of ElementTree.XMLParser (GH-31152)
Both implementations accept target=None now.
2022-02-12 10:27:02 +02:00
Petr Viktorin 204946986f
bpo-46613: Add PyType_GetModuleByDef to the public API (GH-31081)
* Make PyType_GetModuleByDef public (remove underscore)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-02-11 17:22:11 +01:00
Dong-hee Na 0ac5372bf6
bpo-46323: Fix double-free issue for borrowed refs (GH-31272) 2022-02-11 17:48:47 +09:00
Dennis Sweeney 0a145069e8
bpo-44953: Add vectorcall for itemgetter and attrgetter instances (GH-27828) 2022-02-10 16:57:47 -05:00
Dong-hee Na db052851a7
bpo-46323: Allow alloca(0) for python callback function of ctypes (GH-31249) 2022-02-10 19:10:07 +09:00
Dong-hee Na d18120cd67
bpo-46323: Reduce stack usage of ctypes python callback function. (GH-31224) 2022-02-10 03:10:11 +09:00
Eric Snow 81c72044a1
bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized global objects. (gh-30928)
We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code.  It is still used in a number of non-builtin stdlib modules.

The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime.  A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings).

https://bugs.python.org/issue46541#msg411799 explains the rationale for this change.

The core of the change is in:

* (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros
* Include/internal/pycore_runtime_init.h - added the static initializers for the global strings
* Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState
* Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers

I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings.  That check is added to the PR CI config.

The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()).  This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *.

The following are not changed (yet):

* stop using _Py_IDENTIFIER() in the stdlib modules
* (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API
* (maybe) intern the strings during runtime init

https://bugs.python.org/issue46541
2022-02-08 13:39:07 -07:00
Dong-hee Na b5527688aa
bpo-46323: Use PyObject_Vectorcall while calling ctypes callback function (GH-31138) 2022-02-08 22:09:17 +09:00
Dong-hee Na e959dd9f5c
bpo-46323 Fix ref leak if ctypes.CFuncPtr raises an error. (GH-31209) 2022-02-08 14:22:13 +09:00
Victor Stinner f20ca766fe
bpo-46670: Fix #ifdef in sha3module.c (GH-31180)
* Test if HAVE_ALIGNED_REQUIRED is defined, not its value.
* Define explicitly NOT_PYTHON macro to 0.

Fix "gcc -Wundef" warnings.
2022-02-07 16:22:24 +01:00
Victor Stinner 4f1d3f33dd
bpo-46670: Remove unused macros in the Modules directory (GH-31194)
* bpo-46670: Remove unused macros in the Modules directory

* Add again LINKAT_DIR_FD_CONVERTER: generated by Argument Clinic
2022-02-07 16:21:31 +01:00
Victor Stinner d3e53bc532
bpo-39277: Fix PY_TIMEOUT_MAX cast in _threadmodule.c (GH-31195)
Cast PY_TIMEOUT_MAX to double, not to _PyTime_t.

Fix the clang warning:

Modules/_threadmodule.c:1648:26: warning: implicit conversion from
'_PyTime_t' (aka 'long') to 'double' changes value from
9223372036854775 to 9223372036854776
[-Wimplicit-const-int-float-conversion]
    double timeout_max = (_PyTime_t)PY_TIMEOUT_MAX * 1e-6;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~ ~
2022-02-07 16:21:09 +01:00
Victor Stinner 4cce1352bb
bpo-46323: _ctypes.CFuncPtr fails if _argtypes_ is too long (GH-31188)
ctypes.CFUNCTYPE() and ctypes.WINFUNCTYPE() now fail to create the
type if its "_argtypes_" member contains too many arguments.
Previously, the error was only raised when calling a function.

Change also how CFUNCTYPE() and WINFUNCTYPE() handle KeyError to
prevent creating a chain of exceptions if ctypes.CFuncPtr raises an
error.
2022-02-07 14:53:15 +01:00
Zackery Spytz 59e004af63
bpo-40479: Fix undefined behavior in Modules/_hashopenssl.c (GH-31153)
va_end() must be called before returning.
2022-02-06 23:40:54 -08:00
Victor Stinner b556f53785
bpo-46670: Test if a macro is defined, not its value (GH-31178)
* audioop.c: #ifdef WORDS_BIGENDIAN
* ctypes.h: #ifdef USING_MALLOC_CLOSURE_DOT_C
* _ctypes/malloc_closure.c: #ifdef HAVE_FFI_CLOSURE_ALLOC
  and #ifdef USING_APPLE_OS_LIBFFI
* pytime.c: #ifdef __APPLE__
* unicodeobject.c: #ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
2022-02-07 01:46:51 +01:00
Christian Heimes 96b344c2f1
bpo-40280: Address more test failures on Emscripten (GH-31050)
Co-authored-by: Brett Cannon <brett@python.org>
2022-02-05 20:52:01 +01:00
Benjamin Peterson 1aa6be06c4
closes bpo-46626: Expose IP_BIND_ADDRESS_NO_PORT socket option. (GH-31106) 2022-02-03 10:46:50 -08:00
Petr Viktorin 0ef0853012
bpo-46433: _PyType_GetModuleByDef: handle static types in MRO (GH-30696)
Automerge-Triggered-By: GH:encukou
2022-02-02 07:57:51 -08:00
Christian Heimes f66c857572
bpo-45459: Add Py_buffer to limited API (GH-29991)
- [x] ``Py_buffer`` struct
- [x] ``PyBuffer_*()`` API functions
- [x] ``PyBUF_*`` constants
- [x] ``Py_bf_getbuffer`` and ``Py_bf_releasebuffer`` type slots
- [x] ``PyMemoryView_FromBuffer()`` API
- [x] tests for limited API
- [x] ``make regen-limited-abi``
- [x] documentation update
- [ ] export ``PyPickleBuffer*()`` API ???
2022-02-02 07:03:10 -08:00
Kumar Aditya a05866ce3e
Remove Python 3.3 compatibility code from overlapped.c (GH-31049) 2022-02-02 10:16:36 +02:00
Victor Stinner 6c6a153dee
bpo-46417: signal: move siginfo_type to the module state (GH-30964) 2022-01-27 21:21:50 +01:00
Victor Stinner af32b3ef1f
bpo-40170: PyType_SUPPORTS_WEAKREFS() becomes a regular function (GH-30938)
Convert the PyType_SUPPORTS_WEAKREFS() macro to a regular function.
It no longer access the PyTypeObject.tp_weaklistoffset member
directly.

Add _PyType_SUPPORTS_WEAKREFS() static inline functions, used
internally by Python for best performance.
2022-01-27 03:00:55 +01:00
Erlend Egeberg Aasland 3eb3b4f270
bpo-43853: Expand test suite for SQLite UDF's (GH-27642) 2022-01-26 08:26:16 -08:00
Christian Heimes 6e5a193816
bpo-46513: Remove AC_C_CHAR_UNSIGNED / __CHAR_UNSIGNED__ (GH-30851) 2022-01-26 01:03:49 -08:00
Mark Dickinson 83a0ef2162
bpo-29882: Fix portability bug introduced in GH-30774 (#30794) 2022-01-23 09:59:34 +00:00
Victor Stinner 9c8e490b8f
bpo-46417: Clear _io module static objects at exit (GH-30807)
Add _PyIO_Fini() function, called by finalize_interp_clear(). It
clears static objects used by the _io extension module.
2022-01-22 23:22:20 +01:00
Kumar Aditya ea5b96842e
bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777)
* bpo-46469: Make asyncio generic classes return GenericAlias

* 📜🤖 Added by blurb_it.

* Update Misc/NEWS.d/next/Library/2022-01-22-05-05-08.bpo-46469.plUab5.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-01-22 13:28:53 +02:00
Erlend Egeberg Aasland 38afeb1a33
bpo-46249: Move set lastrowid out of the sqlite3 query loop (GH-30489) 2022-01-22 18:40:22 +09:00
Victor Stinner 8ee07dda13
bpo-46417: Add _PyType_GetSubclasses() function (GH-30761)
Add a new _PyType_GetSubclasses() function to get type's subclasses.

_PyType_GetSubclasses(type) returns a list which holds strong
refererences to subclasses. It is safer than iterating on
type->tp_subclasses which yields weak references and can be modified
in the loop.

_PyType_GetSubclasses(type) now holds a reference to the tp_subclasses
dict while creating the list of subclasses.

set_collection_flag_recursive() of _abc.c now uses
_PyType_GetSubclasses().
2022-01-21 23:29:10 +01:00
Thomas Klausner 40fcd16889
bpo-30512: Add CAN Socket support for NetBSD (GH-30066) 2022-01-21 09:44:05 +02:00
Victor Stinner d013b24135
bpo-46417: signal uses PyStructSequence_NewType() (GH-30735)
The signal module now creates its struct_siginfo type as a heap type
using PyStructSequence_NewType(), rather than using a static type.

Add 'siginfo_type' member to the global signal_state_t structure.
2022-01-21 04:02:38 +01:00
Victor Stinner 1781d55eb3
bpo-46417: _curses uses PyStructSequence_NewType() (GH-30736)
The _curses module now creates its ncurses_version type as a heap
type using PyStructSequence_NewType(), rather than using a static
type.

* Move _PyStructSequence_FiniType() definition to pycore_structseq.h.
* test.pythoninfo: log curses.ncurses_version.
2022-01-21 03:30:20 +01:00
Victor Stinner 17f268a4ae
bpo-46417: time module uses PyStructSequence_NewType() (GH-30734)
The time module now creates its struct_time type as a heap
type using PyStructSequence_NewType(), rather than using a static
type.

* Add a module state to the time module: add traverse, clear and free
  functions.
* Use PyModule_AddType().
* Remove the 'initialized' variable.
2022-01-21 02:52:43 +01:00
Victor Stinner f389b37fb1
bpo-46417: _thread uses PyStructSequence_NewType() (GH-30733)
The _thread module now creates its _ExceptHookArgs type as a heap
type using PyStructSequence_NewType(), rather than using a static
type.
2022-01-21 02:51:04 +01:00
Zane Bitter 27df7566bc
bpo-41857: mention timeout argument units in select.poll() and select.depoll() doc-strings (GH-22406) 2022-01-21 01:08:44 +02:00
Steve Dower 7407fe4c25
bpo-46028: Calculate base_executable by resolving symlinks in a venv (GH-30144) 2022-01-18 15:46:26 +00:00
Brandt Bucher 5cd9a162cd
bpo-46361: Fix "small" `int` caching (GH-30583) 2022-01-16 16:06:37 +00:00
Mark Dickinson d02c5e9b55
bpo-46258: Streamline isqrt fast path (#30333) 2022-01-15 09:58:04 +00:00
Christian Heimes cfbde65df3
bpo-46383: Fix signature of zoneinfo module_free function (GH-30607) 2022-01-15 09:52:19 +01:00
Victor Stinner 7c770d3350
bpo-46280: Fix tracemalloc_copy_domain() (GH-30591)
Test if tracemalloc_copy_traces() failed to allocated memory in
tracemalloc_copy_domain().
2022-01-14 05:11:38 +01:00
Eric Snow 322f962f3e
bpo-45953: Statically initialize all the non-object PyInterpreterState fields we can. (gh-30589)
https://bugs.python.org/issue45953
2022-01-13 17:17:28 -07:00
neonene d4e64cd4b0
bpo-46362: Ensure ntpath.abspath() uses the Windows API correctly (GH-30571)
This makes ntpath.abspath()/getpath_abspath() follow normpath(), since some WinAPIs such as PathCchSkipRoot() require backslashed paths.
2022-01-13 23:35:42 +00:00
Christian Heimes 276c234ce0
bpo-40479: Fix typo, flag must be set for OpenSSL < 3.0.0 (GH-30584) 2022-01-13 21:47:42 +01:00
Victor Stinner 1a4d1c1c9b
bpo-46070: _PyGC_Fini() untracks objects (GH-30577)
Py_EndInterpreter() now explicitly untracks all objects currently
tracked by the GC. Previously, if an object was used later by another
interpreter, calling PyObject_GC_UnTrack() on the object crashed if
the previous or the next object of the PyGC_Head structure became a
dangling pointer.
2022-01-13 19:28:32 +01:00
Christian Heimes 443b308fee
bpo-40479: Fix hashlib's usedforsecurity for OpenSSL 3.0.0 (GH-30455) 2022-01-13 09:46:38 +01:00
Christian Heimes a6ca8eee22
bpo-46315: Add ifdef HAVE_ feature checks for WASI compatibility (GH-30507) 2022-01-13 09:46:04 +01:00
Eric Snow ed57b36c32
bpo-45953: Statically allocate the main interpreter (and initial thread state). (gh-29883)
Previously, the main interpreter was allocated on the heap during runtime initialization.  Here we instead embed it into _PyRuntimeState, which means it is statically allocated as part of the _PyRuntime global.  The same goes for the initial thread state (of each interpreter, including the main one).  Consequently there are fewer allocations during runtime/interpreter init, fewer possible failures, and better memory locality.

FYI, this also helps efforts to consolidate globals, which in turns helps work on subinterpreter isolation.

https://bugs.python.org/issue45953
2022-01-12 16:28:46 -07:00
Christian Heimes e34c9367f8
bpo-40280: Allow to compile _testcapi as builtin module (GH-30559) 2022-01-12 20:27:37 +01:00
Christian Heimes 43839ba438
bpo-40280: Add --with-emscripten-target to build for browser or node (GH-30552)
Co-authored-by: Ethan Smith <ethan@ethanhs.me>
2022-01-12 16:08:19 +01:00
Victor Stinner 08bc1bad11
bpo-46303: Fix fileutils.h compiler warnings (GH-30550)
Add missing pycore_fileutils.h include in _tkinter.c and
_testconsole.c.
2022-01-12 00:35:26 +01:00
Victor Stinner ea1a54506b
bpo-46303: Move fileutils.h private functions to internal C API (GH-30484)
Move almost all private functions of Include/cpython/fileutils.h to
the internal C API Include/internal/pycore_fileutils.h.

Only keep _Py_fopen_obj() in Include/cpython/fileutils.h, since it's
used by _testcapi which must not use the internal C API.

Move EncodeLocaleEx() and DecodeLocaleEx() functions from _testcapi
to _testinternalcapi, since the C API moved to the internal C API.
2022-01-11 11:56:16 +01:00
Serhiy Storchaka 2d787971c6
bpo-37295: Use constant-time comb() and perm() for larger n depending on k (GH-30305) 2022-01-09 15:32:25 +02:00
Daniel c9dc1f491e
bpo-46297: Fix interpreter crash on startup with multiple PythonPaths set in registry (GH-30466) 2022-01-07 22:26:00 +00:00
Erlend Egeberg Aasland b127e70a8a
bpo-46070: Fix asyncio initialisation guard (GH-30423)
If init flag is set, exit successfully immediately.
If not, only set the flag after successful initialization.
2022-01-07 15:08:19 +01:00
Erlend Egeberg Aasland f1a58441ee
bpo-44092: Remove unused member `reset` from `sqlite3.Cursor` (GH-30377)
Automerge-Triggered-By: GH:pablogsal
2022-01-03 15:47:16 -08:00
Erlend Egeberg Aasland 9d6a239a34
bpo-44092: Don't reset statements/cursors before rollback (GH-26026)
In SQLite versions pre 3.7.11, pending statements would block a rollback.  This is no longer the case, so remove the workaround.
2022-01-03 19:02:39 +00:00
David CARLIER c960b191b8
bpo-46222: posixmodule sendfile FreeBSD's constants updates. (GH-30327)
* posixodule sendfile FreeBSD's constants updates.

* 📜🤖 Added by blurb_it.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2022-01-03 15:01:04 +02:00
Irit Katriel a82baed0e9
bpo-45615: Add missing test for printing traceback for non-exception. Fix traceback.py (GH-30091) 2022-01-02 09:34:03 +00:00
Mark Dickinson 0b58bac3e7
bpo-37295: More direct computation of power-of-two factor in math.comb (GH-30313)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-12-31 19:52:27 +00:00
Sebastian Pipping e18d81569f
bpo-45321: Add missing error codes to module `xml.parsers.expat.errors` (GH-30188)
The idea is to ensure that module `xml.parsers.expat.errors`
contains all known error codes and messages,
even when CPython is compiled or run with an outdated version of libexpat.

https://bugs.python.org/issue45321
2021-12-31 10:57:00 +01:00
David CARLIER 66c47b63a0
bpo-46176: mmap module adding MAP_STACK constant. (GH-30252) 2021-12-29 22:52:29 +09:00
Mark Dickinson 02b5417f11
bpo-37295: Speed up math.comb(n, k) for 0 <= k <= n <= 67 (GH-30275) 2021-12-28 12:26:40 +00:00
neonene 6214caafbe
bpo-40915: Avoid compiler warnings by fixing mmapmodule conversion from LARGE_INTEGER to Py_ssize_t (GH-30175) 2021-12-18 13:03:43 +00:00
Irit Katriel 396b58345f
bpo-45711: Remove type and traceback from exc_info (GH-30122)
* Do not PUSH/POP traceback or type to the stack as part of exc_info

* Remove exc_traceback and exc_type from _PyErr_StackItem

* Add to what's new, because this change breaks things like Cython
2021-12-17 14:46:22 +00:00
Mark Shannon 342b93f9f2
bpo-46072: Add --with-pystats configure option to simplify gathering of VM stats (GH-30116)
* Simplify specialization stats collection macros.

* Add --enable-pystats option to configure.

* Update specialization summary script to handle larger number of kinds
2021-12-15 15:32:32 +00:00
Christian Heimes 74821b3053
bpo-46023: Skip build if module is marked as DISABLED (GH-30100) 2021-12-14 15:42:46 +01:00
Gareth Rees a62be77266
bpo-45643: Add signal.SIGSTKFLT on platforms where this is defined (GH-29266) 2021-12-13 18:22:43 +01:00
Kumar Aditya 41026c3155
bpo-45855: Replaced deprecated `PyImport_ImportModuleNoBlock` with PyImport_ImportModule (GH-30046) 2021-12-12 10:45:20 +02:00
Steve Dower bfc59ed0a0
bpo-46049: Fixes ._pth support on non-Windows (GH-30051) 2021-12-11 15:06:17 +00:00
Steve Dower 971ece8e17
bpo-46048: Fix parsing of single character lines in getpath readlines() (GH-30048) 2021-12-11 13:43:40 +00:00
neonene 3f398a77d3
bpo-45582: Fix test_embed failure during a PGO build on Windows (GH-30014)
This defines VPATH differently in PGO instrumentation builds, to account for a different default output directory. It also adds sys._vpath on Windows to make the value available to sysconfig so that it can be used in tests.
2021-12-10 17:13:55 +00:00
Christian Heimes 036bbb1d1b
bpo-46023: Fix makesetup handling of disabled rule (GH-30001) 2021-12-10 14:11:55 +01:00
Thomas Klausner 2fb797e93c
bpo-46000: Improve NetBSD curses compatibility (GH-29947) 2021-12-10 11:41:47 +02:00
Gabriele N. Tornetta 50669083fe
bpo-43931: Export Python version as API data (GH-25577)
When Python is embedded in other applications, it is not easy to determine which version of Python is being used. This change exposes the Python version as part of the API data. Tools like Austin (https://github.com/P403n1x87/austin) can benefit from this data when targeting applications like uWSGI, as the Python version can then be inferred systematically by looking at the exported symbols rather than relying on unreliable pattern matching or other hacks (like remote code execution etc...).

Automerge-Triggered-By: GH:pablogsal
2021-12-09 17:52:05 -08:00
Steve Dower 3363e1cb05
bpo-46018: Ensure that math.expm1 does not raise on underflow (GH-29997) 2021-12-09 18:31:54 +00:00
Pablo Galindo Salgado f0d290d25c
bpo-46025: Fix a crash in the atexit module for auto-unregistering functions (GH-30002) 2021-12-09 13:53:44 +00:00
David CARLIER 267539bff7
bpo-46016: fcntl module add FreeBSD's F_DUP2FD_CLOEXEC flag support (GH-29993) 2021-12-08 23:28:51 +01:00
Steve Dower 7778116c2f
bpo-46015: Fixes calculation of sys.path in a venv on Windows (GH-29992)
Also ensures that pybuilddir.txt is written early enough in the build to be picked up by later steps.
2021-12-08 19:25:58 +00:00
Steve Dower b0b3086279
bpo-45582: Write empty pybuilddir.txt on Windows to allow relocatable build directories (GH-29979) 2021-12-08 02:18:21 +00:00
Eric Snow 758b74e71e
bpo-46008: Add _PyInterpreterState_Main(). (gh-29978)
PyInterpreterState_Main() is a plain function exposed in the public C-API. For internal usage we can take the more efficient approach in this PR.

https://bugs.python.org/issue46008
2021-12-07 18:56:06 -07:00