Commit Graph

242 Commits

Author SHA1 Message Date
Christian Heimes 0d35a59ce3
gh-95174: Handle missing dup() and constants in WASI (GH-95229)
- 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)
2022-07-26 11:16:51 +02:00
Christian Heimes f00ced8396
bpo-40280: select: Use NULL for empty fdset (GH-31865)
wasm32-emscripten does not support exceptfds and requires NULL. Python
now passes NULL instead of a fdset pointer when the input list is empty.
This works fine on all platforms and might even be a tiny bit faster.
2022-03-14 14:40:28 +01:00
Zane Bitter 27df7566bc
bpo-41857: mention timeout argument units in select.poll() and select.depoll() doc-strings (GH-22406) 2022-01-21 01:08:44 +02:00
Victor Stinner ea1a54506b
bpo-46303: Move fileutils.h private functions to internal C API (GH-30484)
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.
2022-01-11 11:56:16 +01:00
Victor Stinner 833fdf126c
bpo-41710: Add private _PyDeadline_Get() function (GH-28674)
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().
2021-10-01 13:29:25 +02:00
Victor Stinner 09796f2f14
bpo-41710: Add _PyTime_AsTimespec_clamp() (GH-28629)
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.
2021-09-30 02:11:41 +02:00
Victor Stinner 7dcf0f6db3
bpo-43916: select.devpoll uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25751) 2021-04-30 18:19:57 +02:00
Erlend Egeberg Aasland 387397f8a4
bpo-43916: select.poll uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25750) 2021-04-30 15:49:17 +02:00
Victor Stinner 32bd68c839
bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)
No longer use deprecated aliases to functions:

* Replace PyObject_MALLOC() with PyObject_Malloc()
* Replace PyObject_REALLOC() with PyObject_Realloc()
* Replace PyObject_FREE() with PyObject_Free()
* Replace PyObject_Del() with PyObject_Free()
* Replace PyObject_DEL() with PyObject_Free()
2020-12-01 10:37:39 +01:00
Victor Stinner 00d7abd7ef
bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)
No longer use deprecated aliases to functions:

* Replace PyMem_MALLOC() with PyMem_Malloc()
* Replace PyMem_REALLOC() with PyMem_Realloc()
* Replace PyMem_FREE() with PyMem_Free()
* Replace PyMem_Del() with PyMem_Free()
* Replace PyMem_DEL() with PyMem_Free()

Modify also the PyMem_DEL() macro to use directly PyMem_Free().
2020-12-01 09:56:42 +01:00
Christian Heimes ea97ebab35
bpo-1635741: Port select module to multiphase init (GH-23409) 2020-11-21 20:29:26 +01:00
Serhiy Storchaka b510e101f8
bpo-42152: Use PyDict_Contains and PyDict_SetDefault if appropriate. (GH-22986)
If PyDict_GetItemWithError is only used to check whether the key is in dict,
it is better to use PyDict_Contains instead.

And if it is used in combination with PyDict_SetItem, PyDict_SetDefault can
replace the combination.
2020-10-26 12:47:57 +02:00
Serhiy Storchaka 9975cc5008
bpo-41985: Add _PyLong_FileDescriptor_Converter and AC converter for "fildes". (GH-22620) 2020-10-09 23:00:45 +03:00
Anthony Sottile d051801052
bpo-31938: Fix default-value signatures of several functions in the select module (GH-21066) 2020-06-23 23:49:56 +02:00
Victor Stinner 18a90248fd
bpo-32604: Fix reference leak in select module (GH-20600)
Fix reference leak in PyInit_select() of the select module:
remove Py_INCREF(poll_Type).
2020-06-03 14:36:46 +02:00
Jakub Stasiak 372ee27d49
bpo-38580: Document that select() accepts iterables, not just sequences (GH-16832) 2020-05-25 10:03:48 +03:00
Batuhan Taskaya 31245d19f2
bpo-39740: Early declare devpoll_methods to support old compilers (GH-19281) 2020-05-16 23:36:14 +01:00
Victor Stinner 4a21e57fe5
bpo-40268: Remove unused structmember.h includes (GH-19530)
If only offsetof() is needed: include stddef.h instead.

