Skip to content

Commit 700ffee

Browse files
committed
Merge branch 'main' into fix-py-debug-sysconfig
2 parents a7099b9 + 1e3ec33 commit 700ffee

16 files changed

+235
-240
lines changed

Doc/library/uuid.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,29 @@ which relays any information about the UUID's safety, using this enumeration:
103103
- Meaning
104104

105105
* - .. attribute:: UUID.time_low
106-
- The first 32 bits of the UUID.
106+
- The first 32 bits of the UUID. Only relevant to version 1.
107107

108108
* - .. attribute:: UUID.time_mid
109-
- The next 16 bits of the UUID.
109+
- The next 16 bits of the UUID. Only relevant to version 1.
110110

111111
* - .. attribute:: UUID.time_hi_version
112-
- The next 16 bits of the UUID.
112+
- The next 16 bits of the UUID. Only relevant to version 1.
113113

114114
* - .. attribute:: UUID.clock_seq_hi_variant
115-
- The next 8 bits of the UUID.
115+
- The next 8 bits of the UUID. Only relevant to versions 1 and 6.
116116

117117
* - .. attribute:: UUID.clock_seq_low
118-
- The next 8 bits of the UUID.
118+
- The next 8 bits of the UUID. Only relevant to versions 1 and 6.
119119

120120
* - .. attribute:: UUID.node
121-
- The last 48 bits of the UUID.
121+
- The last 48 bits of the UUID. Only relevant to version 1.
122122

123123
* - .. attribute:: UUID.time
124-
- The 60-bit timestamp.
124+
- The 60-bit timestamp for version 1 and 6,
125+
or the 48-bit timestamp for version 7.
125126

126127
* - .. attribute:: UUID.clock_seq
127-
- The 14-bit sequence number.
128+
- The 14-bit sequence number. Only relevant to versions 1 and 6.
128129

129130

130131
.. attribute:: UUID.hex

Lib/functools.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -516,22 +516,6 @@ def _unwrap_partialmethod(func):
516516

517517
_CacheInfo = namedtuple("CacheInfo", ["hits", "misses", "maxsize", "currsize"])
518518

