summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_builtin.py
Commit message (Collapse)AuthorAgeFilesLines
* #2196 hasattr now allows SystemExit and KeyboardInterrupt to propagateBenjamin Peterson2008-05-121-0/+10
|
* Moved testing of builtin types out of test_builtin and into type specific ↵Benjamin Peterson2008-05-031-692/+0
| | | | modules
* #2719: backport next() from 3k.Georg Brandl2008-04-301-0/+27
|
* Finished backporting PEP 3127, Integer Literal Support and Syntax.Eric Smith2008-03-171-0/+45
| | | | | | | | Added 0b and 0o literals to tokenizer. Modified PyOS_strtoul to support 0b and 0o inputs. Modified PyLong_FromString to support guessing 0b and 0o inputs. Renamed test_hexoct.py to test_int_literal.py and added binary tests. Added upper and lower case 0b, 0O, and 0X tests to test_int_literal.py
* Tests for bin() builtin. These need to get merged into py3k, which has no ↵Eric Smith2008-02-221-0/+9
| | | | tests for bin.
* Moved test_format into the correct TestCase.Eric Smith2008-02-211-39/+39
|
* Backport of PEP 3101, Advanced String Formatting, from py3k.Eric Smith2008-02-171-0/+95
| | | | | | | | | | | | | | | Highlights: - Adding PyObject_Format. - Adding string.Format class. - Adding __format__ for str, unicode, int, long, float, datetime. - Adding builtin format. - Adding ''.format and u''.format. - str/unicode fixups for formatters. The files in Objects/stringlib that implement PEP 3101 (stringdefs.h, unicodedefs.h, formatter.h, string_format.h) are identical in trunk and py3k. Any changes from here on should be made to trunk, and changes will propogate to py3k).
* Rename rational.Rational to fractions.Fraction, to avoid name clashMark Dickinson2008-02-101-2/+2
| | | | with numbers.Rational. See issue #1682 for related discussion.
* Make int() and long() fall back to __trunc__(). See issue 2002.Jeffrey Yasskin2008-02-041-0/+102
|
* Test round-trip on float.as_integer_ratio() and float.__truediv__().Raymond Hettinger2008-02-011-0/+6
|
* Issue #1996: float.as_integer_ratio() should return fraction in lowest terms.Raymond Hettinger2008-02-011-0/+8
|
* Move __builtins__.trunc() to math.trunc() perJeffrey Yasskin2008-02-011-32/+0
| | | | | http://mail.python.org/pipermail/python-dev/2008-January/076626.html and issue 1965.
* Moved Rational._binary_float_to_ratio() to float.as_integer_ratio() becauseJeffrey Yasskin2008-01-271-1/+20
| | | | | | | it's useful outside of rational numbers. This is my first C code that had to do anything significant. Please be more careful when looking over it.
* Fix #1679: "0x" was taken as a valid integer literal.Georg Brandl2008-01-191-0/+5
| | | | | Fixes the tokenizer, tokenize.py and int() to reject this. Patches by Malte Helmert.
* Continue rolling back pep-3141 changes that changed behavior from 2.5. ThisJeffrey Yasskin2008-01-051-13/+11
| | | | | | | | | | | | round included: * Revert round to its 2.6 behavior (half away from 0). * Because round, floor, and ceil always return float again, it's no longer necessary to have them delegate to __xxx___, so I've ripped that out of their implementations and the Real ABC. This also helps in implementing types that work in both 2.6 and 3.0: you return int from the __xxx__ methods, and let it get enabled by the version upgrade. * Make pow(-1, .5) raise a ValueError again.
* Patch #1725 by Mark Dickinson, fixes incorrect conversion of -1e1000Guido van Rossum2008-01-051-0/+6
| | | | and adds errors for -0x.
* Backport PEP 3141 from the py3k branch to the trunk. This includes r50877 (justJeffrey Yasskin2008-01-031-1/+74
| | | | | | | the complex_pow part), r56649, r56652, r56715, r57296, r57302, r57359, r57361, r57372, r57738, r57739, r58017, r58039, r58040, and r59390, and new documentation. The only significant difference is that round(x) returns a float to preserve backward-compatibility. See http://bugs.python.org/issue1689.
* Patch #1444529: the builtin compile() now accepts keyword arguments.Georg Brandl2007-03-131-0/+9
| | | | (backport)
* Backport from Py3k branch:Georg Brandl2007-03-121-4/+59
| | | | | | | Patch #1591665: implement the __dir__() special function lookup in PyObject_Dir. Had to change a few bits of the patch because classobjs and __methods__ are still in Py2.6.
* Patch #1638879: don't accept strings with embedded NUL bytes in long().Georg Brandl2007-03-061-0/+5
|
* Bug #1545497: when given an explicit base, int() did ignore NULsGeorg Brandl2006-10-121-0/+5
| | | | embedded in the string to convert.
* Forward-port of r52136,52138: a review of overflow-detecting code.Armin Rigo2006-10-041-2/+9
| | | | | | | | | | | | | | | | | | | | | | | * unified the way intobject, longobject and mystrtoul handle values around -sys.maxint-1. * in general, trying to entierely avoid overflows in any computation involving signed ints or longs is extremely involved. Fixed a few simple cases where a compiler might be too clever (but that's all guesswork). * more overflow checks against bad data in marshal.c. * 2.5 specific: fixed a number of places that were still confusing int and Py_ssize_t. Some of them could potentially have caused "real-world" breakage. * list.pop(x): fixing overflow issues on x was messy. I just reverted to PyArg_ParseTuple("n"), which does the right thing. (An obscure test was trying to give a Decimal to list.pop()... doesn't make sense any more IMHO) * trying to write a few tests...
* Fix integer negation and absolute value to not relyMartin v. Löwis2006-10-041-0/+1
| | | | | on undefined behaviour of the C compiler anymore. Will backport to 2.5 and 2.4.
* Fix and test for an infinite C recursion.Armin Rigo2006-08-091-0/+4
|
* __hash__ may now return long int; the final hashMartin v. Löwis2006-08-091-0/+9
| | | | | value is obtained by invoking hash on the long int. Fixes #1536021.
* Whitespace normalization.Tim Peters2006-08-091-1/+1
|
* Don't produce output in test_builtin.Georg Brandl2006-08-061-2/+2
|
* Bug #1535165: fixed a segfault in input() and raw_input() whenGeorg Brandl2006-08-061-0/+8
| | | | sys.stdin is closed.
* Bug #1417699: Reject locale-specific decimal point in float()Martin v. Löwis2006-07-031-3/+14
| | | | and atof().
* Normalized a few cases of whitespace in function declarations.Martin Blais2006-06-061-1/+1
| | | | | | | | | | | | Found them using:: find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done (I was doing this all over my own code anyway, because I'd been using spaces in all defs, so I thought I'd make a run on the Python code as well. If you need to do such fixes in your own code, you can use xx-rename or parenregu.el within emacs.)
* Heavily fiddled variant of patch #1442927: PyLong_FromString optimization.Tim Peters2006-05-241-0/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ``long(str, base)`` is now up to 6x faster for non-power-of-2 bases. The largest speedup is for inputs with about 1000 decimal digits. Conversion from non-power-of-2 bases remains quadratic-time in the number of input digits (it was and remains linear-time for bases 2, 4, 8, 16 and 32). Speedups at various lengths for decimal inputs, comparing 2.4.3 with current trunk. Note that it's actually a bit slower for 1-digit strings: len speedup ---- ------- 1 -4.5% 2 4.6% 3 8.3% 4 12.7% 5 16.9% 6 28.6% 7 35.5% 8 44.3% 9 46.6% 10 55.3% 11 65.7% 12 77.7% 13 73.4% 14 75.3% 15 85.2% 16 103.0% 17 95.1% 18 112.8% 19 117.9% 20 128.3% 30 174.5% 40 209.3% 50 236.3% 60 254.3% 70 262.9% 80 295.8% 90 297.3% 100 324.5% 200 374.6% 300 403.1% 400 391.1% 500 388.7% 600 440.6% 700 468.7% 800 498.0% 900 507.2% 1000 501.2% 2000 450.2% 3000 463.2% 4000 452.5% 5000 440.6% 6000 439.6% 7000 424.8% 8000 418.1% 9000 417.7%
* Bug #1334662 / patch #1335972: int(string, base) wrong answers.Tim Peters2006-05-231-0/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In rare cases of strings specifying true values near sys.maxint, and oddball bases (not decimal or a power of 2), int(string, base) could deliver insane answers. This repairs all such problems, and also speeds string->int significantly. On my box, here are % speedups for decimal strings of various lengths: length speedup ------ ------- 1 12.4% 2 15.7% 3 20.6% 4 28.1% 5 33.2% 6 37.5% 7 41.9% 8 46.3% 9 51.2% 10 19.5% 11 19.9% 12 23.9% 13 23.7% 14 23.3% 15 24.9% 16 25.3% 17 28.3% 18 27.9% 19 35.7% Note that the difference between 9 and 10 is the difference between short and long Python ints on a 32-bit box. The patch doesn't actually do anything to speed conversion to long: the speedup is due to detecting "unsigned long" overflow more quickly. This is a bugfix candidate, but it's a non-trivial patch and it would be painful to separate the "bug fix" from the "speed up" parts.
* Bug #1473625: stop cPickle making float dumps locale dependent in protocol 0.Georg Brandl2006-04-301-24/+12
| | | | | On the way, add a decorator to test_support to facilitate running single test functions in different locales with automatic cleanup.
* Fix __import__("") to raise ValueError rather than return None.Thomas Wouters2006-04-041-0/+1
|
* Patch #1460496: round() now accepts keyword arguments.Georg Brandl2006-03-311-0/+3
|
* Part of bug 1459808: fiddle test_input_and_raw_input()Tim Peters2006-03-281-2/+10
| | | | so it passes w/ -Qnew.
* Correct test_builtin locale handling.Georg Brandl2006-01-091-1/+1
|
* Get float() to be more portable across platforms. Disable hex strings.Neal Norwitz2005-12-181-2/+4
|
* Test another error case in PyFloat_FromString().Walter Dörwald2005-11-291-0/+2
|
* Improve test coverage. Hope the test_file changes work the same on windows.Neal Norwitz2005-11-271-0/+13
|
* improve test coverage in Python/pystrtod.c and Python/mystrtoul.c.Neal Norwitz2005-11-221-0/+29
|
* Disable a few other tests, that can't work if Python is compiled withoutWalter Dörwald2005-08-031-5/+14
| | | | Unicode support.
* Make subclasses of int, long, complex, float, and unicode perform typeBrett Cannon2005-04-261-0/+97
| | | | | | | conversion using the proper magic slot (e.g., __int__()). Also move conversion code out of PyNumber_*() functions in the C API into the nb_* function. Applied patch #1109424. Thanks Walter Doewald.
* Add two new functions, any() and all().Raymond Hettinger2005-03-111-0/+36
|
* Use decorators.Guido van Rossum2005-01-161-3/+4
|
* Whitespace normalization.Tim Peters2004-12-071-13/+13
|
* SF patch #1077353: add key= argument to min and maxRaymond Hettinger2004-12-031-4/+75
| | | | (First draft of patch contributed by Steven Bethard.)
* Improve test coverage.Raymond Hettinger2004-09-301-0/+3
|
* Checkin Tim's fix to an error discussed on python-dev.Raymond Hettinger2004-09-261-0/+5
| | | | | | | | | | | | | | | | | Also, add a testcase. Formerly, the list_extend() code used several local variables to remember its state across iterations. Since an iteration could call arbitrary Python code, it was possible for the list state to be changed. The new code uses dynamic structure references instead of C locals. So, they are always up-to-date. After list_resize() is called, its size has been updated but the new cells are filled with NULLs. These needed to be filled before arbitrary iteration code was called; otherwise, that code could attempt to modify a list that was in a semi-invalid state. The solution was to change the ob->size field back to a value reflecting the actual number of valid cells.
* Subclasses of string can no longer be interned. The semantics ofJeremy Hylton2004-08-071-0/+17
| | | | | | | | | | | interning were not clear here -- a subclass could be mutable, for example -- and had bugs. Explicitly interning a subclass of string via intern() will raise a TypeError. Internal operations that attempt to intern a string subclass will have no effect. Added a few tests to test_builtin that includes the old buggy code and verifies that calls like PyObject_SetAttr() don't fail. Perhaps these tests should have gone in test_string.