When structmember.h is used, add a comment explaining that
PyMemberDef is used.
2020-04-15 02:35:41 +02:00
Hai Shi f707d94af6
bpo-39968: Convert extension modules' macros of get_module_state() to inline functions (GH-19017) 2020-03-16 14:15:01 +01:00
Victor Stinner 5b23f7618d
bpo-39239: epoll.unregister() no longer ignores EBADF (GH-17882)
The select.epoll.unregister() method no longer ignores the EBADF
error.
2020-01-07 15:00:02 +01:00
Xiang Zhang 303475e873
Fix a compile warning in selectmodule.c. (GH-16617) 2019-10-07 20:01:54 +08:00
Dino Viehland f919054e53
bpo-38116: Convert select module to PEP-384 (#15971)
* Convert select module to PEP-384

Summary: Do the necessary versions to be Pyro-compatible, including migrating `PyType_Ready` to `PyType_FromSpec` and moving static data into a new `_selectstate` struct.

* 📜🤖 Added by blurb_it.

* Fixup Mac OS/X build
2019-09-14 15:20:27 +01:00
Jeroen Demeyer 762f93ff2e bpo-37337: Add _PyObject_CallMethodNoArgs() (GH-14267) 2019-07-08 17:19:25 +09:00
Jeroen Demeyer 530f506ac9 bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async (GH-13464)
Automatically replace
tp_print -> tp_vectorcall_offset
tp_compare -> tp_as_async
tp_reserved -> tp_as_async
2019-05-30 19:13:39 -07:00
Serhiy Storchaka a24107b04c
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112) 2019-02-25 17:59:46 +02:00
Zackery Spytz 99d56b5356 bpo-35441: Remove dead and buggy code related to PyList_SetItem(). (GH-11033)
In _localemodule.c and selectmodule.c, remove dead code that would
cause double decrefs if run.

In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases
where a new list is populated and there is no possibility of an error.

In addition, check if the list changed size in the loop in array_array_fromlist().
2018-12-08 16:16:55 +02:00
Oran Avraham 7f52415a6d bpo-35310: Clear select() lists before returning upon EINTR (GH-10877)
select() calls are retried on EINTR (per PEP 475).  However, if a
timeout was provided and the deadline has passed after running the
signal handlers, rlist, wlist and xlist should be cleared since select(2)
left them unmodified.
2018-12-05 21:36:03 +01:00
Serhiy Storchaka d4f9cf5545
bpo-33029: Fix signatures of getter and setter functions. (GH-10746)
Fix also return type for few other functions (clear, releasebuffer).
2018-11-27 19:34:35 +02:00
Berker Peksag b690b9b047
bpo-29386: Pass -1 to epoll_wait() when timeout is < -1 (GH-9040)
Although the kernel accepts any negative value for timeout, the
documented value to block indefinitely is -1.

This commit also makes the code similar to select.poll.poll().
2018-09-11 20:29:48 +03:00
Michael Osipov 0e6e7a1e52 bpo-34419: selectmodule.c does not compile on HP-UX due to bpo-31938 (GH-8796)
Fix compile errors reported by HP aCC by fixing bugs introduced in 6dc57e2a20
which do not cause trouble on clang or GCC.

