Skip to content

Commit

Permalink
Merge branch 'main' into return_in_while
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel authored Oct 19, 2022
2 parents b4c0df2 + 5055300 commit d9a81f2
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 33 deletions.
5 changes: 1 addition & 4 deletions Doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ sphinx==4.5.0

blurb

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

# The theme used by the documentation is stored separately, so we need
# to install that as well.
Expand Down
51 changes: 28 additions & 23 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5698,45 +5698,48 @@ def test_joinable_queue(self):

@classmethod
def _test_list(cls, obj):
assert obj[0] == 5
assert obj.count(5) == 1
assert obj.index(5) == 0
case = unittest.TestCase()
case.assertEqual(obj[0], 5)
case.assertEqual(obj.count(5), 1)
case.assertEqual(obj.index(5), 0)
obj.sort()
obj.reverse()
for x in obj:
pass
assert len(obj) == 1
assert obj.pop(0) == 5
case.assertEqual(len(obj), 1)
case.assertEqual(obj.pop(0), 5)

def test_list(self):
o = self.manager.list()
o.append(5)
self.run_worker(self._test_list, o)
assert not o
self.assertIsNotNone(o)
self.assertEqual(len(o), 0)

@classmethod
def _test_dict(cls, obj):
assert len(obj) == 1
assert obj['foo'] == 5
assert obj.get('foo') == 5
assert list(obj.items()) == [('foo', 5)]
assert list(obj.keys()) == ['foo']
assert list(obj.values()) == [5]
assert obj.copy() == {'foo': 5}
assert obj.popitem() == ('foo', 5)
case = unittest.TestCase()
case.assertEqual(len(obj), 1)
case.assertEqual(obj['foo'], 5)
case.assertEqual(obj.get('foo'), 5)
case.assertListEqual(list(obj.items()), [('foo', 5)])
case.assertListEqual(list(obj.keys()), ['foo'])
case.assertListEqual(list(obj.values()), [5])
case.assertDictEqual(obj.copy(), {'foo': 5})
case.assertTupleEqual(obj.popitem(), ('foo', 5))

def test_dict(self):
o = self.manager.dict()
o['foo'] = 5
self.run_worker(self._test_dict, o)
assert not o
self.assertIsNotNone(o)
self.assertEqual(len(o), 0)

@classmethod
def _test_value(cls, obj):
assert obj.value == 1
assert obj.get() == 1
case = unittest.TestCase()
case.assertEqual(obj.value, 1)
case.assertEqual(obj.get(), 1)
obj.set(2)

def test_value(self):
Expand All @@ -5747,19 +5750,21 @@ def test_value(self):

@classmethod
def _test_array(cls, obj):
assert obj[0] == 0
assert obj[1] == 1
assert len(obj) == 2
assert list(obj) == [0, 1]
case = unittest.TestCase()
case.assertEqual(obj[0], 0)
case.assertEqual(obj[1], 1)
case.assertEqual(len(obj), 2)
case.assertListEqual(list(obj), [0, 1])

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

@classmethod
def _test_namespace(cls, obj):
assert obj.x == 0
assert obj.y == 1
case = unittest.TestCase()
case.assertEqual(obj.x, 0)
case.assertEqual(obj.y, 1)

def test_namespace(self):
o = self.manager.Namespace()
Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_py_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ def pycompilecmd(self, *args, **kwargs):
# assert_python_* helpers don't return proc object. We'll just use
# subprocess.run() instead of spawn_python() and its friends to test
# stdin support of the CLI.
opts = '-m' if __debug__ else '-Om'
if args and args[0] == '-' and 'input' in kwargs:
return subprocess.run([sys.executable, '-m', 'py_compile', '-'],
return subprocess.run([sys.executable, opts, 'py_compile', '-'],
input=kwargs['input'].encode(),
capture_output=True)
return script_helper.assert_python_ok('-m', 'py_compile', *args, **kwargs)
return script_helper.assert_python_ok(opts, 'py_compile', *args, **kwargs)

def pycompilecmd_failure(self, *args):
return script_helper.assert_python_failure('-m', 'py_compile', *args)
Expand Down
12 changes: 9 additions & 3 deletions Lib/wsgiref/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,7 @@ def start_response(self, status, headers,exc_info=None):
self.status = status
self.headers = self.headers_class(headers)
status = self._convert_string_type(status, "Status")
assert len(status)>=4,"Status must be at least 4 characters"
assert status[:3].isdigit(), "Status message must begin w/3-digit code"
assert status[3]==" ", "Status message must have a space after code"
self._validate_status(status)

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

return self.write

def _validate_status(self, status):
if len(status) < 4:
raise AssertionError("Status must be at least 4 characters")
if not status[:3].isdigit():
raise AssertionError("Status message must begin w/3-digit code")
if status[3] != " ":
raise AssertionError("Status message must have a space after code")

def _convert_string_type(self, value, title):
"""Convert/check value type."""
if type(value) is str:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Python again uses C-style casts for most casting operations when compiled
with C++. This may trigger compiler warnings, if they are enabled with e.g.
``-Wold-style-cast `` or ``-Wzero-as-null-pointer-constant`` options for ``g++``.
``-Wold-style-cast`` or ``-Wzero-as-null-pointer-constant`` options for ``g++``.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace ``assert`` statements with ``raise AssertionError()`` in :class:`~wsgiref.BaseHandler` so that the tested behaviour is maintained running with optimizations ``(-O)``.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixing tests that fail when running with optimizations (``-O``) in ``_test_multiprocessing.py``
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixing tests that fail when running with optimizations (``-O``) in ``test_py_compile.py``

0 comments on commit d9a81f2

Please sign in to comment.