summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* [3.12] bpo-37013: Fix the error handling in socket.if_indextoname() ↵Miss Islington (bot)2023-12-251-5/+11
| | | | | | | | | (GH-13503) (GH-112597) * Fix a crash when pass UINT_MAX. * Fix an integer overflow on 64-bit non-Windows platforms. (cherry picked from commit 0daf555c6fb3feba77989382135a58215e1d70a5) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* [3.12] gh-111253: Fix error checking in _socket module init (GH-111254) ↵Miss Islington (bot)2023-11-011-2/+2
| | | | | | | | (#111299) gh-111253: Fix error checking in _socket module init (GH-111254) (cherry picked from commit 3052c098ca2779c2d9ab9800dabe66d0efa01794) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.12] gh-78469: Declare missing sethostname for Solaris 10 (GH-109447) ↵Miss Islington (bot)2023-10-101-2/+3
| | | | | | | | (#110580) Add OS version specific macro for Solaris: Py_SUNOS_VERSION. (cherry picked from commit 3b1580af07c0ce90d1c2073ab087772283d7e3b9) Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
* [3.12] gh-107913: Fix possible losses of OSError error codes (GH-107930) ↵Miss Islington (bot)2023-08-261-5/+7
| | | | | | | | | | | | (#108523) gh-107913: Fix possible losses of OSError error codes (GH-107930) Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be called immediately after using the C API which sets errno or the Windows error code. (cherry picked from commit 2b15536fa94d07e9e286826c23507402313ec7f4) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.12] gh-104432: Use `memcpy()` to avoid misaligned loads (GH-104433) (#107355)Miss Islington (bot)2023-07-271-5/+17
| | | | | | | | | | gh-104432: Use `memcpy()` to avoid misaligned loads (GH-104433) Fix potential unaligned memory access on C APIs involving returned sequences of `char *` pointers within the :mod:`grp` and :mod:`socket` modules. These were revealed using a ``-fsaniziter=alignment`` build on ARM macOS. (cherry picked from commit f01e4cedba1a17d321664834bb255d9d04ad16ce) Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
* gh-98836: Extend PyUnicode_FromFormat() (GH-98838)Serhiy Storchaka2023-05-211-6/+2
| | | | | | | | | * Support for conversion specifiers o (octal) and X (uppercase hexadecimal). * Support for length modifiers j (intmax_t) and t (ptrdiff_t). * Length modifiers are now applied to all integer conversions. * Support for wchar_t C strings (%ls and %lV). * Support for variable width and precision (*). * Support for flag - (left alignment).
* GH-104308: socket.getnameinfo should release the GIL (#104307)Nathaniel J. Smith2023-05-081-0/+2
| | | | | | | | | * socket.getnameinfo should release the GIL * 📜🤖 Added by blurb_it. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)Eric Snow2023-05-051-0/+1
| | | Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
* gh-96534: socketmodule: support FreeBSD divert(4) socket (#96536)Gleb Smirnoff2023-05-041-0/+13
|
* gh-89415: Add source-specific multicast constants to socket module (#103684)Reese Hyde2023-04-271-0/+12
| | | | | Add socket options for source-specific multicast when present as C #defines. Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
* gh-103092: Isolate `socket` module (#103094)Erlend E. Aasland2023-04-091-161/+233
|
* gh-83004: Harden _socket init (GH-103261)Erlend E. Aasland2023-04-071-537/+581
| | | Automerge-Triggered-By: GH:erlend-aasland
* Add IPv6 into to the docstring for socket.getsockname (#102961)Brian Haley2023-03-301-1/+2
| | | Signed-off-by: Brian Haley <haleyb.dev@gmail.com>
* gh-102255: Use GetVersionEx instead of GetVersionExW to match argument type ↵Max Bachmann2023-03-201-1/+1
| | | | | | (GH-102583) Since we pass a structure of type `OSVERSIONINFOEX`, we need to call `GetVersionEx` instead of `GetVersionExW`.
* gh-102255: Improve build support for Windows API partitions (GH-102256)Max Bachmann2023-03-091-21/+39
| | | | | Add `MS_WINDOWS_DESKTOP`, `MS_WINDOWS_APPS`, `MS_WINDOWS_SYSTEM` and `MS_WINDOWS_GAMES` preprocessor definitions to allow switching off functionality missing from particular API partitions ("partitions" are used in Windows to identify overlapping subsets of APIs). CPython only officially supports `MS_WINDOWS_DESKTOP` and `MS_WINDOWS_SYSTEM` (APPS is included by normal desktop builds, but APPS without DESKTOP is not covered). Other configurations are a convenience for people building their own runtimes. `MS_WINDOWS_GAMES` is for the Xbox subset of the Windows API, which is also available on client OS, but is restricted compared to `MS_WINDOWS_DESKTOP`. These restrictions may change over time, as they relate to the build headers rather than the OS support, and so we assume that Xbox builds will use the latest available version of the GDK.
* gh-102336: Remove code specifically for handling Windows 7 (GH-102337)Max Bachmann2023-03-011-32/+10
|
* gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives ↵Irit Katriel2023-02-241-3/+2
| | | | (in Modules/) (#102196)
* gh-74895: getaddrinfo no longer raises OverflowError (#2435)Radek Smejkal2023-02-141-5/+9
| | | `socket.getaddrinfo()` no longer raises `OverflowError` based on the **port** argument. Error reporting (or not) for its value is left up to the underlying C library `getaddrinfo()` implementation.
* gh-100795: Don't call freeaddrinfo on failure. (#101252)Gregory P. Smith2023-01-231-0/+4
| | | | | | | | | 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>
* Revert "gh-100795: avoid unexpected `freeaddrinfo` after failed ↵Kumar Aditya2023-01-221-2/+0
| | | | | | | `getaddrinfo` (#101220)" (#101238) Revert "gh-100795: avoid unexpected `freeaddrinfo` after failed `getaddrinfo` (#101220)" This reverts commit 5f08fe4a2c055880c23c6f9b57ff03005d193bfc.
* gh-100795: avoid unexpected `freeaddrinfo` after failed `getaddrinfo` (#101220)Sergey G. Brester2023-01-221-0/+2
| | | Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
* GH-100813: Add `socket.IP_PKTINFO` constant (#10294)dsentinel2023-01-091-0/+3
|
* gh-98030: socket: add missing TCP socket options (#98031)Matthieu Baerts2022-12-081-3/+63
| | | | | | | | | | | | | 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>
* bpo-15999: Accept arbitrary values for boolean parameters. (#15609)Serhiy Storchaka2022-12-031-2/+2
| | | 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.
* gh-99300: Use Py_NewRef() in Modules/ directory (#99469)Victor Stinner2022-11-141-18/+8
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in test C files of the Modules/ directory.
* gh-95389: expose popular ETHERTYPE_* constants in the socket module (#95390)Noam Cohen2022-11-071-0/+23
| | | | Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
* gh-95174: WASI: skip missing sockets functions (GH-95179)Christian Heimes2022-07-271-10/+103
|
* gh-95174: Handle missing dup() and constants in WASI (GH-95229)Christian Heimes2022-07-261-0/+4
| | | | | | | - check for ``dup()`` libc function - handle missing ``F_DUPFD`` in ``dup2()`` replacement function - add workaround for WASI libc bug in MSG_TRUNC - ESHUTDOWN is missing, use EPIPE instead - POLLPRI is missing, define as 0 (no-op)
* gh-94821: Fix autobind of empty unix domain address (GH-94826)Nir Soffer2022-07-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When binding a unix socket to an empty address on Linux, the socket is automatically bound to an available address in the abstract namespace. >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> s.bind("") >>> s.getsockname() b'\x0075499' Since python 3.9, the socket is bound to the one address: >>> s.getsockname() b'\x00' And trying to bind multiple sockets will fail with: Traceback (most recent call last): File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind s2.bind("") OSError: [Errno 98] Address already in use Added 2 tests: - Auto binding empty address on Linux - Failing to bind an empty address on other platforms Fixes f6b3a07b7df6 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866)
* gh-94068: Remove HVSOCKET_CONTAINER_PASSTHRU constant because it has been ↵Steve Dower2022-06-211-1/+0
| | | | | | | removed from Windows (GH-94069) Fixes #94068 Automerge-Triggered-By: GH:zware
* gh-84461: Silence some compiler warnings on WASM (GH-93978)Christian Heimes2022-06-201-0/+2
|
* gh-92658: AF_HYPERV is only supported on Windows (#93192)Victor Stinner2022-05-251-7/+7
| | | | | 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.
* gh-92658: Add Hyper-V socket support (GH-92755)Jordan Borean2022-05-241-0/+131
|
* gh-91968: Add socket constants SO_USER_COOKIE/SO_RTABLE from BSD (#91967)David CARLIER2022-05-081-0/+6
| | | | | Those are somewhat equivalent to Linux' SO_MARK. Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-92210: Move socket.__init__ to argument clinic (#92237)Joshua Herman2022-05-041-14/+26
| | | | | | 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>
* gh-91320: Use _PyCFunction_CAST() (#92251)Victor Stinner2022-05-031-4/+4
| | | | | | | | | | 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")
* bpo-46696: Add socket.SO_INCOMING_CPU constant (#31237)David CARLIER2022-05-031-0/+3
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-91498: socket: Add TCP_CONNECTION_INFO on macOS (#69256)David CARLIER2022-04-271-0/+3
| | | Fixes GH-91498
* bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866)ty2022-03-271-1/+6
| | | | | | | Add missing terminated NUL in sockaddr_un's length - Linux: https://man7.org/linux/man-pages/man7/unix.7.html - *BSD: SUN_LEN
* bpo-46030: socket module add couple of FreeBSD constants. (GH-30018)David CARLIER2022-03-171-0/+9
| | | Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* bpo-40280: Disable AF_UNIX, AF_PACKET, SO_REUSE* on Emscripten (#31829)Christian Heimes2022-03-111-1/+1
| | | Emscripten's socket emulation is limited. AF_UNIX, AF_PACKET, setsockopt(), and most SO_* constants are not supported.
* closes bpo-46626: Expose IP_BIND_ADDRESS_NO_PORT socket option. (GH-31106)Benjamin Peterson2022-02-031-0/+3
|
* bpo-30512: Add CAN Socket support for NetBSD (GH-30066)Thomas Klausner2022-01-211-2/+4
|
* bpo-40280: Add --with-emscripten-target to build for browser or node (GH-30552)Christian Heimes2022-01-121-1/+1
| | | Co-authored-by: Ethan Smith <ethan@ethanhs.me>
* bpo-46303: Move fileutils.h private functions to internal C API (GH-30484)Victor Stinner2022-01-111-0/+5
| | | | | | | | | | 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.
* bpo-40280: Add configure check for socket shutdown (GH-29795)Christian Heimes2021-11-261-0/+4
|
* bpo-45743: Move __APPLE_USE_RFC_3542 into socketmodule.c (GH-29456)Christian Heimes2021-11-081-0/+2
|
* Fix typos in the Modules directory (GH-28761)Christian Clauss2021-10-071-1/+1
|
* bpo-41710: Add private _PyDeadline_Get() function (GH-28674)Victor Stinner2021-10-011-9/+11
| | | | | | | | Add a private C API for deadlines: add _PyDeadline_Init() and _PyDeadline_Get() functions. * Add _PyTime_Add() and _PyTime_Mul() functions which compute t1+t2 and t1*t2 and clamp the result on overflow. * _PyTime_MulDiv() now uses _PyTime_Add() and _PyTime_Mul().
* bpo-41710: Add _PyTime_AsTimespec_clamp() (GH-28629)Victor Stinner2021-09-301-1/+1
| | | | | | | | | | | | | | | Add the _PyTime_AsTimespec_clamp() function: similar to _PyTime_AsTimespec(), but clamp to _PyTime_t min/max and don't raise an exception. PyThread_acquire_lock_timed() now uses _PyTime_AsTimespec_clamp() to remove the Py_UNREACHABLE() code path. * Add _PyTime_AsTime_t() function. * Add PY_TIME_T_MIN and PY_TIME_T_MAX constants. * Replace _PyTime_AsTimeval_noraise() with _PyTime_AsTimeval_clamp(). * Add pytime_divide_round_up() function. * Fix integer overflow in pytime_divide(). * Add pytime_divmod() function.