Patch by Michael Osipov.
2018-08-17 14:43:02 +03:00
Serhiy Storchaka 7cb7bcff20
bpo-20260: Implement non-bitwise unsigned int converters for Argument Clinic. (GH-8434) 2018-07-26 13:22:16 +03:00
Tal Einat 6dc57e2a20
bpo-31938: Convert selectmodule.c to Argument Clinic (GH-4265) 2018-06-30 23:02:48 +03:00
Tal Einat 0cdf5f4289
bpo-32568: make select.epoll() and its docs consistent (#7840)
* `flags` is indeed deprecated, but there is a validation on its value for
  backwards compatibility reasons.  This adds mention of this in the docs.
* The docs say that `sizehint` is deprecated and ignored, but it is still
  used when `epoll_create1()` is unavailable. This adds mention of this in
  the docs.
* `sizehint=-1` is acceptable again, and is replaced with `FD_SETSIZE-1`.
  This is needed to have a default value available at the Python level,
  since `FD_SETSIZE` is not exposed to Python. (see: bpo-31938)
* Reject `sizehint=0` since it is invalid to pass on to `epoll_create()`.

The relevant tests have also been updated.
2018-06-30 15:43:23 +03:00
Siddhesh Poyarekar 55edd0c185 bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. (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.
2018-04-29 21:59:33 +03:00
oldk aa0735f597 bpo-32747: Remove trailing spaces in docstrings. (GH-5491) 2018-02-02 10:52:55 +02:00
Victor Stinner b8d90328ad
bpo-28914: Fix compilation of select on Android (#5447)
EPOLL_CLOEXEC is not defined on Android.

Co-Authored-By: Wataru Matsumoto <sxsns243@gmail.com>
2018-01-30 12:18:54 +01:00
stratakis e8b1965639 bpo-23699: Use a macro to reduce boilerplate code in rich comparison functions (GH-793) 2017-11-02 20:32:54 +10:00
Serhiy Storchaka 2298fad5ff
bpo-31893: Fix errors in b9052a0f91. (#4196)
* Fix a compilation error on FreeBSD.
* Fix the data attribute size on Mac OS X.
2017-10-31 18:18:21 +02:00
Serhiy Storchaka b9052a0f91
bpo-31893: Fixed select.kqueue(). (#4166)
* Fixed the layout of the kqueue_event structure on OpenBSD and NetBSD.
* Fixed the comparison of the kqueue_event objects.
2017-10-31 13:59:55 +02:00
Riccardo Coccioli 6cfa927ceb bpo-31334: Fix timeout in select.poll.poll() (GH-3277)
Always pass -1, or INFTIM where defined, to the poll() system call when
a negative timeout is passed to the poll.poll([timeout]) method in the
select module. Various OSes throw an error with arbitrary negative
values.
2017-10-17 12:45:07 -07:00
Pablo Galindo 2c15b29aea bpo-31786: Make functions in the select module blocking when timeout is a small negative value. (#4003) 2017-10-17 17:14:41 +03:00
Serhiy Storchaka de07210077 bpo-30058: Fixed buffer overflow in select.kqueue.control(). (#1095) 2017-10-12 22:17:46 +03:00
Serhiy Storchaka bf623ae884 bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096)
raised an error.

Replace them with using concrete types API that never fails if appropriate.
2017-04-19 20:03:52 +03:00
Serhiy Storchaka 55fe1ae970 bpo-30022: Get rid of using EnvironmentError and IOError (except test… (#1051) 2017-04-16 10:46:38 +03:00
Serhiy Storchaka 783d0c1a1c bpo-28667: Fix a compile warning on FreeBSD when compare with FD_SETSIZE. (#501)
FreeBSD is the only platforms with unsigned FD_SETSIZE.
2017-03-12 14:43:12 +02:00
Serhiy Storchaka 228b12edcc Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever
possible.  Patch is writen with Coccinelle.
2017-01-23 09:47:21 +02:00
Serhiy Storchaka 5ab81d787f Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of dict. 2016-12-16 16:18:57 +02:00
Berker Peksag e2197d1312 Issue #20100: Simplify newPyEpoll_Object()
EPOLL_CLOEXEC is the only value that can be passed
to epoll_create1() and we are passing EPOLL_CLOEXEC
unconditionally since Python 3.4.
2016-09-26 23:30:41 +03:00
Berker Peksag 7ec64562b2 Issue #28153: Make kqueue()'s event filters optional
Patch by Ed Schouten.
2016-09-14 18:16:59 +03:00
Benjamin Peterson ca47063998 replace Py_(u)intptr_t with the c99 standard types 2016-09-06 13:47:26 -07:00