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

Skip to content

Commit d9a81f2

Browse files
authored
Merge branch 'main' into return_in_while
2 parents b4c0df2 + 5055300 commit d9a81f2

8 files changed

+45
-33
lines changed

Doc/requirements.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ sphinx==4.5.0
77

88
blurb
99

10-
# sphinx-lint 0.6.2 yields many default role errors due to the new regular
11-
# expression used for default role detection, so we don't use the version
12-
# until the errors are fixed.
13-
sphinx-lint==0.6.5
10+
sphinx-lint==0.6.7
1411

1512
# The theme used by the documentation is stored separately, so we need
1613
# to install that as well.

Lib/test/_test_multiprocessing.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5698,45 +5698,48 @@ def test_joinable_queue(self):
56985698

56995699
@classmethod
57005700
def _test_list(cls, obj):
5701-
assert obj[0] == 5
5702-
assert obj.count(5) == 1
5703-
assert obj.index(5) == 0
5701+
case = unittest.TestCase()
5702+
case.assertEqual(obj[0], 5)
5703+
case.assertEqual(obj.count(5), 1)
5704+
case.assertEqual(obj.index(5), 0)
57045705
obj.sort()
57055706
obj.reverse()
57065707
for x in obj:
57075708
pass
5708-
assert len(obj) == 1
5709-
assert obj.pop(0) == 5
5709+
case.assertEqual(len(obj), 1)
5710+
case.assertEqual(obj.pop(0), 5)
57105711

57115712
def test_list(self):
57125713
o = self.manager.list()
57135714
o.append(5)
57145715
self.run_worker(self._test_list, o)
5715-
assert not o
5716+
self.assertIsNotNone(o)
57165717
self.assertEqual(len(o), 0)
57175718

57185719
@classmethod
57195720
def _test_dict(cls, obj):
5720-
assert len(obj) == 1
5721-
assert obj['foo'] == 5
5722-
assert obj.get('foo') == 5
5723-
assert list(obj.items()) == [('foo', 5)]
5724-
assert list(obj.keys()) == ['foo']
5725-
assert list(obj.values()) == [5]
5726-
assert obj.copy() == {'foo': 5}
5727-
assert obj.popitem() == ('foo', 5)
5721+
case = unittest.TestCase()
5722+
case.assertEqual(len(obj), 1)
5723+
case.assertEqual(obj['foo'], 5)
5724+
case.assertEqual(obj.get('foo'), 5)
5725+
case.assertListEqual(list(obj.items()), [('foo', 5)])
5726+
case.assertListEqual(list(obj.keys()), ['foo'])
5727+
case.assertListEqual(list(obj.values()), [5])
5728+
case.assertDictEqual(obj.copy(), {'foo': 5})
5729+
case.assertTupleEqual(obj.popitem(), ('foo', 5))
57285730

57295731
def test_dict(self):
57305732
o = self.manager.dict()
57315733
o['foo'] = 5
57325734
self.run_worker(self._test_dict, o)
5733-
assert not o
5735+
self.assertIsNotNone(o)
57345736
self.assertEqual(len(o), 0)
57355737

57365738
@classmethod
57375739
def _test_value(cls, obj):
5738-
assert obj.value == 1
5739-
assert obj.get() == 1
5740+
case = unittest.TestCase()
5741+
case.assertEqual(obj.value, 1)
5742+
case.assertEqual(obj.get(), 1)
57405743
obj.set(2)
57415744

57425745
def test_value(self):
@@ -5747,19 +5750,21 @@ def test_value(self):
57475750

57485751
@classmethod
57495752
def _test_array(cls, obj):
5750-
assert obj[0] == 0
5751-
assert obj[1] == 1
5752-
assert len(obj) == 2
5753-
assert list(obj) == [0, 1]
5753+
case = unittest.TestCase()
5754+
case.assertEqual(obj[0], 0)
5755+
case.assertEqual(obj[1], 1)
5756+
case.assertEqual(len(obj), 2)
5757+
case.assertListEqual(list(obj), [0, 1])
57545758

57555759
def test_array(self):
57565760
o = self.manager.Array('i', [0, 1])
57575761
self.run_worker(self._test_array, o)
57585762

57595763
@classmethod
57605764
def _test_namespace(cls, obj):
5761-
assert obj.x == 0
5762-
assert obj.y == 1
5765+
case = unittest.TestCase()
5766+
case.assertEqual(obj.x, 0)
5767+
case.assertEqual(obj.y, 1)
57635768

57645769
def test_namespace(self):
57655770
o = self.manager.Namespace()

Lib/test/test_py_compile.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,12 @@ def pycompilecmd(self, *args, **kwargs):
235235
# assert_python_* helpers don't return proc object. We'll just use
236236
# subprocess.run() instead of spawn_python() and its friends to test
237237
# stdin support of the CLI.
238+
opts = '-m' if __debug__ else '-Om'
238239
if args and args[0] == '-' and 'input' in kwargs:
239-
return subprocess.run([sys.executable, '-m', 'py_compile', '-'],
240+
return subprocess.run([sys.executable, opts, 'py_compile', '-'],
240241
input=kwargs['input'].encode(),
241242
capture_output=True)
242-
return script_helper.assert_python_ok('-m', 'py_compile', *args, **kwargs)
243+
return script_helper.assert_python_ok(opts, 'py_compile', *args, **kwargs)
243244

244245
def pycompilecmd_failure(self, *args):
245246
return script_helper.assert_python_failure('-m', 'py_compile', *args)

Lib/wsgiref/handlers.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ def start_response(self, status, headers,exc_info=None):
237237
self.status = status
238238
self.headers = self.headers_class(headers)
239239
status = self._convert_string_type(status, "Status")
240-
assert len(status)>=4,"Status must be at least 4 characters"
241-
assert status[:3].isdigit(), "Status message must begin w/3-digit code"
242-
assert status[3]==" ", "Status message must have a space after code"
240+
self._validate_status(status)
243241

244242
if __debug__:
245243
for name, val in headers:
@@ -250,6 +248,14 @@ def start_response(self, status, headers,exc_info=None):
250248

251249
return self.write
252250

251+
def _validate_status(self, status):
252+
if len(status) < 4:
253+
raise AssertionError("Status must be at least 4 characters")
254+
if not status[:3].isdigit():
255+
raise AssertionError("Status message must begin w/3-digit code")
256+
if status[3] != " ":
257+
raise AssertionError("Status message must have a space after code")
258+
253259
def _convert_string_type(self, value, title):
254260
"""Convert/check value type."""
255261
if type(value) is str:
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Python again uses C-style casts for most casting operations when compiled
22
with C++. This may trigger compiler warnings, if they are enabled with e.g.
3-
``-Wold-style-cast `` or ``-Wzero-as-null-pointer-constant`` options for ``g++``.
3+
``-Wold-style-cast`` or ``-Wzero-as-null-pointer-constant`` options for ``g++``.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace ``assert`` statements with ``raise AssertionError()`` in :class:`~wsgiref.BaseHandler` so that the tested behaviour is maintained running with optimizations ``(-O)``.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixing tests that fail when running with optimizations (``-O``) in ``_test_multiprocessing.py``
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixing tests that fail when running with optimizations (``-O``) in ``test_py_compile.py``

0 commit comments

Comments
 (0)
0