877 Commits
Author SHA1 Message Date
Inada NaokiandEmma Smith b26fc41b5c Remove obsolete and unused configure macros (#159513)
Co-authored-by: Emma Smith <emma@emmatyping.dev>
2026-10-25 05:18:16 +00:00
Inada Naoki 94d16d2e13 gh-89977: Keep the GIL for short socket calls (#157981) 2026-10-24 20:51:24 +09:00
Stan Ulbrych a930e524cb Fix unchecked NULL returns in several C modules (#160213) 2026-10-22 15:55:09 +00:00
Lazizbek Ergashev 03a3f3d30c fixes gh-159561: Remove redundant type check in AF_VSOCK setsockopt() (#159610) 2026-10-18 04:12:51 +00:00
Stan UlbrychandVictor Stinner b93fb19a6e Run a job that the test suite with MSan to the CI (#158625)
* Run the test suite with MSan in CI

* Additional fixes

* Add `_Py_MSAN_UNPOISON_STRING`

* Apply Victor's suggestions

Co-authored-by: Victor Stinner <victor.stinner@gmail.com>

* Apply Victor's suggestions

Co-authored-by: Victor Stinner <victor.stinner@gmail.com>

---------

Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
2026-10-05 02:11:42 +01:00
thexai 77dd973815 gh-152433: Windows: allow build socketmodule for UWP (#152601) 2026-09-11 08:14:40 +02:00
adea841add gh-152936: Make privileged functions available on Android (#152977)
Expose the chroot, initgroups, setegid, seteuid, setgid, sethostname, setregid,
setresgid, setresuid, setreuid, and setuid functions on Android. Previously, 
these methods were excluded by an autoconf guard; they're now included with
a permission check to prevent issues invoking them as a non-root user.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Malcolm Smith <smith@chaquo.com>
2026-09-08 15:09:19 +08:00
cb54488523 gh-156439: Gate socket.if_{nametoindex, indextoname} on respective OS capability (#156708)
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Malcolm Smith <smith@chaquo.com>
2026-09-03 20:49:40 +01:00
stevens e5556cdf71 gh-155621: Fix unrepresentable defaults in socket.sendmsg() signature (#155623) 2026-08-14 15:33:42 +00:00
Victor Stinner 079dd5ee39 gh-155742: Get PyBytes_AS_STRING() as const char* (#155751)
Use "const char*" type instead of "char*" to store
PyBytes_AS_STRING(): treat bytes objects as immutable.
2026-08-14 12:00:45 +00:00
Serhiy Storchaka 9f87800220 gh-135748: Use Argument Clinic for more socket functions (GH-155257)
Convert all convertible functions and methods of the socket module.
They now have signatures for introspection, and functions which take
several arguments use METH_FASTCALL instead of METH_VARARGS.

ioctl(), sendto() and setsockopt() are left as they are.  Their
behaviour depends on the number of the arguments or on the value of a
preceding argument, which Argument Clinic cannot express.
2026-08-13 16:24:59 +03:00
Jakub Kulík 5181a6eca5 gh-155336: Preserve resolver errors from gethostby*_r() (GH-155337) 2026-08-10 07:34:51 +00:00
Serhiy StorchakaandClaude Fable 5 5afbb60e02 gh-93251: Decode localized socket error messages from the locale encoding (GH-154683)
The gai_strerror() and hstrerror() messages were decoded as UTF-8, so
gaierror and herror could be replaced with UnicodeDecodeError if the
message is localized and the locale encoding is not UTF-8.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-26 12:31:26 +03:00
Thomas Kowalski 4f3be1b577 gh-150452: use PyMutex in socket module (#150453) 2026-07-15 10:39:28 +00:00
sobolevn a9fa856014 gh-151126: Sets missing exceptions in tkinter and socket modules initializations (#152418) 2026-06-27 18:00:34 +03:00
tonghuaroot (童话)andtonghuaroot 896f7fdc7d gh-143988: Fix re-entrant mutation crashes in socket sendmsg/recvmsg_into (#143987)
Fix crashes in socket.sendmsg() and socket.recvmsg_into() that could
occur if buffer sequences are mutated re-entrantly during argument
parsing via __buffer__ protocol callbacks.

The bug occurs because:

1. PySequence_Fast() returns the original list object when the input
   is already a list (not a copy).
2. During iteration, PyObject_GetBuffer() triggers __buffer__
   callbacks which may clear the list.
3. Subsequent iterations access invalid memory (heap OOB read).

The fix replaces PySequence_Fast() with PySequence_Tuple() which
always creates a new tuple, ensuring the sequence cannot be mutated
during iteration.

Co-authored-by: tonghuaroot <23011166+tonghuaroot@users.noreply.github.com>
2026-06-10 13:03:49 +00:00
Thomas Kowalski 1e18c45495 gh-150406: Check result of PyThread_allocate_lock() for netdb_lock (GH-150407) 2026-05-30 16:25:40 +00:00
Serhiy Storchaka 287c98f4cb gh-150285: Fix too long docstrings in Argument Clinic code (GH-150338) 2026-05-24 16:16:12 +03:00
Victor Stinner a7ed0c9e1d gh-149879: Fix test_socket on Cygwin (#149913)
Disable SCM_RIGHTS, recvmsg(), sendmsg() and sethostname() on Cygwin.
2026-05-16 10:02:19 +00:00
f4a726da40 GH-135357: Add socket.SO_PASSRIGHTS constant (#135355)
Constant added to Linux 6.16. See the LWN article:
https://lwn.net/Articles/1023085/

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2026-04-27 13:12:34 +00:00
Sergey MiryanovandVictor Stinner c1b20a6d96 GH-145247: Use _PyTuple_FromPair in Modules (part 2) (#148003)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-04-02 23:24:03 +02:00
sunmy2019 1c396e1821 gh-146615: Fix format specifiers in extension modules (GH-146617) 2026-03-31 10:57:37 +03:00
Serhiy Storchaka 17070f41d4 gh-144837: Improve documentation for more collection methods (GH-144841)
Use uniform standard signature syntax in the tutorial and in
the array and collections modules documentation.
2026-03-26 21:29:23 +02:00
Karolina SurmaandVictor Stinner 1887a95f51 gh-128341: Use _Py_ABI_SLOT in stdlib modules (#145770)
Rename from _Py_INTERNAL_ABI_SLOT to _Py_ABI_SLOT
and define the macro using _PyABIInfo_DEFAULT.

Use the ABI slot in stdlib extension modules to enable running
a check of ABI version compatibility.

_tkinter, _tracemalloc and readline don't use the slots, hence they need
explicit handling.

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-24 17:47:55 +00:00
Petr ViktorinandVictor Stinner 91cd2e5806 gh-146175: Soft-deprecate outdated macros; convert internal usage (GH-146178)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-23 12:42:09 +01:00
AN Long c30fae4bea gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248) 2026-03-22 13:29:34 +02:00
82b92e3cd1 gh-143637: Fix re-entrant mutation of ancillary data in socket.sendmsg() (#143892)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-02-13 16:35:08 +01:00
Gleb Smirnoff 05406b221d gh-142991: socketmodule: fixed getsockaddrlen() for PF_DIVERT socket (#142993) 2026-01-06 17:25:29 +01:00
f21ed37daf gh-141817: Add IPV6_HDRINCL constant to the socket module (#141818)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-11-22 18:07:21 +01:00
Bénédikt Tran 3ce2d57b2f gh-100218: correctly set errno when socket.if_{nametoindex,indextoname} raise OSError (#140905)
Previously, socket.if_nametoindex() and socket.if_indextoname() could raise
an `OSError` with a `None` errno. Now, the errno from libc is propagated.
2025-11-09 13:45:38 +01:00
Bénédikt Tran b04a57deef gh-139748: fix leaks in AC error paths when using unicode FS-based converters (#139765) 2025-10-08 20:52:44 +05:30
Victor Stinner c4e7d245d6 gh-138342: Move _PyObject_VisitType() to the internal C API (#139734) 2025-10-08 12:10:58 +02:00
Serhiy Storchaka 1a2e00c97a gh-67795: Accept any real numbers as timestamp and timeout (GH-139224)
Functions that take timestamp or timeout arguments now accept any
real numbers (such as Decimal and Fraction), not only integers or floats,
although this does not improve precision.
2025-09-23 21:31:42 +03:00
Victor Stinner 47485c0384 gh-129813, PEP 782: Fix refleak in sock_recvfrom() (GH-139151) 2025-09-19 09:30:11 +00:00
Victor Stinner d641c41c88 gh-129813, PEP 782: Use PyBytesWriter in socket recvmsg() (#139131)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-18 17:57:04 +02:00
Victor Stinner 4263bc3b3b gh-129813, PEP 782: Use PyBytesWriter in _socket (#139097)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-18 11:20:56 +02:00
Stefan TatschnerandPatrick Menschel a9b6b09141 gh-86819: Add ISO-TP CAN socket constants (#23794)
Co-authored-by: Stefan Tatschner <stefan@rumpelsepp.org>
Co-authored-by: Patrick Menschel <menschel.p@posteo.de>
2025-09-17 17:18:04 +00:00
Victor Stinner bb743b684b gh-129813, PEP 782: Use PyBytesWriter in socket and mmap (#138831)
Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
2025-09-13 18:31:26 +02:00
Peter Bierma 4f6ecd10c2 gh-138342: Use a common utility for visiting an object's type (GH-138343)
Add `_PyObject_VisitType` in place of `tp_traverse` functions that only visit the object's type.
2025-09-01 16:20:33 +00:00
Adam Turner 918e3ba6c0 GH-137623: Use an AC decorator for docstring line length enforcement (#137690) 2025-08-18 18:29:00 +01:00
naweiss a50822ff94 gh-107545: Fix misleading setsockopt() error messages (GH-107546) 2025-08-05 10:16:14 +00:00
Kumar Aditya c825b5d989 gh-135748: use argument clinic for more socket methods (#135749) 2025-06-20 12:02:37 +00:00
Chris Eibl cc8e6d2703 GH-131296: Suppress clang-cl warnings in socketmodule.c (GH-131821) 2025-06-09 17:38:41 +01:00
Kumar Aditya 2d82ab761a gh-132886: use relaxed atomics for sock_fd in gil builds in socket module (#133208) 2025-05-08 22:33:41 +05:30
Serhiy Storchaka 4c914e7a36 gh-133583: Add support for fixed size unsigned integers in argument parsing (GH-133584)
* Add Argument Clinic converters: uint8, uint16, uint32, uint64.
* Add private C API: _PyLong_UInt8_Converter(),
  _PyLong_UInt16_Converter(), _PyLong_UInt32_Converter(),
  _PyLong_UInt64_Converter().
2025-05-08 12:27:50 +03:00
Serhiy Storchaka 4265854d96 gh-132987: Support __index__() in the socket module (GH-133093)
ntohl(), htonl(), if_indextoname(), getaddrinfo() now use __index__() if
available.

Also fix the Argument Clinic names for module-level functions (although
this does not affect the user).
2025-04-29 19:27:07 +03:00
Alyssa Ross 314f4b9716 gh-132991: Add socket.IP_FREEBIND constant (GH-132998) 2025-04-26 20:54:12 +03:00
Serhiy Storchaka d7be26a71e gh-132734: Fix build on FreeBSD and old Linux (GH-132829) 2025-04-23 14:08:30 +03:00
Serhiy Storchaka e84624450d gh-132734: Add new constants for Bluetooth sockets (GH-132735) 2025-04-22 11:02:13 +00:00
ce31ae5209 gh-129719: Restore missing socket.CAN_RAW_ERR_FILTER on Linux (#129721)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-04-18 22:59:37 +03:00