Commit Graph

29 Commits

Author SHA1 Message Date
Brian Wellington
0bed1d3956 socket.create_connection source_address is optional. (#4133) 2020-05-28 19:56:11 +02:00
Rune Tynan
d51e13ad80 Add stubtest to Travis for windows (#4113) 2020-05-27 18:33:07 -07:00
Rune Tynan
f83e4aef7c Fix stubtest failures for socket on windows (#4102) 2020-05-27 09:38:45 +02:00
Shantanu
111f3f02ef socket: fix default mode for makefile (#3978)
Fixes #3977

Co-authored-by: hauntsaninja <>
2020-05-12 18:22:25 -07:00
tikki
bd55cae8b6 fix arg name to socket.getaddrinfo for py3 (#3689) 2020-01-30 18:45:38 -08:00
Jacob Ilias Komissar
eb6ce3cacb Fix socket.socket.ioctl (#3669)
Fixes #3495

Co-authored-by: Niels Buwen <nielsbuwen@users.noreply.github.com>
2020-01-27 21:25:33 -08:00
Jacob Ilias Komissar
39ebd62e71 Update stub for socket module (#3451)
* Add new socket constants from 3.7 and 3.8
* Also move TCP_NOTSENT_LOWAT to 3.7 section and add AF_ALG to AddressFamily
* Add missing and updated socket module (and class) methods
* Improve formatting of socket.pyi
    * Add missing line breaks in long function parameters
* Reorder to mirror module documentations
* Fix type of create_server's family parameter
* Add more system conditionals
* Remove CAPI; it isn't an int (it's a PyCapsule)
* Slightly improve version conditions in socket.pyi
* Add incomplete signatures for socket.sendfile and .sendmsg_afalg
* Add VM_SOCKETS_INVALID_VERSION to socket.pyi
* Remove private _GLOBAL_DEFAULT_TIMEOUT from socket.pyi
* Add mode-dependent return types to socket.makefile
    - For Python 2, return and mode types are based on those of 'open'
    - For Python 3, types are based on actual behaviors
* Mark recv_into and recvfrom_into's nbytes argument as optional
* Improve docstring for socket stub
2019-12-05 08:13:06 +01:00
Sebastian Rittau
0501e2b329 Annotations for remaining Python 3.8 additions (#3358)
* Add os.add_dll_directory()
* Add memfd_create() and flags
* Add type annotation to flags
* Add stat_result.st_reparse_tag and flags
* Add ncurses_version
* Add Path.link_to()
* Add Picker.reducer_override()
* Add plistlib.UID
* Add has_dualstack_ipv6() and create_server()
* Add shlex.join()
* Add SSL methods and fields
* Add Python 3.8 statistics functions and classes
* Remove obsolete sys.subversion
* Add sys.unraisablehook
* Add threading.excepthook
* Add get_native_id() and Thread.native_id
* Add Python 3.8 tkinter methods
* Add CLOCK_UPTIME_RAW
* Add SupportsIndex
* Add typing.get_origin() and get_args()
* Add unicodedata.is_normalized
* Add unittest.mock.AsyncMock

Currently this is just an alias for Any like Mock and MagicMock. All of
these classes should probably be sub-classing Any and add their own
methods. See also #3224.

* Add unittest cleanup methods
* Add IsolatedAsyncioTestCase
* Add ElementTree.canonicalize() and C14NWriterTarget
* cProfile.Profile can be used as a context manager
* Add asyncio task name handling
* mmap.flush() now always returns None
* Add posonlyargcount to CodeType
2019-10-14 09:53:48 +02:00
Guido van Rossum
b336182b69 Fix some errors with --disallow-any-generics (#3276)
See #3267. Covers all of stdlib/2and3.
2019-09-29 09:15:27 -07:00
Jelle Zijlstra
d05a9d3d83 Improve enums (#3168)
I realized while working on srittau/type-stub-pep#64 that a
few things we do in existing enum definitions in typeshed are
problematic:

- Using "= ..." doesn't allow type checkers to correctly type the
  result of Enum.MEMBER.value. In fact, mypy at least infers
  .value to be "Ellipsis" if you do this.
- Properties on the enum values themselves, like HTTPStatus.phrase,
  should not be specified directly as attributes, because it makes
  type checkers think that the properties themselves are enum
  members.

I ended up doing a bit more cleanup to the signal module:
- Remove unnecessary ... initializers.
- Remove unnecessary _SIG = Signals alias.
- I don't have Windows to test, but the C code for _signal suggests
  that CTRL_C_EVENT and CTRL_BREAK events are not Signals, but just ints:
  1dbd084f1f/Modules/signalmodule.c (L1575)
2019-08-05 08:08:57 -07:00
Sebastian Rittau
dad16f2d43 Update socket exceptions (#3127)
* error is an alias for OSError in Python 3
* herror and gaierror can be constructed without arguments (tested
  in Python 2.7 and 3.7)
* timeout uses the same arguments as herror and gaierror
2019-07-18 16:50:28 -07:00
Matthew Wilkes
d149fe435c Represent the use of IntEnums in functions in socket.py. (#3009)
The Pull Request #1121 added the `AddressFamily` type to `socket.pyi`
for Python 3.4+, so constants such as `AF_INET` are correctly
represented as being an enum member rather than an int. The same is
true of the `SocketKind` enums in the `SOCK_*` family.

Various functions in the socket module can accept either an int
or an `AF_*` enum member as arguments, which is allowed by the
int argument type. However the `getaddrinfo` function returns an
`AddressFamily` member rather than an int in the first position
of its list members, so code that access enum specific members
such as the `name` attribute causes a typing error to be found.

This change corrects the return type of `getaddrinfo` but leaves
the family parameters as int, given that `AddressFamily` members
are `IntEnum` and only ever treated as `int`s internally.
2019-06-19 15:14:15 -07:00
Jelle Zijlstra
ff650d3275 socket: add .set_inheritable() (#2935) 2019-04-28 17:13:20 +02:00
Philipp Hahn
b022f76516 socket: timeout may be None (#2801)
timeout=None puts the socket into blocking mode.

Read <https://bugs.python.org/issue18417> and the referenced other
issues for more gory details.
2019-02-18 11:32:25 +01:00
Ville Skyttä
9b5976e15b socket: Some more address typing (#2695) 2018-12-20 19:45:29 -08:00
PRAJWAL M
c0d181605e Make backlog parameter optional in listen method (#2553) 2018-10-25 18:14:39 +02:00
Sebastian Rittau
006a79220f Flake8 fixes (#2549)
* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
2018-10-24 07:20:53 -07:00
Ville Skyttä
066d8becf9 socket.create_connection source_address can be bytes or bytearray too (#2370)
* socket.create_connection source_address can be bytes or bytearray too

* Sync applicable socket.create_connection changes to socket.getaddrinfo
2018-08-09 10:02:34 -07:00
Ville Skyttä
850d16a668 socket.recv* return type improvements (#2363) 2018-08-09 08:07:17 -07:00
Yusuke Miyazaki
6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -07:00
Andrew Svetlov
a5b7ddd96c Accepy bytes in sock.connect() and family (#2252) 2018-06-18 10:30:41 -07:00
Jelle Zijlstra
f65caed181 allow socket.recv_into to take a memoryview (#2127)
Fixes #1862
2018-06-11 14:25:11 -07:00
Dmitry Figol
f7f00c52af socket.create_connection allows host to be None (#2136) 2018-05-17 09:45:59 -04:00
hashstat
0917560195 Add new methods to socket stubs. (#1638)
* Add new methods to socket stubs.

Also fix a couple of invalid types in recv*_into() socket methods.

* Add double-underscores to parameters for position-only arguments
2017-10-07 08:41:06 -07:00
hashstat
6661377597 Ensure AF_*, SOCK_*, AI_*, and MSG_* constants use enum types (#1637) 2017-10-04 08:55:36 -07:00
Dominik Gabi
693509bff6 Change Union[float, None] to Optional in socket.pyi (#1602) 2017-09-13 13:23:54 -07:00
Harmen
d260bb4889 support for with socket.create_connection (#1429) 2017-06-24 09:11:12 -07:00
Jelle Zijlstra
c31dcf4088 Add more flags to socket (#1348)
Also switch to PEP 526-style types in socket.
2017-05-26 08:25:20 -07:00
David Euresti
f741429a75 Move socket into 2and3 (#1149)
* Merge socket modules

* Move socket to 2and3
2017-04-07 18:01:33 -07:00