8000 Merge branch 'main' into wrapping · python/cpython@34bac84 · GitHub
[go: up one dir, main page]

Skip to content

Commit 34bac84

Browse files
authored
Merge branch 'main' into wrapping
2 parents 3e8f08c + 86aa8a5 commit 34bac84

33 files changed

+672
-409
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ jobs:
308308
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
309309
- name: Install Dependencies
310310
run: sudo ./.github/workflows/posix-deps-apt.sh
311+
- name: Set up GCC-10 for ASAN
312+
uses: egor-tensin/setup-gcc@v1
313+
with:
314+
version: 10
311315
- name: Configure OpenSSL env vars
312316
run: |
313317
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> $GITHUB_ENV

Doc/library/tempfile.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ The module defines the following user-callable items:
292292
.. versionchanged:: 3.6
293293
The *dir* parameter now accepts a :term:`path-like object`.
294294

295+
.. versionchanged:: 3.12
296+
:func:`mkdtemp` now always returns an absolute path, even if *dir* is relative.
297+
295298

296299
.. function:: gettempdir()
297300

Doc/library/types.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,13 @@ Standard names are defined for the following types:
351351
.. versionchanged:: 3.9.2
352352
This type can now be subclassed.
353353

354+
.. seealso::
355+
356+
:ref:`Generic Alias Types<types-genericalias>`
357+
In-depth documentation on instances of :class:`!types.GenericAlias`
358+
359+
:pep:`585` - Type Hinting Generics In Standard Collections
360+
Introducing the :class:`!types.GenericAlias` class
354361

355362
.. class:: UnionType
356363

Doc/using/unix.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ On FreeBSD and OpenBSD
5454
pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/python-2.5.1p2.tgz
5555

5656

57-
On OpenSolaris
58-
--------------
59-
F438
60-
You can get Python from `OpenCSW <https://www.opencsw.org/>`_. Various versions
61-
of Python are available and can be installed with e.g. ``pkgutil -i python27``.
62-
63-
6457
.. _building-python-on-unix:
6558

6659
Building Python

Doc/whatsnew/3.12.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,10 @@ uuid
457457
tempfile
458458
--------
459459

460-
The :class:`tempfile.NamedTemporaryFile` function has a new optional parameter
461-
*delete_on_close* (Contributed by Evgeny Zorin in :gh:`58451`.)
460+
* The :class:`tempfile.NamedTemporaryFile` function has a new optional parameter
461+
*delete_on_close* (Contributed by Evgeny Zorin in :gh:`58451`.)
462+
* :func:`tempfile.mkdtemp` now always returns an absolute path, even if the
463+
argument provided to the *dir* parameter is a relative path.
462464

463465
.. _whatsnew-typing-py312:
464466

Include/internal/pycore_code.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ typedef struct {
5151

5252
#define INLINE_CACHE_ENTRIES_BINARY_SUBSCR CACHE_ENTRIES(_PyBinarySubscrCache)
5353

54+
typedef struct {
55+
uint16_t counter;
56+
uint16_t class_version[2];
57+
uint16_t self_type_version[2];
58+
uint16_t method[4];
59+
} _PySuperAttrCache;
60+
61+
#define INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR CACHE_ENTRIES(_PySuperAttrCache)
62+
5463
typedef struct {
5564
uint16_t counter;
5665
uint16_t version[2];
@@ -217,6 +226,8 @@ extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
217226

218227
/* Specialization functions */
219228

229+
extern void _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *class, PyObject *self,
230+
_Py_CODEUNIT *instr, PyObject *name, int load_method);
220231
extern void _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr,
221232
PyObject *name);
222233
extern void _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr,