519-
class _HashedSeq(list):
520-
""" This class guarantees that hash() will be called no more than once
521-
per element. This is important because the lru_cache() will hash
522-
the key multiple times on a cache miss.
523-
524-
"""
525-
526-
__slots__ = 'hashvalue'
527-
528-
def __init__(self, tup, hash=hash):
529-
self[:] = tup
530-
self.hashvalue = hash(tup)
531-
532-
def __hash__(self):
533-
return self.hashvalue
534-
535519
def _make_key(args, kwds, typed,
536520
kwd_mark = (object(),),
537521
fasttypes = {int, str},
@@ -561,7 +545,7 @@ def _make_key(args, kwds, typed,
561545
key += tuple(type(v) for v in kwds.values())
562546
elif len(key) == 1 and type(key[0]) in fasttypes:
563547
return key[0]
564-
return _HashedSeq(key)
548+
return key
565549

566550
def lru_cache(maxsize=128, typed=False):
567551
"""Least-recently-used cache decorator.

Lib/test/test_generated_cases.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ def test_effect_sizes(self):
6868
StackItem("b", None, "oparg*4"),
6969
StackItem("c", None, "1"),
7070
]
71-
stack.pop(z)
72-
stack.pop(y)
73-
stack.pop(x)
71+
null = CWriter.null()
72+
stack.pop(z, null)
73+
stack.pop(y, null)
74+
stack.pop(x, null)
7475
for out in outputs:
7576
stack.push(Local.undefined(out))
7677
self.assertEqual(stack.base_offset.to_c(), "-1 - oparg - oparg*2")
77-
self.assertEqual(stack.top_offset.to_c(), "1 - oparg - oparg*2 + oparg*4")
78+
self.assertEqual(stack.physical_sp.to_c(), "0")
79+
self.assertEqual(stack.logical_sp.to_c(), "1 - oparg - oparg*2 + oparg*4")
7880

7981

8082
class TestGeneratedCases(unittest.TestCase):

Lib/test/test_uuid.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ def test_uuid7(self):
913913
equal(self.uuid._last_counter_v7, counter)
914914

915915
unix_ts_ms = timestamp_ms & 0xffff_ffff_ffff
916+
equal(u.time, unix_ts_ms)
916917
equal((u.int >> 80) & 0xffff_ffff_ffff, unix_ts_ms)
917918

918919
equal((u.int >> 75) & 1, 0) # check that the MSB is 0
@@ -966,6 +967,7 @@ def test_uuid7_monotonicity(self):
966967
urand.assert_called_once_with(10)
967968
equal(self.uuid._last_timestamp_v7, timestamp_ms)
968969
equal(self.uuid._last_counter_v7, counter)
970+
equal(u1.time, timestamp_ms)
969971
equal((u1.int >> 64) & 0xfff, counter_hi)
970972
equal((u1.int >> 32) & 0x3fff_ffff, counter_lo)
971973
equal(u1.int & 0xffff_ffff, tail)
@@ -988,6 +990,7 @@ def test_uuid7_monotonicity(self):
988990
equal(self.uuid._last_timestamp_v7, timestamp_ms)
989991
# 42-bit counter advanced by 1
990992
equal(self.uuid._last_counter_v7, counter + 1)
993+
equal(u2.time, timestamp_ms)
991994
equal((u2.int >> 64) & 0xfff, counter_hi)
992995
equal((u2.int >> 32) & 0x3fff_ffff, counter_lo + 1)
993996
equal(u2.int & 0xffff_ffff, next_fail)
@@ -1025,6 +1028,7 @@ def test_uuid7_timestamp_backwards(self):
10251028
equal(u.version, 7)
10261029
equal(self.uuid._last_timestamp_v7, fake_last_timestamp_v7 + 1)
10271030
unix_ts_ms = (fake_last_timestamp_v7 + 1) & 0xffff_ffff_ffff
1031+
equal(u.time, unix_ts_ms)
10281032
equal((u.int >> 80) & 0xffff_ffff_ffff, unix_ts_ms)
10291033
# 42-bit counter advanced by 1
10301034
equal(self.uuid._last_counter_v7, counter + 1)
@@ -1064,6 +1068,7 @@ def test_uuid7_overflow_counter(self):
10641068
# timestamp advanced due to overflow
10651069
equal(self.uuid._last_timestamp_v7, timestamp_ms + 1)
10661070
unix_ts_ms = (timestamp_ms + 1) & 0xffff_ffff_ffff
1071+
equal(u.time, unix_ts_ms)
10671072
equal((u.int >> 80) & 0xffff_ffff_ffff, unix_ts_ms)
10681073
# counter overflowed, so we picked a new one
10691074
equal(self.uuid._last_counter_v7, new_counter)

Lib/uuid.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,16 @@ class UUID:
134134
135135
fields a tuple of the six integer fields of the UUID,
136136
which are also available as six individual attributes
137-
and two derived attributes. The time_* attributes are
138-
only relevant to version 1, while the others are only
139-
relevant to versions 1 and 6:
137+
and two derived attributes. Those attributes are not
138+
always relevant to all UUID versions:
139+
140+
The 'time_*' attributes are only relevant to version 1.
141+
142+
The 'clock_seq*' and 'node' attributes are only relevant
143+
to versions 1 and 6.
144+
145+
The 'time' attribute is only relevant to versions 1, 6
146+
and 7.
140147
141148
time_low the first 32 bits of the UUID
142149
time_mid the next 16 bits of the UUID
@@ -145,7 +152,8 @@ class UUID:
145152
clock_seq_low the next 8 bits of the UUID
146153
node the last 48 bits of the UUID
147154
148-
time the 60-bit timestamp
155+
time the 60-bit timestamp for UUIDv1/v6,
156+
or the 48-bit timestamp for UUIDv7
149157
clock_seq the 14-bit sequence number
150158
151159
hex the UUID as a 32-character hexadecimal string
@@ -366,6 +374,9 @@ def time(self):
366374
time_hi = self.int >> 96
367375
time_lo = (self.int >> 64) & 0x0fff
368376
return time_hi << 28 | (self.time_mid << 12) | time_lo
377+
elif self.version == 7:
378+
# unix_ts_ms (48) | ... (80)
379+
return self.int >> 80
369380
else:
370381
# time_lo (32) | time_mid (16) | ver (4) | time_hi (12) | ... (64)
371382
#

Python/ast_opt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ typedef struct {
2121
int ff_features;
2222
int syntax_check_only;
2323

24-
_Py_c_array_t cf_finally; /* context for PEP 678 check */
24+
_Py_c_array_t cf_finally; /* context for PEP 765 check */
2525
int cf_finally_used;
2626
} _PyASTOptimizeState;
2727

Python/bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ dummy_func(
14841484
(void)counter;
14851485
}
14861486

1487-
op(_UNPACK_SEQUENCE, (seq -- output[oparg], top[0])) {
1487+
op(_UNPACK_SEQUENCE, (seq -- unused[oparg], top[0])) {
14881488
PyObject *seq_o = PyStackRef_AsPyObjectSteal(seq);
14891489
int res = _PyEval_UnpackIterableStackRef(tstate, seq_o, oparg, -1, top);
14901490
Py_DECREF(seq_o);
@@ -1533,7 +1533,7 @@ dummy_func(
15331533
DECREF_INPUTS();
15341534
}
15351535

1536-
inst(UNPACK_EX, (seq -- left[oparg & 0xFF], unused, right[oparg >> 8], top[0])) {
1536+
inst(UNPACK_EX, (seq -- unused[oparg & 0xFF], unused, unused[oparg >> 8], top[0])) {
15371537
PyObject *seq_o = PyStackRef_AsPyObjectSteal(seq);
15381538
int res = _PyEval_UnpackIterableStackRef(tstate, seq_o, oparg & 0xFF, oparg >> 8, top);
15391539
Py_DECREF(seq_o);

Python/generated_cases.c.h

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/cases_generator/cwriter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import contextlib
22
from lexer import Token
33
from typing import TextIO, Iterator
4-
4+
from io import StringIO
55

66
class CWriter:
77
"A writer that understands tokens and how to format C code"
@@ -18,6 +18,10 @@ def __init__(self, out: TextIO, indent: int, line_directives: bool):
1818
self.pending_spill = False
1919
self.pending_reload = False
2020

21+
@staticmethod
22+
def null() -> "CWriter":
23+
return CWriter(StringIO(), 0, False)
24+
2125
def set_position(self, tkn: Token) -> None:
2226
if self.last_token is not None:
2327
if self.last_token.end_line < tkn.line:

Tools/cases_generator/generators_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ def error_if(
205205
next(tkn_iter) # Semi colon
206206
storage.clear_inputs("at ERROR_IF")
207207

208-
c_offset = storage.stack.peek_offset()
208+
c_offset = storage.stack.sp_offset()
209209
try:
210-
offset = -int(c_offset)
210+
offset = int(c_offset)
211211
except ValueError:
212212
offset = -1
213213
self.out.emit(self.goto_error(offset, label, storage))

0 commit comments

Comments
 (0)