Skip to content

Commit

Permalink
+1
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Nov 27, 2024
1 parent ed6d703 commit d56a55c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,9 @@ are always available. They are listed here in alphabetical order.

.. class:: imaginary(x=0.0)

Return an imaginary number with the value ``float(x)*1j``. If argument
is omitted, returns ``0j``.
Return an imaginary number with the value ``float(x)*1j``. If argument is
omitted, returns ``0j``.


.. function:: input()
input(prompt)
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ def test_add(self):
self.assertComplexesAreIdentical((1-0j) + float(1.0), complex(2, -0.0))
self.assertComplexesAreIdentical(float(1.0) + (1-0j), complex(2, -0.0))


def test_sub(self):
self.assertEqual(1j - int(+1), complex(-1, 1))
self.assertEqual(1j - int(-1), complex(1, 1))
Expand Down
11 changes: 6 additions & 5 deletions Lib/test/test_marshal.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ def test_exact_type_match(self):
# >>> class Int(int): pass
# >>> type(loads(dumps(Int())))
# <type 'int'>
for typ in (int, float, complex, tuple, list, dict, set, frozenset):
for typ in (int, float, complex, tuple, list, dict, set, frozenset,
imaginary):
# Note: str subclasses are not tested because they get handled
# by marshal's routines for objects supporting the buffer API.
subtyp = type('subtyp', (typ,), {})
Expand Down Expand Up @@ -372,7 +373,7 @@ def readinto(self, buf):
if n is not None and n > 4:
n += 10**6
return n
for value in (1.0, 1j, b'0123456789', '0123456789'):
for value in (1.0, 1j, 1+1j, b'0123456789', '0123456789'):
self.assertRaises(ValueError, marshal.load,
BadReader(marshal.dumps(value)))

Expand Down Expand Up @@ -628,7 +629,7 @@ def test_write_long_to_file(self):
self.assertEqual(data, b'\x78\x56\x34\x12')

def test_write_object_to_file(self):
obj = ('\u20ac', b'abc', 123, 45.6, 7+8j, 'long line '*1000)
obj = ('\u20ac', b'abc', 123, 45.6, 7+8j, 122j, 'long line '*1000)
for v in range(marshal.version + 1):
_testcapi.pymarshal_write_object_to_file(obj, os_helper.TESTFN, v)
with open(os_helper.TESTFN, 'rb') as f:
Expand Down Expand Up @@ -665,7 +666,7 @@ def test_read_long_from_file(self):
os_helper.unlink(os_helper.TESTFN)

def test_read_last_object_from_file(self):
obj = ('\u20ac', b'abc', 123, 45.6, 7+8j)
obj = ('\u20ac', b'abc', 123, 45.6, 7+8j, 666j)
for v in range(marshal.version + 1):
data = marshal.dumps(obj, v)
with open(os_helper.TESTFN, 'wb') as f:
Expand All @@ -681,7 +682,7 @@ def test_read_last_object_from_file(self):
os_helper.unlink(os_helper.TESTFN)

def test_read_object_from_file(self):
obj = ('\u20ac', b'abc', 123, 45.6, 7+8j)
obj = ('\u20ac', b'abc', 123, 45.6, 7+8j, 1j)
for v in range(marshal.version + 1):
data = marshal.dumps(obj, v)
with open(os_helper.TESTFN, 'wb') as f:
Expand Down

0 comments on commit d56a55c

Please sign in to comment.