Mark Dickinson
97e9cfa75a
gh-95605: Fix `float(s)` error message when `s` contains only whitespace (GH-95665)
...
This PR fixes the error message from float(s) in the case where s contains only whitespace.
2022-08-10 19:25:39 +01:00
Michael Droettboom
625ba9bdff
GH-94808: Cover handling non-finite numbers from round when ndigits is provided (GH-94860)
2022-07-14 14:46:40 -07:00
Victor Stinner
3ceb4b8d3a
gh-84623: Remove unused imports in tests ( #93772 )
2022-06-13 16:56:03 +02:00
John Belmonte
b0b836b20c
bpo-45995: add "z" format specifer to coerce negative 0 to zero (GH-30049)
...
Add "z" format specifier to coerce negative 0 to zero.
See https://github.com/python/cpython/issues/90153 (originally https://bugs.python.org/issue45995 ) for discussion.
This covers `str.format()` and f-strings. Old-style string interpolation is not supported.
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2022-04-11 15:34:18 +01:00
Victor Stinner
882d8096c2
bpo-46906: Add PyFloat_Pack8() to the C API (GH-31657)
...
Add new functions to pack and unpack C double (serialize and
deserialize):
* PyFloat_Pack2(), PyFloat_Pack4(), PyFloat_Pack8()
* PyFloat_Unpack2(), PyFloat_Unpack4(), PyFloat_Unpack8()
Document these functions and add unit tests.
Rename private functions and move them from the internal C API
to the public C API:
* _PyFloat_Pack2() => PyFloat_Pack2()
* _PyFloat_Pack4() => PyFloat_Pack4()
* _PyFloat_Pack8() => PyFloat_Pack8()
* _PyFloat_Unpack2() => PyFloat_Unpack2()
* _PyFloat_Unpack4() => PyFloat_Unpack4()
* _PyFloat_Unpack8() => PyFloat_Unpack8()
Replace the "unsigned char*" type with "char*" which is more common
and easy to use.
2022-03-12 00:10:02 +01:00
Victor Stinner
5a1c637ec6
bpo-46852: Restore test_getformat() test (GH-31601)
2022-02-27 01:12:33 +01:00
Victor Stinner
5ab745fc51
bpo-46852: Remove the float.__set_format__() method (GH-31585)
...
Remove the undocumented private float.__set_format__() method,
previously known as float.__set_format__() in Python 3.7. Its
docstring said: "You probably don't want to use this function. It
exists mainly to be used in Python's test suite."
2022-02-26 00:53:27 +01:00
Christian Heimes
e73283a20f
bpo-45668: Fix PGO tests without test extensions (GH-29315)
2021-11-01 11:14:53 +01:00
Serhiy Storchaka
92bf8691fb
bpo-43413: Fix handling keyword arguments in subclasses of some buitin classes (GH-26456)
...
* Constructors of subclasses of some buitin classes (e.g. tuple, list,
frozenset) no longer accept arbitrary keyword arguments.
* Subclass of set can now define a __new__() method with additional
keyword parameters without overriding also __init__().
2021-09-12 13:27:50 +03:00
Mark Dickinson
60b93d9e49
bpo-44954: Fix wrong result in float.fromhex corner case (GH-27834)
2021-08-20 11:40:11 +01:00
Dong-hee Na
5a3108044d
bpo-28395: Remove unnecessary semicolons in tests (GH-26868)
2021-06-23 18:01:06 +09:00
Serhiy Storchaka
9f1c5f6e8a
bpo-43475: Fix the Python implementation of hash of Decimal NaN (GH-26679)
2021-06-12 15:15:17 +03:00
Inada Naoki
3caea9adda
bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25171)
...
* Fix test_float
* Fix _osx_support
* Fix test_fstring
* Fix test_gc
* Fix test_gzip
* Fix test_hashlib
* Fix unrelated whitespace issue
Co-authored-by: Ned Deily <nad@python.org>
2021-04-04 17:01:10 +09:00
Dennis Sweeney
e8acc355d4
bpo-41873: Add vectorcall for float() (GH-22432)
2020-09-29 09:55:52 +09:00
Batuhan Taşkaya
cb8b946ac1
bpo-38629: implement __floor__ and __ceil__ for float type (GH-16985)
2019-12-15 23:00:28 +01:00
Serhiy Storchaka
bdbad71b9d
bpo-20092. Use __index__ in constructors of int, float and complex. (GH-13108)
2019-06-02 00:05:48 +03:00
Serhiy Storchaka
5b10b98247
bpo-22831: Use "with" to avoid possible fd leaks in tests (part 2). (GH-10929)
2019-03-05 10:06:26 +02:00
Xtreak
3f7983a25a
bpo-35560: Remove assertion from format(float, "n") (GH-11288)
...
Fix an assertion error in format() in debug build for floating point
formatting with "n" format, zero padding and small width. Release build is
not impacted. Patch by Karthikeyan Singaravelan.
2019-01-07 16:09:14 +01:00
INADA Naoki
16dfca4d82
bpo-34087: Fix buffer overflow in int(s) and similar functions (GH-8274)
...
`_PyUnicode_TransformDecimalAndSpaceToASCII()` missed trailing NUL char.
It caused buffer overflow in `_Py_string_to_number_with_underscores()`.
This bug is introduced in 9b6c60cb
.
2018-07-14 12:06:43 +09:00
Serhiy Storchaka
9b6c60cbce
bpo-31979: Simplify transforming decimals to ASCII ( #4336 )
...
in int(), float() and complex() parsers.
This also speeds up parsing non-ASCII numbers by around 20%.
2017-11-13 21:23:48 +02:00
Benjamin Peterson
2bb69a5b4e
bpo-31373: remove overly strict float range checks ( #3486 )
...
This undoes a853a8ba78
except for the pytime.c
parts. We want to continue to allow IEEE 754 doubles larger than FLT_MAX to be
rounded into finite floats. Tests were added to very this behavior.
2017-09-10 23:50:46 -07:00
Serhiy Storchaka
9e6ac83aca
bpo-29773: Add more cases for testing string to float conversion errors. ( #580 )
2017-03-09 20:07:58 +02:00
Serhiy Storchaka
2e5642422f
bpo-29695: Remove bad keyword parameters in int(), bool(), float(), list() and tuple(). ( #518 )
2017-03-06 17:01:06 +02:00
Serhiy Storchaka
58d23e6806
bpo-29695: Deprecated using bad named keyword arguments in builtings: ( #486 )
...
int(), bool(), float(), list() and tuple(). Specify the value as a
positional argument instead.
2017-03-06 00:53:39 +02:00
Brett Cannon
a721abac29
Issue #26331 : Implement the parsing part of PEP 515.
...
Thanks to Georg Brandl for the patch.
2016-09-09 14:57:09 -07:00
Serhiy Storchaka
16931c3559
Issue #26983 : float() now always return an instance of exact float.
...
The deprecation warning is emitted if __float__ returns an instance of
a strict subclass of float. In a future versions of Python this can
be an error.
2016-06-03 21:42:55 +03:00
Serhiy Storchaka
1f364438ad
Issue #23640 : int.from_bytes() no longer bypasses constructors for subclasses.
2016-05-12 10:39:32 +03:00
Serhiy Storchaka
ea36c941a1
Issue #23640 : int.from_bytes() no longer bypasses constructors for subclasses.
2016-05-12 10:37:58 +03:00
Serhiy Storchaka
e437a10d15
Issue #23277 : Remove unused imports in tests.
2016-04-24 21:41:02 +03:00
Serhiy Storchaka
f9afda57ad
Issue #24731 : Fixed crash on converting objects with special methods
...
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
2015-11-25 15:52:04 +02:00
Serhiy Storchaka
15095800a3
Issue #24731 : Fixed crash on converting objects with special methods
...
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
2015-11-25 15:47:01 +02:00
Martin Panter
eeb896c411
Issue #24802 : Copy bytes-like objects to null-terminated buffers if necessary
...
This avoids possible buffer overreads when int(), float(), compile(), exec()
and eval() are passed bytes-like objects. Similar code is removed from the
complex() constructor, where it was not reachable.
Patch by John Leitch, Serhiy Storchaka and Martin Panter.
2015-11-07 02:32:21 +00:00
Martin Panter
61d6e4ae9d
Issue #24802 : Merge null termination fixes from 3.4 into 3.5
2015-11-07 02:56:11 +00:00
Steve Dower
cb39d1f466
Issue 19933: Provide default argument for ndigits in round. Patch by Vajrasky Kok.
2015-04-15 16:10:59 -04:00
Zachary Ware
38c707e7e0
Issue #21741 : Update 147 test modules to use test discovery.
...
I have compared output between pre- and post-patch runs of these tests
to make sure there's nothing missing and nothing broken, on both
Windows and Linux. The only differences I found were actually tests
that were previously *not* run.
2015-04-13 15:00:43 -05:00
Benjamin Peterson
101447b3fe
fix up import style
2015-03-09 10:37:50 -04:00
Benjamin Peterson
c19ed37579
remove redundant test
2015-03-06 09:10:26 -05:00
Benjamin Peterson
a915723dc7
fix potential refleak in PyFloat_AsDouble ( closes #23590 )
2015-03-06 09:08:44 -05:00
Zachary Ware
101d9e7250
Issue 19572: More silently skipped tests explicitly skipped.
2013-12-08 00:44:27 -06:00
Zachary Ware
9fe6d86709
Issue 19572: More silently skipped tests explicitly skipped.
2013-12-08 00:20:35 -06:00
Ezio Melotti
a5b9599538
#17080 : improve error message of float/complex when the wrong type is passed.
2013-11-07 19:18:34 +02:00
Mark Dickinson
89e6d3896a
Remove untests for non-existent functionality.
2012-04-29 19:17:05 +01:00
Mark Dickinson
e383e82e04
Issue #14521 : Make result of float('nan') and float('-nan') more consistent across platforms. Further, don't rely on Py_HUGE_VAL for float('inf').
2012-04-29 15:31:56 +01:00
Benjamin Peterson
29037720d1
merge 3.2
2011-10-28 19:44:00 -04:00
Benjamin Peterson
b3b8ba6121
bring is_integer into tested existence
2011-10-28 19:42:48 -04:00
Ezio Melotti
3b3499ba69
#11565 : Merge with 3.1.
2011-03-16 11:35:38 +02:00
Ezio Melotti
13925008dc
#11565 : Fix several typos. Patch by Piotr Kasprzyk.
2011-03-16 11:05:33 +02:00
Ezio Melotti
b88ed1549e
#11565 : Merge with 3.2.
2011-03-16 11:38:59 +02:00
Eli Bendersky
67ebabd152
Removed fcmp and FUZZ from test.support, following the discussion on python-dev:
...
http://mail.python.org/pipermail/python-dev/2011-January/107735.html
2011-02-25 10:14:17 +00:00
Eric Smith
3ab08cadae
Issue #10624 : Use support.requires_IEEE_754 in all appropriate tests.
2010-12-04 15:17:38 +00:00