summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* closes bpo-37405: Make socket.getsockname() always return a tuple for ↵bggardner2019-09-121-1/+1
| | | | | AF_CAN. (GH-14392) This fixes a regression from 3.5. In recent releases, `getsockname()` in the AF_CAN case has returned a string.
* bpo-15999: Always pass bool instead of int to socket.setblocking(). (GH-15621)Serhiy Storchaka2019-09-011-1/+1
|
* Unmark files as executable that can't actually be executed. (GH-15353)Greg Price2019-08-211-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There are plenty of legitimate scripts in the tree that begin with a `#!`, but also a few that seem to be marked executable by mistake. Found them with this command -- it gets executable files known to Git, filters to the ones that don't start with a `#!`, and then unmarks them as executable: $ git ls-files --stage \ | perl -lane 'print $F[3] if (!/^100644/)' \ | while read f; do head -c2 "$f" | grep -qxF '#!' \ || chmod a-x "$f"; \ done Looking at the list by hand confirms that we didn't sweep up any files that should have the executable bit after all. In particular * The `.psd` files are images from Photoshop. * The `.bat` files sure look like things that can be run. But we have lots of other `.bat` files, and they don't have this bit set, so it must not be needed for them. Automerge-Triggered-By: @benjaminp
* bpo-37811: FreeBSD, OSX: fix poll(2) usage in sockets module (GH-15202)Artem Khramov2019-08-141-0/+11
| | | | | | | | | | | | | | | | FreeBSD implementation of poll(2) restricts the timeout argument to be either zero, or positive, or equal to INFTIM (-1). Unless otherwise overridden, socket timeout defaults to -1. This value is then converted to milliseconds (-1000) and used as argument to the poll syscall. poll returns EINVAL (22), and the connection fails. This bug was discovered during the EINTR handling testing, and the reproduction code can be found in https://bugs.python.org/issue23618 (see connect_eintr.py, attached). On GNU/Linux, the example runs as expected. This change is trivial: If the supplied timeout value is negative, truncate it to -1.
* bpo-36590: Add Bluetooth RFCOMM and support for Windows. (GH-12767)Greg Bowser2019-08-021-6/+59
| | | | | | | | | | | Support for RFCOMM, L2CAP, HCI, SCO is based on the BTPROTO_* macros being defined. Winsock only supports RFCOMM, even though it has a BTHPROTO_L2CAP macro. L2CAP support would build on windows, but not necessarily work. This also adds some basic unittests for constants (all of which existed prior to this commit, just not on windows) and creating sockets. pair: Nate Duarte <slacknate@gmail.com>
* bpo-37085: Expose SocketCAN bcm_msg_head flags (#13646)karl ding2019-07-311-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | Expose the CAN_BCM SocketCAN constants used in the bcm_msg_head struct flags (provided by <linux/can/bcm.h>) under the socket library. This adds the following constants with a CAN_BCM prefix: * SETTIMER * STARTTIMER * TX_COUNTEVT * TX_ANNOUNCE * TX_CP_CAN_ID * RX_FILTER_ID * RX_CHECK_DLC * RX_NO_AUTOTIMER * RX_ANNOUNCE_RESUME * TX_RESET_MULTI_IDX * RX_RTR_FRAME * CAN_FD_FRAME The CAN_FD_FRAME flag was introduced in the 4.8 kernel, while the other ones were present since SocketCAN drivers were mainlined in 2.6.25. As such, it is probably unnecessary to guard against these constants being missing.
* bpo-37345: Add formal UDPLITE support (GH-14258)Gabe Appleton2019-06-241-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment you can definitely use UDPLITE sockets on Linux systems, but it would be good if this support were formalized such that you can detect support at runtime easily. At the moment, to make and use a UDPLITE socket requires something like the following code: ``` >>> import socket >>> a = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 136) >>> b = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 136) >>> a.bind(('localhost', 44444)) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.setsockopt(136, 10, 16) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.setsockopt(136, 10, 32) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.setsockopt(136, 10, 64) >>> b.sendto(b'test'*256, ('localhost', 44444)) ``` If you look at this through Wireshark, you can see that the packets are different in that the checksums and checksum coverages change. With the pull request that I am submitting momentarily, you could do the following code instead: ``` >>> import socket >>> a = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDPLITE) >>> b = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDPLITE) >>> a.bind(('localhost', 44444)) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.set_send_checksum_coverage(16) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.set_send_checksum_coverage(32) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.set_send_checksum_coverage(64) >>> b.sendto(b'test'*256, ('localhost', 44444)) ``` One can also detect support for UDPLITE just by checking ``` >>> hasattr(socket, 'IPPROTO_UDPLITE') ``` https://bugs.python.org/issue37345
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-2/+2
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-37007: Implement socket.if_nametoindex(), if_indextoname() and ↵Zackery Spytz2019-05-291-11/+49
| | | | if_nameindex() on Windows (GH-13522)
* bpo-32388: Remove cross-version binary compatibility requirement in tp_flags ↵Antoine Pitrou2019-05-291-2/+1
| | | | | | | | (GH-4944) It is now allowed to add new fields at the end of the PyTypeObject struct without having to allocate a dedicated compatibility flag in tp_flags. This will reduce the risk of running out of bits in the 32-bit tp_flags value.
* bpo-36842: Implement PEP 578 (GH-12613)Steve Dower2019-05-231-0/+80
| | | Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
* bpo-29515: add missing socket.IPPROTO_* constants on Windows (GH-12183)Giampaolo Rodola2019-03-281-1/+46
|
* bpo-8677: use PY_SSIZE_T_CLEAN in socketmodule.c (GH-12467)Inada Naoki2019-03-201-1/+2
|
* bpo-36254: Fix invalid uses of %d in format strings in C. (GH-12264)Serhiy Storchaka2019-03-131-2/+2
|
* bpo-35550: Fix incorrect Solaris define guards (GH-11275)Jakub Kulík2018-12-311-1/+1
| | | | | | | Python source code uses on several places ifdef sun or defined(sun) without the underscores, which is not standard compliant and shouldn't be used. Defines should check for __sun instead. Reference: http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system#Solaris https://bugs.python.org/issue35550
* bpo-35214: MSan workarounds for socket, time, and test_faulthandler. (GH-11375)Gregory P. Smith2018-12-311-0/+20
| | | | | Add Clang Memory Sanitizer build instrumentation to work around false positives from the socket and time modules as well as skipping a couple test_faulthandler tests.
* bpo-35415: validate fileno argument to socket.socket (GH-10917)Dima Tisnek2018-12-171-20/+29
| | | https://bugs.python.org/issue35415
* bpo-35454: Fix miscellaneous minor issues in error handling. (#11077)Serhiy Storchaka2018-12-111-4/+8
| | | | | | * bpo-35454: Fix miscellaneous minor issues in error handling. * Fix a null pointer dereference.
* bpo-35050: AF_ALG length check off-by-one error (GH-10058)Christian Heimes2018-12-101-3/+5
| | | | | | | | The length check for AF_ALG salg_name and salg_type had a off-by-one error. The code assumed that both values are not necessarily NULL terminated. However the Kernel code for alg_bind() ensures that the last byte of both strings are NULL terminated. Signed-off-by: Christian Heimes <christian@python.org>
* bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka2018-11-271-4/+4
| | | | | | Fix invalid function cast warnings with gcc 8 for method conventions different from METH_NOARGS, METH_O and METH_VARARGS excluding Argument Clinic generated code.
* Fix a possible reference leak in _socket.getaddrinfo(). (GH-10543)Zackery Spytz2018-11-141-2/+4
| | | "single" needs to be decrefed if PyList_Append() fails.
* bpo-31425: Expose AF_QIPCRTR in socket module (GH-3706)Bjorn Andersson2018-09-261-2/+49
| | | | | | The AF_QIPCRTR address family was introduced in Linux v4.7. Co-authored-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* closes bpo-25041: Document AF_PACKET socket address format. (GH-4092)Cheryl Sabella2018-09-121-3/+3
|
* closes bpo-29832: Remove "getsockaddrarg" from error messages. (GH-3163)Oren Milman2018-09-111-60/+119
|
* closes bpo-34581 : Conditionalize use of __pragma in Modules/socketmodule.c. ↵Erik Janssens2018-09-051-2/+5
| | | | | | (GH-9067)
* bpo-34217: Use lowercase for windows headers (GH-8472)Erik Janssens2018-08-161-1/+1
|
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-10/+10
| | | | | | | | | (GH-6030) METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 due to the argument mismatch. Fix this by adding a dummy unused argument.
* bpo-32394: Remove some TCP options on old version Windows. (GH-5523)animalize2018-02-261-0/+70
|
* bpo-32221: makeipaddr(): remove interface part + speedup (GH-5449) (#5449)Коренберг Марк2018-02-121-28/+31
|
* Fix some warnings produced by different compilers. (#5593)Serhiy Storchaka2018-02-091-2/+6
|
* bpo-32746: Fix multiple typos (GH-5144)Leo Arias2018-02-041-1/+1
| | | Fix typos found by codespell in docs, docstrings, and comments.
* bpo-32747: Remove trailing spaces in docstrings. (GH-5491)oldk2018-02-021-7/+7
|
* bpo-28134: Auto-detect socket values from file descriptor (#1349)Christian Heimes2018-01-291-2/+69
| | | | | | | | | | | | | | | Fix socket(fileno=fd) by auto-detecting the socket's family, type, and proto from the file descriptor. The auto-detection can be overruled by passing in family, type, and proto explicitly. Without the fix, all socket except for TCP/IP over IPv4 are basically broken: >>> s = socket.create_connection(('www.python.org', 443)) >>> s <socket.socket fd=3, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('2003:58:bc4a:3b00:56ee:75ff:fe47:ca7b', 59730, 0, 0), raddr=('2a04:4e42:1b::223', 443, 0, 0)> >>> socket.socket(fileno=s.fileno()) <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('2003:58:bc4a:3b00::%2550471192', 59730, 0, 2550471192), raddr=('2a04:4e42:1b:0:700c:e70b:ff7f:0%2550471192', 443, 0, 2550471192)> Signed-off-by: Christian Heimes <christian@python.org>
* bpo-32373: Add socket.getblocking() method. (#4926)Yury Selivanov2018-01-281-1/+48
|
* Revert "bpo-32221: makeipaddr(): remove interface part + speedup (GH-4724)" ↵Yury Selivanov2018-01-281-31/+28
| | | | | (#5394) This reverts commit 47c0b1f7d4115e6f15e6776c1f91d28e7d96fe0c.
* bpo-32221: makeipaddr(): remove interface part + speedup (GH-4724)Коренберг Марк2018-01-271-28/+31
|
* bpo-32454: socket closefd (#5048)Christian Heimes2018-01-271-2/+29
| | | | | Add close(fd) function to the socket module Signed-off-by: Christian Heimes <christian@python.org>
* bpo-32282: Remove unnecessary check for `VersionHelpers.h` in ↵Max Bélanger2018-01-071-10/+0
| | | | `socketmodule.c` on Windows
* bpo-32331: Fix socket.type when SOCK_NONBLOCK is available (#4877)Yury Selivanov2017-12-191-6/+15
|
* bpo-31927: Fix bugs in socketmodule.c on NetBSD and other issues. (#4235)Serhiy Storchaka2017-11-091-64/+67
| | | | | | | * Fix compilation of the socket module on NetBSD 8. * Fix the assertion failure or reading arbitrary data when parse a AF_BLUETOOTH address on NetBSD and DragonFly BSD. * Fix other potential errors and make the code more reliable.
* Fix miscellaneous typos (#4275)luzpaz2017-11-051-1/+1
|
* bpo-16135: Cleanup: Code rot left over from OS/2 support (GH-4147)Erik Bray2017-10-271-7/+0
| | | | Remove dangling references to PYCC_VACPP that are not relelvant since removal of OS/2 support.
* Fix _socket module compilation on Cygwin. (#4137)Erik Bray2017-10-271-1/+1
|
* bpo-31806: Use _PyTime_ROUND_TIMEOUT for the timeout argument parsing in ↵Pablo Galindo2017-10-181-3/+3
| | | | | | | | | more functions (#4026) Fix timeout rounding in time.sleep(), threading.Lock.acquire() and socket.socket.settimeout() to round correctly negative timeouts between -1.0 and 0.0. The functions now block waiting for events as expected. Previously, the call was incorrectly non-blocking.
* Remove a null statement that was necessary for --without-threads (#3478)Zackery Spytz2017-09-111-1/+0
|
* bpo-31393: Fix the use of PyUnicode_READY(). (#3451)Serhiy Storchaka2017-09-081-1/+4
|
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-12/+2
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-27584: New addition of vSockets to the python socket module (#2489)caavery2017-09-061-2/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bpo-27584: New addition of vSockets to the python socket module Support for AF_VSOCK on Linux only * bpo-27584: Fixes for V2 Fixed syntax and naming problems. Fixed #ifdef AF_VSOCK checking Restored original aclocal.m4 * bpo-27584: Fixes for V3 Added checking for fcntl and thread modules. * bpo-27584: Fixes for V4 Fixed white space error * bpo-27584: Fixes for V5 Added back comma in (CID, port). * bpo-27584: Fixes for V6 Added news file. socket.rst now reflects first Linux introduction of AF_VSOCK. Fixed get_cid in test_socket.py. Replaced PyLong_FromLong with PyLong_FromUnsignedLong in socketmodule.c Got rid of extra AF_VSOCK #define. Added sockaddr_vm to sock_addr. * bpo-27584: Fixes for V7 Minor cleanup. * bpo-27584: Fixes for V8 Put back #undef AF_VSOCK as it is necessary when vm_sockets.h is not installed.
* remove IRIX support (closes bpo-31341) (#3310)Benjamin Peterson2017-09-041-4/+2
| | | See PEP 11.
* bpo-30987 - Support for ISO-TP protocol in SocketCAN (#2956)Pier-Yves Lessard2017-08-281-5/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added support for CAN_ISOTP protocol * Added unit tests for CAN ISOTP * Updated documentation for ISO-TP protocol * Removed trailing whitespace in documentation * Added blurb NEWS.d file * updated Misc/ACKS * Fixed broken unit test that was using isotp const outside of skippable section * Removed dependecy over third party project * Added implementation for getsockname + unit tests * Missing newline at end of ACKS file * Accidentally inserted a type in ACKS file * Followed tiran changes review #1 recommendations * Added spaces after comma