Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/includes/email-read-alternative.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
print('From:', msg['from'])
print('Subject:', msg['subject'])

# If we want to print a priview of the message content, we can extract whatever
# If we want to print a preview of the message content, we can extract whatever
# the least formatted payload is and print the first three lines. Of course,
# if the message has no plain text part printing the first three lines of html
# is probably useless, but this is just a conceptual example.
Expand Down
2 changes: 1 addition & 1 deletion Lib/ctypes/test/test_pep3118.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class Complete(Structure):
(PackedPoint, "B", (), PackedPoint),
(Point2, "T{<l:x:<l:y:}".replace('l', s_long), (), Point2),
(EmptyStruct, "T{}", (), EmptyStruct),
# the pep does't support unions
# the pep doesn't support unions
(aUnion, "B", (), aUnion),
# structure with sub-arrays
(StructWithArrays, "T{(2,3)<l:x:(4)T{<l:x:<l:y:}:y:}".replace('l', s_long), (), StructWithArrays),
Expand Down
2 changes: 1 addition & 1 deletion Lib/ctypes/test/test_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class XX(Structure):
self.assertEqual(sizeof(XX), 0)

def test_fields(self):
# test the offset and size attributes of Structure/Unoin fields.
# test the offset and size attributes of Structure/Union fields.
class X(Structure):
_fields_ = [("x", c_int),
("y", c_char)]
Expand Down
2 changes: 1 addition & 1 deletion Lib/email/quoprimime.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def body_encode(body, maxlinelen=76, eol=NL):
if not body:
return body

# quote speacial characters
# quote special characters
body = body.translate(_QUOPRI_BODY_ENCODE_MAP)

soft_break = '=' + eol
Expand Down
2 changes: 1 addition & 1 deletion Lib/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def _get_chunk_left(self):
chunk_left = self.chunk_left
if not chunk_left: # Can be 0 or None
if chunk_left is not None:
# We are at the end of chunk. dicard chunk end
# We are at the end of chunk, discard chunk end
self._safe_read(2) # toss the CRLF at the end of the chunk
try:
chunk_left = self._read_next_chunk_size()
Expand Down
2 changes: 1 addition & 1 deletion Lib/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ def spawnve(mode, file, args, env):
otherwise return -SIG, where SIG is the signal that killed it. """
return _spawnvef(mode, file, args, env, execve)

# Note: spawnvp[e] is't currently supported on Windows
# Note: spawnvp[e] isn't currently supported on Windows

def spawnvp(mode, file, args):
"""spawnvp(mode, file, args) -> integer
Expand Down
2 changes: 1 addition & 1 deletion Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ def frombuf(cls, buf, encoding, errors):

# The old GNU sparse format occupies some of the unused
# space in the buffer for up to 4 sparse structures.
# Save the them for later processing in _proc_sparse().
# Save them for later processing in _proc_sparse().
if obj.type == GNUTYPE_SPARSE:
pos = 386
structs = []
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3896,7 +3896,7 @@ def test_noforkbomb(self):
#

class TestForkAwareThreadLock(unittest.TestCase):
# We recurisvely start processes. Issue #17555 meant that the
# We recursively start processes. Issue #17555 meant that the
# after fork registry would get duplicate entries for the same
# lock. The size of the registry at generation n was ~2**n.

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_baseexception.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_raise_string(self):
self.raise_fails("spam")

def test_catch_non_BaseException(self):
# Tryinng to catch an object that does not inherit from BaseException
# Trying to catch an object that does not inherit from BaseException
# is not allowed.
class NonBaseException(object):
pass
Expand Down
50 changes: 50 additions & 0 deletions Lib/test/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,5 +595,55 @@ class A:
with self.assertRaises(TypeError):
type.__setattr__(A, b'x', None)

def testConstructorErrorMessages(self):
# bpo-31506: Improves the error message logic for object_new & object_init

# Class without any method overrides
class C:
pass

with self.assertRaisesRegex(TypeError, r'C\(\) takes no arguments'):
C(42)

with self.assertRaisesRegex(TypeError, r'C\(\) takes no arguments'):
C.__new__(C, 42)

with self.assertRaisesRegex(TypeError, r'C\(\).__init__\(\) takes no arguments'):
C().__init__(42)

with self.assertRaisesRegex(TypeError, r'C\(\) takes no arguments'):
object.__new__(C, 42)

with self.assertRaisesRegex(TypeError, r'C\(\).__init__\(\) takes no arguments'):
object.__init__(C(), 42)

# Class with both `__init__` & `__new__` method overridden
class D:
def __new__(cls, *args, **kwargs):
super().__new__(cls, *args, **kwargs)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

with self.assertRaisesRegex(TypeError, r'object.__new__\(\) takes no argument'):
D(42)

with self.assertRaisesRegex(TypeError, r'object.__new__\(\) takes no argument'):
D.__new__(D, 42)

with self.assertRaisesRegex(TypeError, r'object.__new__\(\) takes no argument'):
object.__new__(D, 42)

# Class that only overrides __init__
class E:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

with self.assertRaisesRegex(TypeError, r'object.__init__\(\) takes no argument'):
E().__init__(42)

with self.assertRaisesRegex(TypeError, r'object.__init__\(\) takes no argument'):
object.__init__(E(), 42)


if __name__ == '__main__':
unittest.main()
6 changes: 3 additions & 3 deletions Lib/test/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def __await__(self):

c = new_coro()
self.assertIsInstance(c, Awaitable)
c.close() # awoid RuntimeWarning that coro() was not awaited
c.close() # avoid RuntimeWarning that coro() was not awaited

class CoroLike: pass
Coroutine.register(CoroLike)
Expand Down Expand Up @@ -600,7 +600,7 @@ def __await__(self):

c = new_coro()
self.assertIsInstance(c, Coroutine)
c.close() # awoid RuntimeWarning that coro() was not awaited
c.close() # avoid RuntimeWarning that coro() was not awaited

class CoroLike:
def send(self, value):
Expand Down Expand Up @@ -1607,7 +1607,7 @@ def test_MutableSequence(self):
'__len__', '__getitem__', '__setitem__', '__delitem__', 'insert')

def test_MutableSequence_mixins(self):
# Test the mixins of MutableSequence by creating a miminal concrete
# Test the mixins of MutableSequence by creating a minimal concrete
# class inherited from it.
class MutableSequenceSubclass(MutableSequence):
def __init__(self):
Expand Down
Loading