Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bcaeb4c

Browse filesBrowse files
authored
Merge branch 'main' into email-message-import
2 parents c5e7a61 + 4227bfa commit bcaeb4c
Copy full SHA for bcaeb4c

File tree

Expand file treeCollapse file tree

6 files changed

+103
-20
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+103
-20
lines changed

‎Doc/library/sqlite3.rst

Copy file name to clipboardExpand all lines: Doc/library/sqlite3.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,9 +2437,9 @@ or if :attr:`~Connection.autocommit` is ``True``,
24372437
the context manager does nothing.
24382438

24392439
.. note::
2440-
24412440
The context manager neither implicitly opens a new transaction
2442-
nor closes the connection.
2441+
nor closes the connection. If you need a closing context manager, consider
2442+
using :meth:`contextlib.closing`.
24432443

24442444
.. testcode::
24452445

‎Doc/requirements-oldest-sphinx.txt

Copy file name to clipboardExpand all lines: Doc/requirements-oldest-sphinx.txt
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ python-docs-theme>=2022.1
1313
# Sphinx 4.2 comes from ``needs_sphinx = '4.2'`` in ``Doc/conf.py``.
1414

1515
alabaster==0.7.13
16-
Babel==2.12.1
16+
Babel==2.13.0
1717
certifi==2023.7.22
18-
charset-normalizer==3.2.0
18+
charset-normalizer==3.3.0
1919
colorama==0.4.6
20-
docutils==0.16
20+
docutils==0.17.1
2121
idna==3.4
2222
imagesize==1.4.1
23-
Jinja2==2.11.3
24-
MarkupSafe==1.1.1
25-
packaging==23.1
23+
Jinja2==3.1.2
24+
MarkupSafe==2.1.3
25+
packaging==23.2
2626
Pygments==2.16.1
2727
requests==2.31.0
2828
snowballstemmer==2.2.0
@@ -33,4 +33,4 @@ sphinxcontrib-htmlhelp==2.0.1
3333
sphinxcontrib-jsmath==1.0.1
3434
sphinxcontrib-qthelp==1.0.3
3535
sphinxcontrib-serializinghtml==1.1.5
36-
urllib3==2.0.4
36+
urllib3==2.0.6

‎Lib/test/libregrtest/pgo.py

Copy file name to clipboardExpand all lines: Lib/test/libregrtest/pgo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
'test_set',
4343
'test_sqlite3',
4444
'test_statistics',
45+
'test_str',
4546
'test_struct',
4647
'test_tabnanny',
4748
'test_time',
48-
'test_unicode',
4949
'test_xml_etree',
5050
'test_xml_etree_c',
5151
]

‎Lib/test/test_copy.py

Copy file name to clipboardExpand all lines: Lib/test/test_copy.py
+18-8Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -936,14 +936,24 @@ def __replace__(self, **changes):
936936

937937
def test_namedtuple(self):
938938
from collections import namedtuple
939-
Point = namedtuple('Point', 'x y', defaults=(0,))
940-
p = Point(11, 22)
941-
self.assertEqual(copy.replace(p), (11, 22))
942-
self.assertEqual(copy.replace(p, x=1), (1, 22))
943-
self.assertEqual(copy.replace(p, y=2), (11, 2))
944-
self.assertEqual(copy.replace(p, x=1, y=2), (1, 2))
945-
with self.assertRaisesRegex(ValueError, 'unexpected field name'):
946-
copy.replace(p, x=1, error=2)
939+
from typing import NamedTuple
940+
PointFromCall = namedtuple('Point', 'x y', defaults=(0,))
941+
class PointFromInheritance(PointFromCall):
942+
pass
943+
class PointFromClass(NamedTuple):
944+
x: int
945+
y: int = 0
946+
for Point in (PointFromCall, PointFromInheritance, PointFromClass):
947+
with self.subTest(Point=Point):
948+
p = Point(11, 22)
949+
self.assertIsInstance(p, Point)
950+
self.assertEqual(copy.replace(p), (11, 22))
951+
self.assertIsInstance(copy.replace(p), Point)
952+
self.assertEqual(copy.replace(p, x=1), (1, 22))
953+
self.assertEqual(copy.replace(p, y=2), (11, 2))
954+
self.assertEqual(copy.replace(p, x=1, y=2), (1, 2))
955+
with self.assertRaisesRegex(ValueError, 'unexpected field name'):
956+
copy.replace(p, x=1, error=2)
947957