Include/internal/pycore_import.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ struct _import_runtime_state {
1919
used exclusively for when the extensions dict is access/modified
2020
from an arbitrary thread. */
2121
PyThreadState main_tstate;
22+
/* A lock to guard the dict. */
23+
PyThread_type_lock mutex;
2224
/* A dict mapping (filename, name) to PyModuleDef for modules.
2325
Only legacy (single-phase init) extension modules are added
2426
and only if they support multiple initialization (m_size >- 0)

Include/internal/pycore_opcode.h

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

Include/internal/pycore_typeobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ PyObject *_Py_slot_tp_getattr_hook(PyObject *self, PyObject *name);
119119

120120
PyObject *
121121
_PySuper_Lookup(PyTypeObject *su_type, PyObject *su_obj, PyObject *name, int *meth_found);
122+
PyObject *
123+
_PySuper_LookupDescr(PyTypeObject *su_type, PyObject *su_obj, PyObject *name);
122124

123125
#ifdef __cplusplus
124126
}

Include/opcode.h

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

Lib/calendar.py

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import sys
99
import datetime
10+
from enum import IntEnum, global_enum
1011
import locale as _locale
1112
from itertools import repeat
1213

@@ -16,6 +17,9 @@
1617
"timegm", "month_name", "month_abbr", "day_name", "day_abbr",
1718
"Calendar", "TextCalendar", "HTMLCalendar", "LocaleTextCalendar",
1819
"LocaleHTMLCalendar", "weekheader",
20+
"Day", "Month", "JANUARY", "FEBRUARY", "MARCH",
21+
"APRIL", "MAY", "JUNE", "JULY",
22+
"AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER",
1923
"MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY",
2024
"SATURDAY", "SUNDAY"]
2125

@@ -37,9 +41,35 @@ def __str__(self):
3741
return "bad weekday number %r; must be 0 (Monday) to 6 (Sunday)" % self.weekday
3842

3943

40-
# Constants for months referenced later
41-
January = 1
42-
February = 2
44+
# Constants for months
45+
@global_enum
46+
class Month(IntEnum):
47+
JANUARY = 1
48+
FEBRUARY = 2
49+
MARCH = 3
50+
APRIL = 4
51+
MAY = 5
52+
JUNE = 6
53+
JULY = 7
54+
AUGUST = 8
55+
SEPTEMBER = 9
56+
OCTOBER = 10
57+
NOVEMBER = 11
58+
DECEMBER = 12
59+
60+
61+
# Constants for days
62+
@global_enum
63+
class Day(IntEnum):
64+
MONDAY = 0
65+
TUESDAY = 1
66+
WEDNESDAY = 2
67+
THURSDAY = 3
68+
FRIDAY = 4
69+
SATURDAY = 5
70+
SUNDAY = 6
71+
72+
4373

4474
# Number of days per month (except for February in leap years)
4575
mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
@@ -95,9 +125,6 @@ def __len__(self):
95125
month_name = _localized_month('%B')
96126
month_abbr = _localized_month('%b')
97127

98-
# Constants for weekdays
99-
(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) = range(7)
100-
101128

102129
def isleap(year):
103130
"""Return True for leap years, False for non-leap years."""
@@ -125,12 +152,12 @@ def monthrange(year, month):
125152
if not 1 <= month <= 12:
126153
raise IllegalMonthError(month)
127154
day1 = weekday(year, month, 1)
128-
ndays = mdays[month] + (month == February and isleap(year))
155+
ndays = mdays[month] + (month == FEBRUARY and isleap(year))
129156
return day1, ndays
130157

131158

132159
def _monthlen(year, month):
133-
return mdays[month] + (month == February and isleap(year))
160+
return mdays[month] + (month == FEBRUARY and isleap(year))
134161

135162

136163
def _prevmonth(year, month):
@@ -260,10 +287,7 @@ def yeardatescalendar(self, year, width=3):
260287
Each month contains between 4 and 6 weeks and each week contains 1-7
261288
days. Days are datetime.date objects.
262289
"""
263-
months = [
264-
self.monthdatescalendar(year, i)
265-
for i in range(January, January+12)
266-
]
290+
months = [self.monthdatescalendar(year, m) for m in Month]
267291
return [months[i:i+width] for i in range(0, len(months), width) ]
268292

269293
def yeardays2calendar(self, year, width=3):
@@ -273,10 +297,7 @@ def yeardays2calendar(self, year, width=3):
273297
(day number, weekday number) tuples. Day numbers outside this month are
274298
zero.
275299
"""
276-
months = [
277-
self.monthdays2calendar(year, i)
278-
for i in range(January, January+12)
279-
]
300+
months = [self.monthdays2calendar(year, m) for m in Month]
280301
return [months[i:i+width] for i in range(0, len(months), width) ]
281302

282303
def yeardayscalendar(self, year, width=3):
@@ -285,10 +306,7 @@ def yeardayscalendar(self, year, width=3):
285306
yeardatescalendar()). Entries in the week lists are day numbers.
286307
Day numbers outside this month are zero.
287308
"""
288-
months = [
289-
self.monthdayscalendar(year, i)
290-
for i in range(January, January+12)
291-
]
309+
months = [self.monthdayscalendar(year, m) for m in Month]
292310
return [months[i:i+width] for i in range(0, len(months), width) ]
293311

294312

@@ -509,7 +527,7 @@ def formatyear(self, theyear, width=3):
509527
a('\n')
510528
a('<tr><th colspan="%d" class="%s">%s</th></tr>' % (
511529
width, self.cssclass_year_head, theyear))
512-
for i in range(January, January+12, width):
530+
for i in range(JANUARY, JANUARY+12, width):
513531
# months in this row
514532
months = range(i, min(i+width, 13))
515533
a('<tr>')

0 commit comments

Comments
 (0)
0