Skip to content

Commit

Permalink
Pull in main
Browse files Browse the repository at this point in the history
  • Loading branch information
erlend-aasland committed Feb 20, 2024
2 parents 730c3f9 + 52d1477 commit 230e321
Show file tree
Hide file tree
Showing 33 changed files with 293 additions and 209 deletions.
5 changes: 5 additions & 0 deletions Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ Constants
Added ``IP_PKTINFO``, ``IP_UNBLOCK_SOURCE``, ``IP_BLOCK_SOURCE``,
``IP_ADD_SOURCE_MEMBERSHIP``, ``IP_DROP_SOURCE_MEMBERSHIP``.

.. versionchanged:: 3.13
Added ``SO_BINDTOIFINDEX``. On Linux this constant can be used in the
same way that ``SO_BINDTODEVICE`` is used, but with the index of a
network interface instead of its name.

.. data:: AF_CAN
PF_CAN
SOL_CAN_*
Expand Down
50 changes: 18 additions & 32 deletions Include/internal/pycore_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ extern "C" {
struct timeval;
#endif

typedef PyTime_t PyTime_t;
#define _SIZEOF_PYTIME_T 8

typedef enum {
Expand Down Expand Up @@ -253,37 +252,28 @@ typedef struct {
double resolution;
} _Py_clock_info_t;

// Get the current time from the system clock.
//
// If the internal clock fails, silently ignore the error and return 0.
// On integer overflow, silently ignore the overflow and clamp the clock to
// [_PyTime_MIN; _PyTime_MAX].
// Similar to PyTime_Time() but silently ignore the error and return 0 if the
// internal clock fails.
//
// Use _PyTime_GetSystemClockWithInfo or the public PyTime_Time() to check
// Use _PyTime_TimeWithInfo() or the public PyTime_Time() to check
// for failure.
// Export for '_random' shared extension.
PyAPI_FUNC(PyTime_t) _PyTime_GetSystemClock(void);
PyAPI_FUNC(PyTime_t) _PyTime_TimeUnchecked(void);

// Get the current time from the system clock.
// On success, set *t and *info (if not NULL), and return 0.
// On error, raise an exception and return -1.
extern int _PyTime_GetSystemClockWithInfo(
extern int _PyTime_TimeWithInfo(
PyTime_t *t,
_Py_clock_info_t *info);

// Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
// The clock is not affected by system clock updates. The reference point of
// the returned value is undefined, so that only the difference between the
// results of consecutive calls is valid.
// Similar to PyTime_Monotonic() but silently ignore the error and return 0 if
// the internal clock fails.
//
// If the internal clock fails, silently ignore the error and return 0.
// On integer overflow, silently ignore the overflow and clamp the clock to
// [_PyTime_MIN; _PyTime_MAX].
//
// Use _PyTime_GetMonotonicClockWithInfo or the public PyTime_Monotonic()
// Use _PyTime_MonotonicWithInfo() or the public PyTime_Monotonic()
// to check for failure.
// Export for '_random' shared extension.
PyAPI_FUNC(PyTime_t) _PyTime_GetMonotonicClock(void);
PyAPI_FUNC(PyTime_t) _PyTime_MonotonicUnchecked(void);

// Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
// The clock is not affected by system clock updates. The reference point of
Expand All @@ -294,7 +284,7 @@ PyAPI_FUNC(PyTime_t) _PyTime_GetMonotonicClock(void);
//
// Return 0 on success, raise an exception and return -1 on error.
// Export for '_testsinglephase' shared extension.
PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo(
PyAPI_FUNC(int) _PyTime_MonotonicWithInfo(
PyTime_t *t,
_Py_clock_info_t *info);

Expand All @@ -309,17 +299,13 @@ PyAPI_FUNC(int) _PyTime_localtime(time_t t, struct tm *tm);
// Export for '_datetime' shared extension.
PyAPI_FUNC(int) _PyTime_gmtime(time_t t, struct tm *tm);

// Get the performance counter: clock with the highest available resolution to
// measure a short duration.
// Similar to PyTime_PerfCounter() but silently ignore the error and return 0
// if the internal clock fails.
//
// If the internal clock fails, silently ignore the error and return 0.
// On integer overflow, silently ignore the overflow and clamp the clock to
// [_PyTime_MIN; _PyTime_MAX].
//
// Use _PyTime_GetPerfCounterWithInfo() or the public PyTime_PerfCounter
// to check for failure.
// Use _PyTime_PerfCounterWithInfo() or the public PyTime_PerfCounter() to
// check for failure.
// Export for '_lsprof' shared extension.
PyAPI_FUNC(PyTime_t) _PyTime_GetPerfCounter(void);
PyAPI_FUNC(PyTime_t) _PyTime_PerfCounterUnchecked(void);


// Get the performance counter: clock with the highest available resolution to
Expand All @@ -328,7 +314,7 @@ PyAPI_FUNC(PyTime_t) _PyTime_GetPerfCounter(void);
// Fill info (if set) with information of the function used to get the time.
//
// Return 0 on success, raise an exception and return -1 on error.
extern int _PyTime_GetPerfCounterWithInfo(
extern int _PyTime_PerfCounterWithInfo(
PyTime_t *t,
_Py_clock_info_t *info);

Expand All @@ -341,12 +327,12 @@ extern int _PyTime_GetPerfCounterWithInfo(
// --- _PyDeadline -----------------------------------------------------------

// Create a deadline.
// Pseudo code: _PyTime_GetMonotonicClock() + timeout.
// Pseudo code: _PyTime_MonotonicUnchecked() + timeout.
// Export for '_ssl' shared extension.
PyAPI_FUNC(PyTime_t) _PyDeadline_Init(PyTime_t timeout);

// Get remaining time from a deadline.
// Pseudo code: deadline - _PyTime_GetMonotonicClock().
// Pseudo code: deadline - _PyTime_MonotonicUnchecked().
// Export for '_ssl' shared extension.
PyAPI_FUNC(PyTime_t) _PyDeadline_Get(PyTime_t deadline);

Expand Down
5 changes: 5 additions & 0 deletions Lib/test/list_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,8 @@ def test_exhausted_iterator(self):
self.assertEqual(list(exhit), [])
self.assertEqual(list(empit), [9])
self.assertEqual(a, self.type2test([1, 2, 3, 9]))

# gh-115733: Crash when iterating over exhausted iterator
exhit = iter(self.type2test([1, 2, 3]))
for _ in exhit:
next(exhit, 1)
Loading

0 comments on commit 230e321

Please sign in to comment.