948958
def test_dataclass(self):
949959
from dataclasses import dataclass

‎Lib/test/test_structseq.py

Copy file name to clipboardExpand all lines: Lib/test/test_structseq.py
+73-2Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import copy
12
import os
3+
import pickle
24
import time
35
import unittest
46

@@ -106,9 +108,78 @@ def __len__(self):
106108

107109
self.assertRaises(Exc, time.struct_time, C())
108110

109-
def test_reduce(self):
111+
def test_pickling(self):
110112
t = time.gmtime()
111-
x = t.__reduce__()
113+
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
114+
p = pickle.dumps(t, proto)
115+
t2 = pickle.loads(p)
116+
self.assertEqual(t2.__class__, t.__class__)
117+
self.assertEqual(t2, t)
118+
self.assertEqual(t2.tm_year, t.tm_year)
119+
self.assertEqual(t2.tm_zone, t.tm_zone)
120+
121+
def test_pickling_with_unnamed_fields(self):
122+
assert os.stat_result.n_unnamed_fields > 0
123+
124+
r = os.stat_result(range(os.stat_result.n_sequence_fields),
125+
{'st_atime': 1.0, 'st_atime_ns': 2.0})
126+
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
127+
p = pickle.dumps(r, proto)
128+
r2 = pickle.loads(p)
129+
self.assertEqual(r2.__class__, r.__class__)
130+
self.assertEqual(r2, r)
131+
self.assertEqual(r2.st_mode, r.st_mode)
132+
self.assertEqual(r2.st_atime, r.st_atime)
133+
self.assertEqual(r2.st_atime_ns, r.st_atime_ns)
134+
135+
def test_copying(self):
136+
n_fields = time.struct_time.n_fields
137+
t = time.struct_time([[i] for i in range(n_fields)])
138+
139+
t2 = copy.copy(t)
140+
self.assertEqual(t2.__class__, t.__class__)
141+
self.assertEqual(t2, t)
142+
self.assertEqual(t2.tm_year, t.tm_year)
143+
self.assertEqual(t2.tm_zone, t.tm_zone)
144+
self.assertIs(t2[0], t[0])
145+
self.assertIs(t2.tm_year, t.tm_year)
146+
147+
t3 = copy.deepcopy(t)
148+
self.assertEqual(t3.__class__, t.__class__)
149+
self.assertEqual(t3, t)
150+
self.assertEqual(t3.tm_year, t.tm_year)
151+
self.assertEqual(t3.tm_zone, t.tm_zone)
152+
self.assertIsNot(t3[0], t[0])
153+
self.assertIsNot(t3.tm_year, t.tm_year)
154+
155+
def test_copying_with_unnamed_fields(self):
156+
assert os.stat_result.n_unnamed_fields > 0
157+
158+
n_sequence_fields = os.stat_result.n_sequence_fields
159+
r = os.stat_result([[i] for i in range(n_sequence_fields)],
160+
{'st_atime': [1.0], 'st_atime_ns': [2.0]})
161+
162+
r2 = copy.copy(r)
163+
self.assertEqual(r2.__class__, r.__class__)
164+
self.assertEqual(r2, r)
165+
self.assertEqual(r2.st_mode, r.st_mode)
166+
self.assertEqual(r2.st_atime, r.st_atime)
167+
self.assertEqual(r2.st_atime_ns, r.st_atime_ns)
168+
self.assertIs(r2[0], r[0])
169+
self.assertIs(r2.st_mode, r.st_mode)
170+
self.assertIs(r2.st_atime, r.st_atime)
171+
self.assertIs(r2.st_atime_ns, r.st_atime_ns)
172+
173+
r3 = copy.deepcopy(r)
174+
self.assertEqual(r3.__class__, r.__class__)
175+
self.assertEqual(r3, r)
176+
self.assertEqual(r3.st_mode, r.st_mode)
177+
self.assertEqual(r3.st_atime, r.st_atime)
178+
self.assertEqual(r3.st_atime_ns, r.st_atime_ns)
179+
self.assertIsNot(r3[0], r[0])
180+
self.assertIsNot(r3.st_mode, r.st_mode)
181+
self.assertIsNot(r3.st_atime, r.st_atime)
182+
self.assertIsNot(r3.st_atime_ns, r.st_atime_ns)
112183

113184
def test_extended_getslice(self):
114185
# Test extended slicing by comparing with list slicing.
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add tests for pickling and copying PyStructSequence objects.
2+
Patched by Xuehai Pan.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.