Commit Graph

12767 Commits

Author SHA1 Message Date
AN Long 3256b178ed
bpo-42658: Use LCMapStringEx in ntpath.normcase to match OS behaviour for case-folding (GH-32010) 2022-06-07 00:47:27 +01:00
Illia Volochii d1e2e0e1b2
gh-93475: Expose FICLONE and FICLONERANGE constants in fcntl (#93478) 2022-06-06 23:21:58 +02:00
Christian Heimes 22fed605e0
gh-90473: Make chmod a dummy on WASI, skip chmod tests (GH-93534)
WASI does not have the ``chmod(2)`` syscall yet.
2022-06-06 19:24:11 +02:00
Pieter Eendebak 5a80e8580e
remove redundant argument to log_helper (GH-93440) 2022-06-03 08:40:05 +01:00
Christian Heimes 8a5e3c2ec6
gh-69093: Fix Setup.local.in rule for _sqlite3 (GH-93380) 2022-05-31 21:23:49 +02:00
Kumar Aditya a565ab0fd5
GH-93312: Add os.PIDFD_NONBLOCK flag (#93313) 2022-05-31 12:51:29 +02:00
oda-gitso 7fa9b7daa5
gh-92839: fixed typo in _bisectmodule.c (line 131) (#92849) 2022-05-28 13:08:06 -05:00
Eric Snow caa279d6fd
bpo-40514: Drop EXPERIMENTAL_ISOLATED_SUBINTERPRETERS (gh-93185)
This was added for bpo-40514 (gh-84694) to test out a per-interpreter GIL. However, it has since proven unnecessary to keep the experiment in the repo. (It can be done as a branch in a fork like normal.) So here we are removing:

* the configure option
* the macro
* the code enabled by the macro
2022-05-27 17:38:01 -06:00
Mark Shannon bbcf42449e
GH-90230: Add stats to breakdown the origin of calls to `PyEval_EvalFrame` (GH-93284) 2022-05-27 16:31:41 +01:00
Victor Stinner 22b75d9bef
gh-82616: Add Py_IS_TYPE_SIGNED() macro (#93178)
_posixsubprocess: add a static assertion to ensure that the pid_t
type is signed.

Replace _Py_IntegralTypeSigned() with _Py_IS_TYPE_SIGNED().
2022-05-27 15:05:35 +02:00
Kumar Aditya cb04a09d2d
GH-93207: Remove HAVE_STDARG_PROTOTYPES configure check for stdarg.h (#93215) 2022-05-27 13:30:45 +02:00
Wenzel Jakob 5e34b494a0
gh-60074: add new stable API function PyType_FromMetaclass (GH-93012)
Added a new stable API function ``PyType_FromMetaclass``, which mirrors
the behavior of ``PyType_FromModuleAndSpec`` except that it takes an
additional metaclass argument. This is, e.g., useful for language
binding tools that need to store additional information in the type
object.
2022-05-27 10:27:39 +02:00
oda-gitso 32e3b790bc
gh-93172: Remove unnecessary "if"s in binascii_a2b_qp_impl() from Modules/binascii.c (GH-93181) 2022-05-25 11:38:47 -04:00
Victor Stinner 71d8775fee
gh-93202: Always use %zd printf formatter (#93201)
Python now always use the ``%zu`` and ``%zd`` printf formats to
format a size_t or Py_ssize_t number. Building Python 3.12 requires a
C11 compiler, so these printf formats are now always supported.

* PyObject_Print() and _PyObject_Dump() now use the printf %zd format
  to display an object reference count.
* Update PY_FORMAT_SIZE_T comment.
* Remove outdated notes about the %zd format in PyBytes_FromFormat()
  and PyUnicode_FromFormat() documentations.
* configure no longer checks for the %zd format and no longer defines
  PY_FORMAT_SIZE_T macro in pyconfig.h.
* pymacconfig.h no longer undefines PY_FORMAT_SIZE_T: macOS 10.4 is
  no longer supported. Python 3.12 now requires macOS 10.6 (Snow
  Leopard) or newer.
2022-05-25 14:21:36 +02:00
Miro Hrončok 16a7e4a0b7
gh-92728: Restore re.template, but deprecate it (GH-93161)
Revert "bpo-47211: Remove function re.template() and flag re.TEMPLATE (GH-32300)"

This reverts commit b09184bf05.
2022-05-25 09:05:35 +03:00
Victor Stinner 08e4e887f2
gh-92658: AF_HYPERV is only supported on Windows (#93192)
Only build the AF_HYPERV support on Windows for the _socket extension.
FreeBSD defines the AF_HYPERV macro but doesn't have the SOCKADDR_HV
type.
2022-05-25 04:44:57 +02:00
neonene ac1dcb8ee7
gh-92434: Silence a compiler warning in _xxsubinterpretersmodule.c for 32bit version (gh-93091) 2022-05-25 10:22:39 +09:00
Jordan Borean fbd11f3edd
gh-92658: Add Hyper-V socket support (GH-92755) 2022-05-24 21:37:06 +01:00
Serhiy Storchaka 14c0d33016
gh-93044: No longer convert the database argument of sqlite3.connect() to bytes (GH-93046)
Just pass it to the factory as is.
2022-05-21 14:35:46 +03:00
Serhiy Storchaka d853758092
gh-91922: Fix sqlite connection on nonstardard locales and paths (GH-92926) 2022-05-20 11:53:05 +03:00
Steve Dower 403d16fa28
gh-92913: Clarify changes to PyInitConfig.module_search_paths[_set] fields (GH-92980) 2022-05-19 20:23:53 +01:00
Christian Heimes 137fd3d88a
gh-90473: Decrease recursion limit and skip tests on WASI (GH-92803) 2022-05-19 12:43:16 +02:00
Dennis Sweeney 524f03c08c
Fix NULL check in test_type_from_ephemeral_spec in_testcapimodule.c (GH-92863) 2022-05-17 18:17:16 +03:00
Dennis Sweeney 702e0da000
Fix NULL test in _testinternalcapi (GH-92861) 2022-05-16 21:32:48 -04:00
Erlend Egeberg Aasland 00f22e8cc2
gh-92547: Remove deprecated sqlite3 features (#92548)
The following sqlite3 features were deprecated in 3.10, scheduled for
removal in 3.12:

- sqlite3.OptimizedUnicode (gh-23163)
- sqlite3.enable_shared_cache (gh-24008)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Signed-off-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-05-16 19:52:08 +02:00
Victor Stinner f62ad4f2c4
gh-89653: Use int type for Unicode kind (#92704)
Use the same type that PyUnicode_FromKindAndData() kind parameter
type (public C API): int.
2022-05-13 12:41:05 +02:00
Mark Shannon 22a1db378c
GH-92236: Remove spurious "line" event when starting coroutine or generator. (GH-92722) 2022-05-13 11:24:45 +01:00
Victor Stinner db388df1d9
gh-89653: PEP 670: Convert PyUnicode_KIND() macro to function (#92705)
In the limited C API version 3.12, PyUnicode_KIND() is now
implemented as a static inline function. Keep the macro for the
regular C API and for the limited C API version 3.11 and older to
prevent introducing new compiler warnings.

Update _decimal.c and stringlib/eq.h for PyUnicode_KIND().
2022-05-13 11:49:56 +02:00
Paul Ganssle 83c0247d47
Check result of utc_to_seconds and skip fold probe in pure Python (#91582)
The `utc_to_seconds` call can fail, here's a minimal reproducer on
Linux:

TZ=UTC python -c "from datetime import *; datetime.fromtimestamp(253402300799 + 1)"

The old behavior still raised an error in a similar way, but only
because subsequent calculations happened to fail as well. Better to fail
fast.

This also refactors the tests to split out the `fromtimestamp` and
`utcfromtimestamp` tests, and to get us closer to the actual desired
limits of the functions. As part of this, we also changed the way we
detect platforms where the same limits don't necessarily apply (e.g.
Windows).

As part of refactoring the tests to hit this condition explicitly (even
though the user-facing behvior doesn't change in any way we plan to
guarantee), I noticed that there was a difference in the places that
`datetime.utcfromtimestamp` fails in the C and pure Python versions, which
was fixed by skipping the "probe for fold" logic for UTC specifically —
since UTC doesn't have any folds or gaps, we were never going to find a
fold value anyway. This should prevent some failures in the pure python
`utcfromtimestamp` method on timestamps close to 0001-01-01.

There are two separate news entries for this because one is a
potentially user-facing change, the other is an internal code
correctness change that, if anything, changes some error messages. The
two happen to be coupled because of the test refactoring, but they are
probably best thought of as independent changes.

Fixes GH-91581
2022-05-12 17:00:50 -04:00
Inada Naoki f9c9354a7a
gh-92536: PEP 623: Remove wstr and legacy APIs from Unicode (GH-92537) 2022-05-12 14:48:38 +09:00
Victor Stinner dfdebda052
gh-92584: test_decimal uses shutil.which() (#92640)
test_decimal now uses shutil.which() rather than deprecated
distutils.spawn.find_executable().
2022-05-11 01:42:09 +02:00
David CARLIER 9d85aba9e2
gh-91968: Add socket constants SO_USER_COOKIE/SO_RTABLE from BSD (#91967)
Those are somewhat equivalent to Linux' SO_MARK.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-08 16:19:41 -07:00
Michael Droettboom adcb6a6055
gh-92356: Fix regression in ctypes function call overhead (#92357)
38f331d introduced a delayed initialization routine to set up
ctypes formattable (`_ctypes_init_fielddesc`), but inadvertently
removed setting the `initialization` flag to 1 to avoid initting
each time.
2022-05-05 20:59:45 -07:00
Paul Ganssle 1303f8c927
gh-80010: Expand fromisoformat to include most of ISO-8601 (#92177)
This expands `fromisoformat` to cover most of the common uses of ISO 8601. We may expand the scope more in the future.
2022-05-05 18:31:24 -06:00
Victor Stinner ada8b6d1b1
gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)
Add the -P command line option and the PYTHONSAFEPATH environment
variable to not prepend a potentially unsafe path to sys.path.

* Add sys.flags.safe_path flag.
* Add PyConfig.safe_path member.
* Programs/_bootstrap_python.c uses config.safe_path=0.
* Update subprocess._optim_args_from_interpreter_flags() to handle
  the -P command line option.
* Modules/getpath.py sets safe_path to 1 if a "._pth" file is
  present.
2022-05-06 01:34:11 +02:00
Gregory P. Smith f6dd14c653
gh-82616: Add process_group support to subprocess.Popen (#23930)
One more thing that can help prevent people from using `preexec_fn`.

Also adds conditional skips to two tests exposing ASAN flakiness on the Ubuntu 20.04 Address Sanitizer Github CI system. When that build is run on more modern systems the "problem" does not show up. It seems ASAN implementation related.

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-05 16:22:32 -07:00
Christian Heimes 8122e8d501
gh-92345: Import rlcompleter before sys.path is extended (#92346)
``pymain_run_python()`` now imports ``readline`` and ``rlcompleter``
before sys.path is extended to include the current working directory of
an interactive interpreter. Non-interactive interpreters are not
affected.

Also move imports of ``re`` and ``keyword`` module to top level so they
are materialized early, too. The ``keyword`` module is trivial and the
``re`` is already imported via ``inspect`` -> ``linecache``.
2022-05-05 21:24:16 +02:00
Alexey Izbyshev 58573ffba0
gh-92301: subprocess: Prefer close_range() to procfs-based fd closing (#92303)
#92301: subprocess: Prefer `close_range()` to procfs-based fd closing.

`close_range()` is much faster for large number of file descriptors, e.g.
4 times faster for 1000 descriptors in a Linux 5.16-based environment.

We prefer close_range() only if it's known to be async-signal-safe.
2022-05-05 09:46:19 -07:00
Soumendra Ganguly ae553b3561
bpo-41818: Add os.login_tty() for *nix. (#29658)
* Add `os.login_tty(fd)` for Unix.

Reviewed-by: Christian Heimes <christian@python.org>
Signed-off-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2022-05-05 09:04:44 -07:00
Mark Shannon f8a2fab212
GH-92239: Make sure that PEP 523 is supported, even when specializing first. (GH-92245) 2022-05-04 09:31:21 -06:00
Joshua Herman 000a072318
gh-92210: Move socket.__init__ to argument clinic (#92237)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-04 07:38:01 -06:00
Erlend Egeberg Aasland 090819ec5f
gh-89022: Improve sqlite3 exceptions related to binding params and API misuse (#91572)
* Map SQLITE_MISUSE to sqlite3.InterfaceError

SQLITE_MISUSE implies misuse of the SQLite C API, which, if it happens,
is _not_ a user error; it is an sqlite3 extension module error.

* Raise better errors when binding parameters fail.

Instead of always raising InterfaceError, guessing what went wrong,
raise accurate exceptions with more accurate error messages.
2022-05-04 07:16:01 -06:00
Victor Stinner d716a0dfe2
Use static inline function Py_EnterRecursiveCall() (#91988)
Currently, calling Py_EnterRecursiveCall() and
Py_LeaveRecursiveCall() may use a function call or a static inline
function call, depending if the internal pycore_ceval.h header file
is included or not. Use a different name for the static inline
function to ensure that the static inline function is always used in
Python internals for best performance. Similar approach than
PyThreadState_GET() (function call) and _PyThreadState_GET() (static
inline function).

* Rename _Py_EnterRecursiveCall() to _Py_EnterRecursiveCallTstate()
* Rename _Py_LeaveRecursiveCall() to _Py_LeaveRecursiveCallTstate()
* pycore_ceval.h: Rename Py_EnterRecursiveCall() to
  _Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() and
  _Py_LeaveRecursiveCall()
2022-05-04 13:30:23 +02:00
Victor Stinner 14243369b5
gh-92036: Fix gc_fini_untrack() (#92037)
Fix a crash in subinterpreters related to the garbage collector. When
a subinterpreter is deleted, untrack all objects tracked by its GC.
To prevent a crash in deallocator functions expecting objects to be
tracked by the GC, leak a strong reference to these objects on
purpose, so they are never deleted and their deallocator functions
are not called.
2022-05-04 11:59:01 +02:00
Erlend Egeberg Aasland f629dcfe83
gh-80254: Disallow recursive usage of cursors in `sqlite3` converters (#29054)
Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 17:03:06 -06:00
Kabir Kwatra 48c6165c28
gh-91928: Add `datetime.UTC` alias for `datetime.timezone.utc` (GH-91973)
### fixes #91928

`UTC` is now module attribute aliased to `datetime.timezone.utc`.
You can now do the following:
```python
from datetime import UTC
```
2022-05-03 15:14:25 -07:00
Erlend Egeberg Aasland 6b7dcc5607
gh-92206: Improve scoping of sqlite3 statement helper (#92260) 2022-05-03 16:07:11 -06:00
Erlend Egeberg Aasland d9ec553194
gh-89289: Fix compiler warning in _sqlite/connection.c (#92258) 2022-05-03 22:21:56 +02:00
Erlend Egeberg Aasland 3e6019cee5
gh-92206: Improve scoping of sqlite3 bind param functions (#92250) 2022-05-03 14:00:39 -06:00
Victor Stinner 804f2529d8
gh-91320: Use _PyCFunction_CAST() (#92251)
Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).

Change generated by the command:

sed -i -e \
  's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \
  $(find -name "*.c")
2022-05-03 21:42:14 +02:00