Commit Graph

13157 Commits

Author SHA1 Message Date
Shantanu a178ba82bf
gh-101326: Fix regression when passing None to FutureIter.throw (#101327) 2023-01-25 12:01:01 -08:00
Erlend E. Aasland fee7a995a1
gh-92123: Adapt _elementtree to multi-phase init (PEP 489) (#101285) 2023-01-24 17:00:24 +01:00
Erlend E. Aasland b2ac39626a
GH-92123: Pass _elementtree state as parameter (#101189) 2023-01-24 12:45:55 +01:00
ram vikram singh 7f95ec3e74
gh-101152: Implement PEP 699 (GH-101193)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Ken Jin <kenjin@python.org>
2023-01-24 17:29:22 +08:00
Gregory P. Smith b724ac2fe7
gh-100795: Don't call freeaddrinfo on failure. (#101252)
When getaddrinfo returns an error, the output pointer is in an unknown state
Don't call freeaddrinfo on it.  See the issue for discussion and details with
links to reasoning.  _Most_ libc getaddrinfo implementations never modify the
output pointer unless they are returning success.

Co-authored-by: Sergey G. Brester <github@sebres.de>
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
2023-01-23 15:03:26 -08:00
Erlend E. Aasland 984387f39a
GH-92123: Store _elementtree state in type contexts (#101190)
- add state pointer to TreeBuilderObject
- add state pointer to XMLParserObject
2023-01-23 13:20:36 +01:00
Jacob Walls d717be04dc
gh-83122: Deprecate testing element truth values in `ElementTree` (#31149)
When testing element truth values, emit a DeprecationWarning in all implementations.

This had emitted a FutureWarning in the rarely used python-only implementation since ~2.7 and has always been documented as a behavior not to rely on.

Matching an element in a tree search but having it test False can be unexpected. Raising the warning enables making the choice to finally raise an exception for this ambiguous behavior in the future.
2023-01-22 17:16:48 -08:00
Raymond Hettinger 997073c28b
Sumprod(): Update citation. Reorder functions. Add final twosum() call. Improve comments. (#101249) 2023-01-22 17:07:52 -06:00
Kumar Aditya b53bad6dd0
Revert "gh-100795: avoid unexpected `freeaddrinfo` after failed `getaddrinfo` (#101220)" (#101238)
Revert "gh-100795: avoid unexpected `freeaddrinfo` after failed `getaddrinfo` (#101220)"

This reverts commit 5f08fe4a2c.
2023-01-22 14:17:01 +05:30
Sergey G. Brester 5f08fe4a2c
gh-100795: avoid unexpected `freeaddrinfo` after failed `getaddrinfo` (#101220)
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
2023-01-22 13:40:00 +05:30
Kamil Turek b4e11a7985
gh-99266: ctypes: Preserve more detailed exception in `ArgumentError`
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-01-21 19:14:43 +05:30
Erlend E. Aasland 13566a37c2
GH-92123: Move _elementtree heap types to module state (#101187) 2023-01-21 12:01:15 +01:00
Erlend E. Aasland 3847a6c64b
gh-92123: Convert `_elementtree` types to heap types (#99221) 2023-01-20 12:40:06 +01:00
Erlend E. Aasland 9109d46051
GH-90699: Clear interned strings in `_elementtree` (#101185) 2023-01-20 16:34:14 +05:30
Eric Snow 6036c3e856
gh-59956: Clarify GILState-related Code (gh-101161)
The objective of this change is to help make the GILState-related code easier to understand.  This mostly involves moving code around and some semantically equivalent refactors.  However, there are a also a small number of slight changes in structure and behavior:

* tstate_current is moved out of _PyRuntimeState.gilstate
* autoTSSkey is moved out of _PyRuntimeState.gilstate
* autoTSSkey is initialized earlier
* autoTSSkey is re-initialized (after fork) earlier

https://github.com/python/cpython/issues/59956
2023-01-19 16:04:14 -07:00
Paul Moore f34176b77f
gh-82052: Don't send partial UTF-8 sequences to the Windows API (GH-101103)
Don't send partial UTF-8 sequences to the Windows API
2023-01-17 19:23:06 +00:00
Steve Dower df10571a13
gh-100320: Fix path calculations on Windows when python.exe is moved outside of the normal location (GH-100947) 2023-01-16 16:05:39 +00:00
Kumar Aditya 74c20b6ece
GH-100997: fix refleak in `_testinternalcapi.c` (#101058) 2023-01-16 16:11:57 +05:30
Cristián Maureira-Fredes 5e9df888dd
Fix `ctypes` typo in `set_exception` (#101040) 2023-01-15 20:42:37 +05:30
Kumar Aditya f6307d4416
GH-100892: consolidate `HEAD_LOCK/HEAD_UNLOCK` macros (#100953) 2023-01-15 20:39:26 +05:30
Oleg Iarygin 124af17b6e
gh-94518: [_posixsubprocess] Replace variable validity flags with reserved values (#94687)
Have _posixsubprocess.c stop using boolean flags to say if gid and uid values were supplied and action is required.  Such an implicit "either initialized or look somewhere else" confused both the reader (another mental connection to constantly track between functions) and a compiler (warnings on potentially uninitialized variables being passed). Instead, we can utilize a special group/user id as a flag value -1 defined by POSIX but used nowhere else. Namely:

gid: call_setgid = False → gid = -1

uid: call_setuid = False → uid = -1

groups: call_setgroups = False → groups = NULL (obtained with (groups_list != Py_None) ? groups : NULL)

This PR is required for #94519.
2023-01-14 12:11:04 -08:00
Eric Snow b511d3512b
GH-100997: Implement Multi-Phase Init for the _testinternalcapi Module (gh-100998)
_testinternalcapi is an internal module used for testing.

https://github.com/python/cpython/issues/100997
2023-01-12 13:42:03 -07:00
Kumar Aditya 762745a124
GH-100892: Fix race in clearing `threading.local` (#100922) 2023-01-11 16:03:31 +05:30
Brandt Bucher 61762b9387
GH-100126: Skip incomplete frames in more places (GH-100613) 2023-01-09 12:20:04 -08:00
Nikita Sobolev 36f2329367
gh-100873: Fix "‘lo’ may be used uninitialized in this function" warning in `mathmodule.c` (#100881) 2023-01-09 21:21:24 +05:30
dgelessus 837ba05267
GH-81061: Fix refcount issue when returning `None` from a `ctypes.py_object` callback (#13364) 2023-01-09 15:43:04 +05:30
dsentinel 7a50d6b5b0
GH-100813: Add `socket.IP_PKTINFO` constant (#10294) 2023-01-09 14:30:40 +05:30
Mark Dickinson 87d3bd0e02
gh-100833: Remove 'volatile' qualifiers in fsum algorithm (#100845)
This PR removes the `volatile` qualifier on various intermediate quantities
in the `math.fsum` implementation, and updates the notes preceding the
algorithm accordingly (as well as fixing some of the exsting notes). See
the linked issue #100833 for discussion.
2023-01-08 19:40:15 +00:00
Raymond Hettinger b139bcd892
GH-100485: Tweaks to sumprod() (GH-100857) 2023-01-08 13:38:24 -06:00
Nikita Sobolev b034fd3e59
gh-100689: Revert "bpo-41798: pyexpat: Allocate the expat_CAPI on the heap memory (GH-24061)" (#100745)
* gh-100689: Revert "bpo-41798: pyexpat: Allocate the expat_CAPI on the heap memory (GH-24061)"

This reverts commit 7c83eaa536.
2023-01-08 18:24:40 +05:30
Raymond Hettinger df3851fe4a
GH-100485: Convert from Fast2Sum to 2Sum (GH-100836) 2023-01-07 21:37:08 -06:00
Raymond Hettinger 47b9f83a83
GH-100485: Add math.sumprod() (GH-100677) 2023-01-07 12:46:35 -06:00
Gabriele N. Tornetta d52d4942cf
gh-100649: Update native_thread_id after fork (gh-100650)
Update native_thread_id after fork
2023-01-01 23:20:38 +09:00
Gregory P. Smith 894f2c3c16
gh-100228: Warn from os.fork() if other threads exist. (#100229)
Not comprehensive, best effort warning. There are cases when threads exist on some platforms that this code cannot detect. macOS when API permissions allow and Linux with a readable /proc procfs present are the currently supported cases where a warning should show up reliably.

Starting with a DeprecationWarning for now, it is less disruptive than something like RuntimeWarning and most likely to only be seen in people's CI tests - a good place to start with this messaging.
2022-12-29 14:41:39 -08:00
Zachary Ware 2df82db485
gh-100540: Remove obsolete Modules/_ctypes/darwin/ dlfcn shim (GH-100541)
As far as I can tell, this hasn't been actually used since Mac OS X 10.2.
2022-12-29 16:13:28 -06:00
Zachary Ware 025b5c3780
gh-100540: Remove unused Modules/_ctypes/libffi_osx/ (GH-100543)
It was an ancient, modified copy of libffi that has not been in use
since GH-22855.
2022-12-28 13:38:52 -06:00
Zachary Ware fd4b55ff17
gh-100540: Remove unnecessary '-DMACOSX' for ctypes on macOS (GH-100542)
The define was only used to protect a `#pragma clang diagnostic`
setting, which is already better guarded by `__clang__` anwyay.
2022-12-28 12:06:58 -06:00
Kumar Aditya 7cf164ad5e
GH-100342: check for allocation failure in AC `*args` parsing (#100343) 2022-12-28 09:46:28 +05:30
Bill Fisher 88d565f32a
gh-99110: Initialize `frame->previous` in init_frame to fix segmentation fault when accessing `frame.f_back` (#100182) 2022-12-23 20:15:53 +05:30
Eric Wieser 84bc6a4f25
gh-76963: PEP3118 itemsize of an empty ctypes array should not be 0 (GH-5576)
The itemsize returned in a memoryview of a ctypes array is now computed from the item type, instead of dividing the total size by the length and assuming that the length is not zero.
2022-12-23 08:23:19 +00:00
Itamar Ostricher 4cc63e0d4e
gh-100344: Add C implementation for `asyncio.current_task` (#100345)
Co-authored-by: pranavtbhat
2022-12-22 19:08:12 +05:30
amaajemyfren bbf4a66a18
GH-69564: Clarify use of octal format of mode argument in help(os.chmod) (#20621)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-12-21 23:18:25 +05:30
Hai Shi d713c54ac8
gh-78878: Fix crash when creating an instance of `_ctypes.CField` (#14837) 2022-12-21 23:01:17 +05:30
Kumar Aditya 4994f2488f
GH-100363: Speed up `asyncio.get_running_loop` (#100364) 2022-12-21 15:19:44 +05:30
František Nesveda d98ca8172c
gh-99925: Fix inconsistency in `json.dumps()` error messages (GH-99926) 2022-12-20 12:54:56 +02:00
Thomas Grainger 79ccc03b62
gh-89051: Add ssl.OP_LEGACY_SERVER_CONNECT (#93927)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Fixes https://github.com/python/cpython/issues/89051
2022-12-20 09:10:30 +02:00
Serhiy Storchaka 0fe61d0838
gh-100272: Fix JSON serialization of OrderedDict (GH-100273)
It now preserves the order of keys.
2022-12-17 14:32:48 +02:00
Erlend E. Aasland 2b38a9aa74
gh-93649: Split tracemalloc tests from _testcapimodule.c (#99551) 2022-12-17 09:53:36 +01:00
colorfulappl efbb1eb9f5
gh-99240: Reset pointer to NULL when the pointed memory is freed in argument parsing (#99890)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-12-17 12:07:44 +05:30
Itamar Ostricher ae83c78215
GH-100000: Cleanup and polish various watchers code (GH-99998)
* Initialize `type_watchers` array to `NULL`s
* Optimize code watchers notification
* Optimize func watchers notification
2022-12-14 19:14:16 +00:00
Eric Snow 5eb28bca9f
gh-81057: Move Signal-Related Globals to _PyRuntimeState (gh-100085)
https://github.com/python/cpython/issues/81057
2022-12-12 16:50:19 -07:00
Eric Snow 53d9cd95cd
gh-81057: Move faulthandler Globals to _PyRuntimeState (gh-100152)
https://github.com/python/cpython/issues/81057
2022-12-12 09:58:46 -07:00
Eric Snow 8790d4d31f
gh-81057: Move tracemalloc Globals to _PyRuntimeState (gh-100151)
https://github.com/python/cpython/issues/81057
2022-12-12 08:44:23 -07:00
Eric Snow 7a0f3c1d92
gh-81057: Fix a Reference Leak in the posix Module (gh-100140)
The leak was introduced in gh-100082.

https://github.com/python/cpython/issues/81057
2022-12-09 10:18:29 -07:00
Raymond Hettinger 8c215466db
GH-98363: Shrink the physical size as well as the logical size (GH-100138) 2022-12-09 11:02:35 -06:00
Eric Snow 3e06b5030b
gh-81057: Fix an ifdef in the time module (#100125)
An earlier commit only defined check_ticks_per_second() when HAVE_TIMES is defined. However, we also need it when HAVE_CLOCK is defined. This primarily affects Windows.

https://github.com/python/cpython/issues/81057
2022-12-08 18:16:37 -07:00
Eric Snow 8a3f06c54b
gh-81057: Move time Globals to _PyRuntimeState (gh-100122)
https://github.com/python/cpython/issues/81057
2022-12-08 16:46:09 -07:00
Eric Snow cda9f0236f
gh-81057: Move OS-Related Globals to _PyRuntimeState (gh-100082)
https://github.com/python/cpython/issues/81057
2022-12-08 15:38:06 -07:00
Raymond Hettinger 35cc0ea736
GH-98363: Have batched() return tuples (GH-100118) 2022-12-08 15:08:16 -06:00
Matthieu Baerts cce8362960
gh-98030: socket: add missing TCP socket options (#98031)
A few TCP socket options have been added to the Linux kernel these last
few years.

This commit adds all the ones available in Linux 6.0:

  https://elixir.bootlin.com/linux/v6.0/source/include/uapi/linux/tcp.h#L91

While at it, the TCP_FASTOPEN option has been moved lower in the list
just to keep the same order as in tcp.h to ease future synchronisations.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
2022-12-07 20:59:37 -08:00
Eric Snow 91a8e002c2
gh-81057: Move More Globals to _PyRuntimeState (gh-100092)
https://github.com/python/cpython/issues/81057
2022-12-07 15:56:31 -07:00
Victor Stinner b11a384dc7
gh-98724: Fix Py_CLEAR() macro side effects (#99100) (#100070)
The Py_CLEAR(), Py_SETREF() and Py_XSETREF() macros now only evaluate
their arguments once. If an argument has side effects, these side
effects are no longer duplicated.

Use temporary variables to avoid duplicating side effects of macro
arguments. If available, use _Py_TYPEOF() to avoid type punning.
Otherwise, use memcpy() for the assignment to prevent a
miscompilation with strict aliasing caused by type punning.

Add _Py_TYPEOF() macro: __typeof__() on GCC and clang.

Add test_py_clear() and test_py_setref() unit tests to _testcapi.
2022-12-07 15:22:38 +01:00
Serhiy Storchaka fd38a2f0ec
gh-93453: No longer create an event loop in get_event_loop() (#98440)
asyncio.get_event_loop() now always return either running event loop or
the result of get_event_loop_policy().get_event_loop() call. The latter
should now raise an RuntimeError if no current event loop was set
instead of creating and setting a new event loop.

It affects also a number of asyncio functions and constructors which
call get_event_loop() implicitly: ensure_future(), shield(), gather(),
etc.

DeprecationWarning is no longer emitted if there is no running event loop but
the current event loop was set.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-12-06 18:42:12 +01:00
Eric Snow e9e63ad865
gh-99984: Fix Compiler Warnings (#100036)
https://github.com/python/cpython/issues/99984
2022-12-05 14:41:06 -07:00
Eric Snow 530cc9dbb6
gh-99741: Implement Multi-Phase Init for the _xxsubinterpreters Module (gh-99742)
_xxsubinterpreters is an internal module used for testing.

https://github.com/python/cpython/issues/99741
2022-12-05 13:40:20 -07:00
Serhiy Storchaka 922a6cf6c2
gh-60203: Revert changes in cycle.__setstate__ (#99982)
In case if only True/False be supported as boolean arguments in future,
we should continue to support 1/0 here.
2022-12-05 17:27:40 +01:00
Felix Ye 854a878e4f
gh-98248: Normalizing the error messages in function struct.pack (GH-98252)
Provide consistent and informative error messages in function struct.pack when its integral arguments are not in range.
2022-12-04 20:24:18 +00:00
Itamar Ostricher 1012dc1b43
GH-91054: Reset static events counts in code watchers tests (#99978) 2022-12-04 12:38:21 +00:00
Serhiy Storchaka a87c46eab3
bpo-15999: Accept arbitrary values for boolean parameters. (#15609)
builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.
2022-12-03 11:52:21 -08:00
Eric Snow 0547a981ae
gh-99741: Clean Up the _xxsubinterpreters Module (gh-99940)
This cleanup up resolves a few subtle bugs and makes the implementation for multi-phase init much cleaner.

https://github.com/python/cpython/issues/99741
2022-12-02 11:36:57 -07:00
Itamar Ostricher 3c137dc613
GH-91054: Add code object watchers API (GH-99859)
* Add API to allow extensions to set callback function on creation and destruction of PyCodeObject

Co-authored-by: Ye11ow-Flash <janshah@cs.stonybrook.edu>
2022-12-02 17:28:27 +00:00
Serhiy Storchaka f08e52ccb0
gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (GH-99613)
Previously *consumed was not set in this case.
2022-12-01 14:54:51 +02:00
Victor Stinner 85dd6cb6df
gh-99845: Use size_t type in __sizeof__() methods (#99846)
The implementation of __sizeof__() methods using _PyObject_SIZE() now
use an unsigned type (size_t) to compute the size, rather than a signed
type (Py_ssize_t).

Cast explicitly signed (Py_ssize_t) values to unsigned type
(Py_ssize_t).
2022-11-30 17:22:52 +01:00
Dong-hee Na 8bb2303fd7
gh-99127: Allow some features of syslog to the main interpreter only (gh-99128) 2022-11-30 07:58:20 +09:00
Victor Stinner 74d5f61ebd
gh-99845: Clean up _PyObject_VAR_SIZE() usage (#99847)
* code_sizeof() now uses an unsigned type (size_t) to compute the result.
* Fix _PyObject_ComputedDictPointer(): cast _PyObject_VAR_SIZE() to
  Py_ssize_t, rather than long: it's a different type on 64-bit Windows.
* Clarify that _PyObject_VAR_SIZE() uses an unsigned type (size_t).
2022-11-29 12:15:21 +01:00
Kumar Aditya 4cfc1b8568
GH-91375: Port `_asyncio` static types to heap types and module state (#99122)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-11-29 15:37:37 +05:30
Serhiy Storchaka deaa8dee48
gh-99593: Add tests for Unicode C API (part 1) (GH-99651)
Add tests for functions corresponding to the str class methods.
2022-11-29 09:59:56 +02:00
Zackery Spytz 53eef27133
bpo-31718: Fix io.IncrementalNewlineDecoder SystemErrors and segfaults (#18640)
Co-authored-by: Oren Milman <orenmn@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-11-28 16:16:40 +05:30
TheShermanTanker ec2b76aa8b
GH-95896: posixmodule.c: fix osdefs.h inclusion to not depend on compiler (#95897)
Co-authored-by: Steve Dower <steve.dower@python.org>
2022-11-26 15:01:42 +05:30
Victor Stinner 5556d3e02c
gh-98724: Fix warnings on Py_SETREF() usage (#99781)
Cast argument to the expected type.
2022-11-26 00:30:37 +01:00
Zackery Spytz 85c128e34d
bpo-40882: Fix a memory leak in SharedMemory on Windows (GH-20684)
In multiprocessing.shared_memory.SharedMemory(), the temporary view
returned by MapViewOfFile() should be unmapped when it is no longer
needed.
2022-11-25 17:39:48 +00:00
Zackery Spytz d386115039
bpo-38031: Fix a possible assertion failure in _io.FileIO() (#GH-5688) 2022-11-25 12:55:26 +00:00
Victor Stinner 3a803bcaac
Revert "gh-98724: Fix Py_CLEAR() macro side effects" (#99737)
Revert "gh-98724: Fix Py_CLEAR() macro side effects (#99100)"

This reverts commit c03e05c2e7.
2022-11-24 22:17:33 +01:00
colorfulappl 0da728387c
gh-64490: Fix bugs in argument clinic varargs processing (#32092) 2022-11-24 20:56:50 +01:00
colorfulappl 8dbe08eb7c
gh-99240: Fix double-free bug in Argument Clinic str_converter generated code (GH-99241)
Fix double-free bug mentioned at https://github.com/python/cpython/issues/99240,
by moving memory clean up out of "exit" label.

Automerge-Triggered-By: GH:erlend-aasland
2022-11-24 06:01:26 -08:00
colorfulappl 69f6cc77d0
gh-64490: Fix refcount error when arguments are packed to tuple in argument clinic (#99233) 2022-11-24 17:54:18 +05:30
Illia Volochii 9dc08361be
gh-96828: Add an `ssl.OP_ENABLE_KTLS` option (GH-96830)
Expose the constant when OpenSSL defines it.
2022-11-23 18:24:09 -08:00
Victor Stinner 81f7359f67
gh-99537: Use Py_SETREF(var, NULL) in C code (#99687)
Replace "Py_DECREF(var); var = NULL;" with "Py_SETREF(var, NULL);".
2022-11-23 14:57:50 +01:00
Victor Stinner f1a4a6a587
gh-99300: Replace Py_INCREF() with Py_NewRef() in _elementtree.c (#99696)
* Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef()
  and Py_XNewRef() in Modules/_elementtree.c.
* Make reference counting more explicit: don't steal implicitly a
  reference on PyList_SET_ITEM(), use Py_NewRef() instead.
* Replace PyModule_AddObject() with PyModule_AddObjectRef().
2022-11-22 22:17:06 +01:00
Charles Machalow 1b2de89bce
gh-99547: Add isjunction methods for checking if a path is a junction (GH-99548) 2022-11-22 17:19:34 +00:00
Victor Stinner 9a91182d4a
gh-99537: Use Py_CLEAR() function in C code (#99686)
Replace "Py_XDECREF(var); var = NULL;" with "Py_CLEAR(var);".

Don't replace "Py_DECREF(var); var = NULL;" with "Py_CLEAR(var);". It
would add an useless "if (var)" test in code path where var cannot be
NULL.
2022-11-22 15:22:55 +01:00
Victor Stinner 7e3f09cad9
gh-99537: Use Py_SETREF() function in C code (#99656)
Fix potential race condition in code patterns:

* Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);"
* Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);"
* Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);"

Other changes:

* Replace "old = var; var = new; Py_DECREF(var)"
  with "Py_SETREF(var, new);"
* Replace "old = var; var = new; Py_XDECREF(var)"
  with "Py_XSETREF(var, new);"
* And remove the "old" variable.
2022-11-22 14:22:22 +01:00
mpage 3db0a21f73
gh-91053: Add an optional callback that is invoked whenever a function is modified (#98175) 2022-11-22 13:06:44 +01:00
Victor Stinner 20d9749a0f
gh-99537: Use Py_SETREF() function in longobject C code (#99655)
Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);"
in longobject.c and _testcapi/long.c.
2022-11-22 13:04:19 +01:00
Ronald Oussoren 959ba45d75
GH-97001: Release GIL in termios extension (#99503)
Without releasing the GIL calls to termios APIs might block the entire interpreter.
2022-11-22 11:14:23 +01:00
Petr Viktorin 4d82f628c4
gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h (GH-99014)
The ``structmember.h`` header is deprecated, though it continues to be available
and there are no plans to remove it. There are no deprecation warnings. Old code
can stay unchanged (unless the extra include and non-namespaced macros bother
you greatly). Specifically, no uses in CPython are updated -- that would just be
unnecessary churn.
The ``structmember.h`` header is deprecated, though it continues to be
available and there are no plans to remove it.

Its contents are now available just by including ``Python.h``,
with a ``Py`` prefix added if it was missing:

- `PyMemberDef`, `PyMember_GetOne` and`PyMember_SetOne`
- Type macros like `Py_T_INT`, `Py_T_DOUBLE`, etc.
  (previously ``T_INT``, ``T_DOUBLE``, etc.)
- The flags `Py_READONLY` (previously ``READONLY``) and
  `Py_AUDIT_READ` (previously all uppercase)

Several items are not exposed from ``Python.h``:

- `T_OBJECT` (use `Py_T_OBJECT_EX`)
- `T_NONE` (previously undocumented, and pretty quirky)
- The macro ``WRITE_RESTRICTED`` which does nothing.
- The macros ``RESTRICTED`` and ``READ_RESTRICTED``, equivalents of
  `Py_AUDIT_READ`.
- In some configurations, ``<stddef.h>`` is not included from ``Python.h``.
  It should be included manually when using ``offsetof()``.

The deprecated header continues to provide its original
contents under the original names.
Your old code can stay unchanged, unless the extra include and non-namespaced
macros bother you greatly.

There is discussion on the issue to rename `T_PYSSIZET` to `PY_T_SSIZE` or
similar. I chose not to do that -- users will probably copy/paste that with any
spelling, and not renaming it makes migration docs simpler.


Co-Authored-By: Alexander Belopolsky <abalkin@users.noreply.github.com>
Co-Authored-By: Matthias Braun <MatzeB@users.noreply.github.com>
2022-11-22 08:25:43 +01:00
colorfulappl c450c8c9ed
gh-96002: Add functional test for Argument Clinic (#96178)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-11-21 15:08:45 +01:00
Ronald Oussoren cdde29dde9
gh-99337: Fix compile errors with gcc 12 on macOS (#99470)
Fix a number of compile errors with GCC-12 on macOS:

1. In pylifecycle.c the compile rejects _Pragma within a declaration
2. posixmodule.c was missing a number of ..._RUNTIME macros for non-clang on macOS
3. _ctypes assumed that __builtin_available is always present on macOS
2022-11-21 10:50:20 +01:00
Nikita Sobolev a3360facba
gh-99284: [ctypes] remove `_use_broken_old_ctypes_structure_semantics_` (GH-99285)
It was untested and undocumented. No code has been found in the wild that ever used it.
2022-11-18 22:25:32 -08:00
Erlend E. Aasland 12b5a3c5f5
gh-93649: Split float/long tests from _testcapimodule.c (GH-99549)
Automerge-Triggered-By: GH:erlend-aasland
2022-11-17 00:56:56 -08:00