Commit graph

13815 commits

Author SHA1 Message Date
Donghee Na 7eeea13403
gh-112205: Support @getter annotation from AC (gh-112396) 2023-11-30 19:40:53 +09:00
Serhiy Storchaka e0449b9a7f
Add more C API tests (GH-112522)
Add tests for PyObject_Str(), PyObject_Repr(), PyObject_ASCII() and
PyObject_Bytes().
2023-11-29 17:37:05 +02:00
Grant Ramsay e413daf5f6
gh-112454: Disable TLS-PSK if OpenSSL was built without PSK support (#112491)
If OpenSSL was built without PSK support, the python TLS-PSK
methods will raise "NotImplementedError" if called.

Add a constant "ssl.HAS_PSK" to check if TLS-PSK is supported
2023-11-28 16:15:39 -08:00
Sergey B Kirpichev f14d741daa
gh-109802: Increase test coverage for complexobject.c (GH-112452) 2023-11-28 10:18:33 +02:00
Tian Gao 2df26d8348
gh-112105: Make completer delims work on libedit (gh-112106) 2023-11-28 06:23:23 +00:00
Radislav Chugunov ac4b44266d
gh-112071: Make _random.Random methods thread-safe in --disable-gil builds (gh-112128)
Co-authored-by: Donghee Na <donghee.na@python.org>
2023-11-28 03:27:39 +00:00
Anthony Shaw 154f099e61
gh-112292 : Catch import error conditions with readline hooks (gh-112313)
Prevents a segmentation fault in registered hooks for the readline library, but only when the readline module is loaded inside an isolated sub interpreter.  The module is single-phase init so loading it fails, but not until the module init function has already run, where the readline hooks get registered.

The readlinestate_global macro was error-prone to PyImport_FindModule returning NULL and crashing in about 18 places.  I could reproduce 1 easily, but this PR replaces the macro with a function and adds error conditions to the other functions.
2023-11-27 18:58:53 -07:00
kale-smoothie 967f2a3052
bpo-41422: Visit the Pickler's and Unpickler's memo in tp_traverse (GH-21664)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-11-27 18:09:41 +00:00
Serhiy Storchaka d8908932fc
gh-111789: Use PyDict_GetItemRef() in Modules/pyexpat.c (gh-112079) 2023-11-27 18:51:31 +01:00
Serhiy Storchaka ef9b2fc9b0
gh-111789: Use PyDict_GetItemRef() in Modules/_threadmodule.c (gh-112077) 2023-11-27 18:46:43 +01:00
Serhiy Storchaka 0f00903320
gh-111789: Use PyDict_GetItemRef() in Modules/_struct.c (gh-112076) 2023-11-27 18:41:47 +01:00
Serhiy Storchaka b14e5df120
gh-111789: Use PyDict_GetItemRef() in Modules/_csv.c (gh-112073) 2023-11-27 18:35:52 +01:00
Serhiy Storchaka 4eea1e8236
gh-112438: Fix support of format units with the "e" prefix in nested tuples in PyArg_Parse (gh-112439) 2023-11-27 18:32:55 +01:00
Grant Ramsay e954ac7205
gh-63284: Add support for TLS-PSK (pre-shared key) to the ssl module (#103181)
Add support for TLS-PSK (pre-shared key) to the ssl module.

---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-11-27 04:01:44 +00:00
Mark Dickinson 9fe60340d7
gh-112358: Fix Python 3.12 regression with subclassing struct.Struct. (#112424)
Revert commit c8c0afc713 (PR #94532),
which moved `struct.Struct` initialisation from `Struct.__init__` to `Struct.__new__`.
This caused issues with code in the wild that subclasses `struct.Struct`.
2023-11-26 14:29:52 +00:00
Eric Snow 9e56eedd01
gh-76785: Return an "excinfo" Object From Interpreter.run() (gh-111573) 2023-11-23 00:55:00 +00:00
Eric Snow 790db85c77
gh-76785: Add _PyType_GetModuleName() to the Internal C-API (gh-112323)
The new function corresponds to the existing (public) PyType_GetName() and PyType_GetQualName().
2023-11-22 15:03:33 -07:00
Mayuresh Kedari fef6fb8762
gh-111965: Use critical sections to make io.BufferedIOBase and its related classes thread safe (gh-112298) 2023-11-22 20:25:07 +09:00
Ned Deily fde8fe50e4
gh-59703: restore include of mach-o/dyld.h (gh-112309)
On older versions of macOS, _NSGetExecutablePath appears to only
be available via macho-o/dyld so macho-o/dyld.h is still needed.
2023-11-22 01:20:57 -05:00
Donghee Na 4fa376b005
gh-111863: Rename term Py_NOGIL to Py_GIL_DISABLED in sysconfig (gh-112307) 2023-11-22 10:32:43 +09:00
AN Long de2715f086
gh-59703: use the system dladdr function in getpath.c for macOS framework builds (GH-111546)
Co-authored-by: Ned Deily <nad@python.org>
2023-11-21 00:15:25 -05:00
Hugo van Kemenade 3b3ec0d77f
gh-111863: Rename Py_NOGIL to Py_GIL_DISABLED (#111864)
Rename Py_NOGIL to Py_GIL_DISABLED
2023-11-20 15:52:00 +02:00
AN Long 77d9f1e6d9
gh-111965: Using critical sections to make `io.StringIO` thread safe. (gh-112116) 2023-11-19 21:34:40 +09:00
Donghee Na 2bcc0f7d34
gh-112213: Update _weakref module to use new AC feature (gh-112250) 2023-11-19 10:43:51 +09:00
Donghee Na b8c952af72
gh-111903: Update AC to support "pycore_critical_section.h" header (gh-112251) 2023-11-19 10:13:58 +09:00
AN Long 1a969b4f55
gh-111965: Use critical sections to make io.TextIOWrapper thread safe (gh-112193) 2023-11-19 08:21:04 +09:00
Donghee Na 0566ab9c4d
gh-111926: Update _weakref to be threadsafe in --disable-gil build (gh-112189) 2023-11-18 16:09:23 +09:00
Wanderxjtu 0ee2d77331
gh-112070: make functools.lru_cache threadsafe in --disable-gil build (gh-112111)
* gh-112070: make `functools.lrucacle` threadsafe in --disable-gil build

* gh-112070: update generate `functoolsmodule` files

* gh-112070: add NEWS file

* Delete Misc/NEWS.d/next/Library/2023-11-15-20-19-45.gh-issue-112070.q6OhcU.rst

* gh-112070: reformat functoolsmodule.c

---------

Co-authored-by: Sam Gross <colesbury@gmail.com>
2023-11-17 14:03:02 +09:00
Victor Stinner ceefa0b079
gh-111482: Fix time_clockid_converter() on AIX (#112170)
clockid_t is defined as long long on AIX.
2023-11-17 00:00:16 +01:00
Sam Gross 446f18a911
gh-111956: Add thread-safe one-time initialization. (gh-111960) 2023-11-16 12:19:54 -07:00
Victor Stinner bd89bca9e2
gh-111798: Use lower Py_C_RECURSION_LIMIT in debug mode (#112124)
* Run again test_ast_recursion_limit() on WASI platform.
* Add _testinternalcapi.get_c_recursion_remaining().
* Fix test_ast and test_sys_settrace: test_ast_recursion_limit() and
  test_trace_unpack_long_sequence() now adjust the maximum recursion
  depth depending on the the remaining C recursion.
2023-11-16 13:52:33 +00:00
Tomas R a6465605c1
gh-111916: Make hashlib related modules thread-safe without the GIL (#111981)
Always use an individual lock on hash objects when in free-threaded builds.

Fixes #111916
2023-11-15 23:53:38 +00:00
Miro Hrončok ec05507367
gh-96954: Fix make regen-unicodedata in out-of-tree builds (#112118)
This avoids:

    python3.13 Tools/unicode/makeunicodedata.py
    python3.13: can't open file '.../build/debug/Tools/unicode/makeunicodedata.py': [Errno 2] No such file or directory
    make: *** [Makefile:1498: regen-unicodedata] Error 2

Re-run `make regen-unicodedata` to update the script path in generated files.
2023-11-15 16:42:17 +00:00
Serhiy Storchaka d4f83e1e3a
gh-111789: Use PyDict_GetItemRef() in Modules/_asynciomodule.c (GH-112072) 2023-11-15 04:28:30 +00:00
Radislav Chugunov 4744f59a5e
gh-112062: Make _struct module thread-safe in --disable-gil builds (#112094)
* gh-112062: Make `_struct` module thread-safe in --disable-gil builds
2023-11-15 09:30:34 +05:30
Victor Stinner 55f3cce821
gh-111545: Test PyHash_GetFuncDef() function (#112098)
Add Modules/_testcapi/hash.c and Lib/test/test_capi/test_hash.py.
2023-11-15 03:41:29 +01:00
adder32 fe9db901b2
gh-111995: Add getnameinfo extension flag (#111994)
Add getnameinfo extension NI_IDN flag.
2023-11-15 01:00:24 +00:00
Serhiy Storchaka 9302f05f9a
gh-111942: Fix SystemError in the TextIOWrapper constructor (#112061)
In non-debug more the check for the "errors" argument is skipped,
and then PyUnicode_AsUTF8() can fail, but its result was not checked.

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-11-14 20:02:28 +00:00
Serhiy Storchaka ee06fffd38
gh-111942: Fix crashes in TextIOWrapper.reconfigure() (GH-111976)
* Fix crash when encoding is not string or None.
* Fix crash when both line_buffering and write_through raise exception
  when converted ti int.
* Add a number of tests for constructor and reconfigure() method
  with invalid arguments.
2023-11-14 17:37:56 +02:00
Victor Stinner 4f04172c92
gh-111262: Add PyDict_Pop() function (#112028)
_PyDict_Pop_KnownHash(): remove the default value and the return type
becomes an int.

Co-authored-by: Stefan Behnel <stefan_ml@behnel.de>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2023-11-14 12:51:00 +00:00
Sam Gross 324531df90
gh-111903: Add @critical_section directive to Argument Clinic. (#111904)
The `@critical_section` directive instructs Argument Clinic to generate calls
to `Py_BEGIN_CRITICAL_SECTION()` and `Py_END_CRITICAL_SECTION()` around the
bound function. In `--disable-gil` builds, these calls will lock and unlock
the `self` object. They are no-ops in the default build.

This is used in one place (`_io._Buffered.close`) as a demonstration.
Subsequent PRs will use it more widely in the `_io.Buffered` bindings.
2023-11-14 10:47:46 +00:00
Serhiy Storchaka c98600bed4
gh-111789: Use PyDict_GetItemRef() in _ctypes (GH-111828) 2023-11-14 11:28:34 +02:00
Irit Katriel 36aab34fab
gh-107149: make new opcode util functions private rather than public and unstable (#112042) 2023-11-14 00:31:02 +00:00
Victor Stinner babb787047
gh-111138: Add PyList_Extend() and PyList_Clear() functions (#111862)
* Split list_extend() into two sub-functions: list_extend_fast() and
  list_extend_iter().
* list_inplace_concat() no longer has to call Py_DECREF() on the
  list_extend() result, since list_extend() now returns an int.
2023-11-13 16:14:56 +00:00
AN Long d0058cbd1c
gh-111928: make "memo" dict local to scan_once call (gh-112005)
Co-authored-by: Sam Gross <colesbury@gmail.com>
2023-11-13 04:58:34 +00:00
T. Wouters ce6a533c4b
gh-111777: Fix assertion errors on incorrectly still-tracked GC object destruction (#111778)
In PyObject_GC_Del, in Py_DEBUG mode, when warning about GC objects that
were not properly untracked before starting destruction, take care to
untrack the object _before_ warning, to avoid triggering a GC run and
causing the problem the code tries to warn about. Also make sure to save and
restore any pending exceptions, which the warning would otherwise clobber or
trigger an assertion error on.
2023-11-12 01:03:34 +01:00
T. Wouters 21615f77b5
Fix undefined behaviour in datetime.time.fromisoformat() (#111982)
Fix undefined behaviour in datetime.time.fromisoformat() when parsing a string without a timezone. 'tzoffset' is not assigned to by parse_isoformat_time if it returns 0, but time_fromisoformat then passes tzoffset to another function, which is undefined behaviour (even if the function in question does not use the value).
2023-11-12 00:56:27 +01:00
Serhiy Storchaka afac3c9b7e
gh-111789: Simplify the sqlite code (GH-111829)
Use new C API functions PyDict_GetItemRef() and
PyMapping_GetOptionalItemString().
2023-11-10 20:49:24 +00:00
Serhiy Storchaka 771bd3c94a
Add private _PyUnicode_AsUTF8NoNUL() function (GH-111957)
Like PyUnicode_AsUTF8(), but check for embedded null characters.
2023-11-10 21:31:36 +02:00
Serhiy Storchaka 0b06d2482d
gh-111841: Fix os.putenv() and os.unsetenv() with embedded NUL on Windows (GH-111842) 2023-11-10 18:42:14 +02:00