summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_builtin.py
Commit message (Collapse)AuthorAgeFilesLines
* Patch #1638879: don't accept strings with embedded NUL bytes in long().Georg Brandl2007-03-061-0/+5
| | | | (backport from rev. 54173)
* Bug #1545497: when given an explicit base, int() did ignore NULsGeorg Brandl2006-10-121-0/+5
| | | | | embedded in the string to convert. (backport from rev. 52305)
* Forward-port of r52136: 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.
* 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.
* SF bug #1004669: Type returned from .keys() is not checkedRaymond Hettinger2004-08-071-0/+9
|
* Completed the patch for Bug #215126.Raymond Hettinger2004-08-021-0/+25
| | | | | | | * Fixes an incorrect variable in a PyDict_CheckExact. * Allow general mapping locals arguments for the execfile() function and exec statement. * Add tests.
* * Fix missing return after error message is set.Raymond Hettinger2004-07-061-0/+1
| | | | * Add a test case that would have caught it.
* SF Bug #215126: Over restricted type checking on eval() functionRaymond Hettinger2004-07-021-1/+55
| | | | | | The builtin eval() function now accepts any mapping for the locals argument. Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing down the normal case. My timings so no measurable impact.
* Replace backticks with repr() or "%r"Walter Dörwald2004-02-121-2/+2
| | | | From SF patch #852334.
* Fix input() builtin function to respect compiler flags.Hye-Shik Chang2004-02-021-0/+13
| | | | (SF patch 876178, patch by mwh, unittest by perky)
* Guido grants a Christmas wish:Raymond Hettinger2003-12-171-2/+35
| | | | sorted() becomes a regular function instead of a classmethod.
* - Removed FutureWarnings related to hex/oct literals and conversionsGuido van Rossum2003-11-291-3/+2
| | | | | | | | | | and left shifts. (Thanks to Kalle Svensson for SF patch 849227.) This addresses most of the remaining semantic changes promised by PEP 237, except for repr() of a long, which still shows the trailing 'L'. The PEP appears to promise warnings for operations that changed semantics compared to Python 2.3, but this is not implemented; we've suffered through enough warnings related to hex/oct literals and I think it's best to be silent now.
* * Migrate set() and frozenset() from the sandbox.Raymond Hettinger2003-11-161-3/+2
| | | | | | | | * Install the unittests, docs, newsitem, include file, and makefile update. * Exercise the new functions whereever sets.py was being used. Includes the docs for libfuncs.tex. Separate docs for the types are forthcoming.
* Deleting cyclic object comparison.Armin Rigo2003-10-281-6/+6
| | | | | SF patch 825639 http://mail.python.org/pipermail/python-dev/2003-October/039445.html
* Make a copy of L before appending, so the global L remainsWalter Dörwald2003-08-151-4/+4
| | | | | | unchanged (and sys.gettotalrefcount() remains constant). Fix a few typos.
* As discussed on python-dev, changed builtin.zip() to handle zero argumentsRaymond Hettinger2003-08-021-1/+2
| | | | by returning an empty list instead of raising a TypeError.
* Port test_complex.py to unittest.Walter Dörwald2003-06-181-56/+0
| | | | | | | | Move the constructor tests from test_builtin to test_complex. Add a bunch of tests (code coverage is a 94%). From SF patch #736962.
* Used sets.Set() to compare unordered sequences.Raymond Hettinger2003-05-021-11/+3
| | | | Improves clarity and brevity.
* Combine the functionality of test_support.run_unittest()Walter Dörwald2003-05-011-3/+1
| | | | | | | | | | and test_support.run_classtests() into run_unittest() and use it wherever possible. Also don't use "from test.test_support import ...", but "from test import test_support" in a few spots. From SF patch #662807.
* Adding new built-in function sum, with docs and tests.Alex Martelli2003-04-221-0/+21
|
* Add a few errors tests for range().Walter Dörwald2003-04-151-0/+6
|
* test_range(): The C code changed to raise TypeError in one of theseTim Peters2003-04-151-1/+1
| | | | cases, but the test still expected ValueError. Repaired that.
* Patch by Chad Netzer (with significant change):Guido van Rossum2003-04-111-0/+35
| | | | | | | - range() now works even if the arguments are longs with magnitude larger than sys.maxint, as long as the total length of the sequence fits. E.g., range(2**100, 2**101, 2**100) is the following list: [1267650600228229401496703205376L]. (SF patch #707427.)