summaryrefslogtreecommitdiffstats
path: root/Objects/intobject.c
Commit message (Collapse)AuthorAgeFilesLines
* 00147-add-debug-malloc-stats.patchFedora Python maintainers2020-09-291-0/+17
| | | | | | | 00147 # Add a sys._debugmallocstats() function Based on patch 202 from RHEL 5's python.spec, with updates from rhbz#737198 Sent upstream as http://bugs.python.org/issue14785
* bpo-16055: Fixes incorrect error text for int('1', base=1000) (#6980)Victor Stinner2018-05-181-1/+1
| | | | Fixes incorrect error text for int('1', base=1000) and long('1', base=1000).
* consistently use Py_TYPE, Py_REFCNT, and correct initializer macros (#3563)Benjamin Peterson2017-09-141-4/+4
| | | This no-op change makes 2.7 more consistent with 3.x to ease comparison and backports.
* Issue #28998: More APIs now support longs as well as ints.Serhiy Storchaka2016-12-271-2/+5
|
* Issue #24469: Fixed memory leak caused by int subclasses without overriddenSerhiy Storchaka2016-11-291-8/+0
| | | | tp_free (e.g. C-inherited Cython classes).
* Issue #28139: Fix messed up indentationMartin Panter2016-09-171-2/+2
| | | | | Also update the classmethod and staticmethod doc strings and comments to match the RST documentation.
* Issue #22463: Backport compiler warning fixes and workaroundsMartin Panter2016-06-211-2/+2
| | | | | | | | | | | | | | * Set but unused variable in Parser/pgen.c in non-debug builds. Patch by Christian Heimes. * Unused static function in Modules/readline.c. Patch by Georg Brandl. * main_window unused in Modules/tkappinit.c. Patch by Gregory P. Smith. * Dead assignment in Modules/_ctypes/cfield.c. Extracted from patch by Brett Cannon. * Expression result unused in PyObject_INIT macro expansions. Based on patches by Christian Heimes. * Load expat_config.h and therefore pyconfig.h before C stdlib headers are loaded. This silences pre-processor warnings including '_POSIX_C_SOURCE redefined'. Extracted from patch by Christian Heimes.
* remove strange castsBenjamin Peterson2014-11-231-4/+4
|
* Issue #15989: Fix several occurrences of integer overflowSerhiy Storchaka2013-01-191-0/+14
| | | | | | | when result of PyInt_AsLong() or PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277.
* Issue #16761: Raise TypeError when int() or long() called with base argument ↵Serhiy Storchaka2012-12-281-1/+7
| | | | only.
* Issue #14783: Backport changes from 3.2.Chris Jerdonek2012-10-081-8/+13
|
* Issue #12973: Fix int.__pow__ overflow checks that invoked undefined ↵Mark Dickinson2011-09-191-2/+8
| | | | behaviour, thereby producing incorrect results on Clang.
* Untabify C files. Will watch buildbots.Antoine Pitrou2010-05-091-1076/+1076
|
* Improve error message from nb_int returning a non-integer, in various ↵Mark Dickinson2010-05-021-4/+4
| | | | PyInt_As* functions:
* Silence a compiler warning.Raymond Hettinger2010-04-031-1/+1
|
* Issue #1811: Improve accuracy and consistency of true division for integers.Mark Dickinson2009-12-271-6/+25
|
* Avoid undefined behaviour due to overflow in i_divmod (Objects/intobject.c).Mark Dickinson2009-12-041-1/+10
|
* Issue #7406: Fix some occurrences of potential signed overflow in intMark Dickinson2009-12-021-3/+6
| | | | arithmetic.
* Silence another MSVC warning about unary minus.Mark Dickinson2009-11-161-1/+1
|
* Issue #6713: Improve decimal int -> string conversions. Thanks GawainMark Dickinson2009-09-271-10/+28
| | | | Bolton for the suggestion and original patches.
* Remove unnecessary uses of context in PyGetSetDef. See issue #5880.Mark Dickinson2009-05-031-10/+15
|
* Issue #3166: Make long -> float (and int -> float) conversionsMark Dickinson2009-04-201-12/+68
| | | | | | correctly rounded, using round-half-to-even. This ensures that the value of float(n) doesn't depend on whether we're using 15-bit digits or 30-bit digits for Python longs.
* Issue #4850: Change COUNT_ALLOCS variables to Py_ssize_t.Martin v. Löwis2009-01-071-1/+2
|
* Issue #3439: add bit_length method to int and long.Mark Dickinson2008-12-171-0/+36
| | | | | Thanks Fredrik Johansson and Victor Stinner for code, Raymond Hettinger for review.
* - Issue #2862: Make int and float freelist management consistent with otherGregory P. Smith2008-07-061-35/+25
| | | | | freelists. Changes their CompactFreeList apis into ClearFreeList apis and calls them via gc.collect().
* Revert 64424, 64438, and 64439.Raymond Hettinger2008-06-241-7/+0
|
* Make bin() implementation parallel oct() and hex() so that int/long ↵Raymond Hettinger2008-06-201-0/+7
| | | | subclasses can override or so that other classes can support.
* This reverts r63675 based on the discussion in this thread:Gregory P. Smith2008-06-091-7/+7
| | | | | | | http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
* Refactor and clean up str.format() code (and helpers) in advance of ↵Eric Smith2008-05-301-16/+11
| | | | optimizations.
* Renamed PyString to PyBytesChristian Heimes2008-05-261-8/+8
|
* I finally got the time to update and merge Mark's and my trunk-math branch. ↵Christian Heimes2008-04-181-0/+12
| | | | | | The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math. The patch also adds acosh, asinh, atanh, log1p and copysign to all platforms. Finally it fixes differences between platforms like different results or exceptions for edge cases. Have fun :)
* Pluralss only need one s, not 2 (intss -> ints)Neal Norwitz2008-03-271-1/+1
|
* Fix build on platforms that don't have intptr_t. Patch by Joseph Armbruster.Jeffrey Yasskin2008-03-181-1/+1
|
* Backport of PEP 3101, Advanced String Formatting, from py3k.Eric Smith2008-02-171-0/+36
| | | | | | | | | | | | | | | 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).
* Added PyNumber_ToBase and supporting routines _PyInt_Format andEric Smith2008-02-101-19/+71
| | | | | | | | | | | | | | | | | _PyLong_Format. In longobject.c, changed long_format to _PyLong_Format. In intobject.c, changed uses of PyOS_snprintf to _PyInt_Format instead. _PyLong_Format is similar to py3k's routine of the same name, except it has 2 additional parameters: addL and newstyle. addL was existing in long_format, and controls adding the trailing "L". This is unneeded in py3k. newstyle is used to control whether octal prepends "0" (the pre-2.6 style), or "0o" (the 3.0 sytle). PyNumber_ToBase is needed for PEP 3127 (Integer Literal Support and Syntax) and PEP 3101 (Advanced String Formatting). This changeset does not need merging into py3k.
* Patch #1953Christian Heimes2008-02-041-18/+34
| | | | | I implemented the function sys._compact_freelists() and C API functions PyInt_/PyFloat_CompactFreeList() to compact the pre-allocated blocks of ints and floats. They allow the user to reduce the memory usage of a Python process that deals with lots of numbers. The patch also renames sys._cleartypecache to sys._clear_type_cache
* Continue rolling back pep-3141 changes that changed behavior from 2.5. ThisJeffrey Yasskin2008-01-051-32/+0
| | | | | | | | | | | | 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.
* Make math.{floor,ceil}({int,long}) return float again for backwardsJeffrey Yasskin2008-01-041-2/+2
| | | | compatibility after r59671 made them return integral types.
* Backport PEP 3141 from the py3k branch to the trunk. This includes r50877 (justJeffrey Yasskin2008-01-031-16/+68
| | | | | | | 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.
* #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and ↵Christian Heimes2007-12-191-12/+12
| | | | Py_REFCNT. Macros for b/w compatibility are available.
* Add a bunch of GIL release/acquire points in tp_print implementations and forBrett Cannon2007-09-171-1/+4
| | | | | | PyObject_Print(). Closes issue #1164.
* PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis2007-07-211-14/+13
| | | | | backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
* Port rev 55353 from Guido:Neal Norwitz2007-05-161-1/+1
| | | | | | | Add what looks like a necessary call to PyErr_NoMemory() when PyMem_MALLOC() fails. Will backport.
* As per Armin Rigo's suggestion, remove special handing from intobject.c to ↵Kristján Valur Jónsson2007-05-071-7/+2
| | | | deal with the peculiarities of classobject's implementation of the number protocol. The nb_long method of classobject now falls back to nb_int if there is no __long__ attribute present.
* Fix problems in x64 build that were discovered by the testsuite:Kristján Valur Jónsson2007-05-031-0/+4
| | | | | | | | | | | | - Reenable modules on x64 that had been disabled aeons ago for Itanium. - Cleared up confusion about compilers for 64 bit windows. There is only Itanium and x64. Added macros MS_WINI64 and MS_WINX64 for those rare cases where it matters, such as the disabling of modules above. - Set target platform (_WIN32_WINNT and WINVER) to 0x0501 (XP) for x64, and 0x0400 (NT 4.0) otherwise, which are the targeted minimum platforms. - Fixed thread_nt.h. The emulated InterlockedCompareExchange function didn´t work on x64, probaby due to the lack of a "volatile" specifier. Anyway, win95 is no longer a target platform. - Itertools module used wrong constant to check for overflow in count() - PyInt_AsSsize_t couldn't deal with attribute error when accessing the __long__ member. - PyLong_FromSsize_t() incorrectly specified that the operand were unsigned. With these changes, the x64 passes the testsuite, for those modules present.
* Variation of patch # 1624059 to speed up checking if an object is a subclassNeal Norwitz2007-02-251-1/+1
| | | | | | | | | | | | | | | | | | of some of the common builtin types. Use a bit in tp_flags for each common builtin type. Check the bit to determine if any instance is a subclass of these common types. The check avoids a function call and O(n) search of the base classes. The check is done in the various Py*_Check macros rather than calling PyType_IsSubtype(). All the bits are set in tp_flags when the type is declared in the Objects/*object.c files because PyType_Ready() is not called for all the types. Should PyType_Ready() be called for all types? If so and the change is made, the changes to the Objects/*object.c files can be reverted (remove setting the tp_flags). Objects/typeobject.c would also have to be modified to add conditions for Py*_CheckExact() in addition to each the PyType_IsSubtype check.
* Minor change in int() docstring for proper spacing.Gustavo Niemeyer2007-01-101-1/+1
|
* Mention in the int() docstring that a base zero has meaning, asGustavo Niemeyer2007-01-101-2/+3
| | | | stated in http://docs.python.org/lib/built-in-funcs.html as well.
* Bug #1545497: when given an explicit base, int() did ignore NULsGeorg Brandl2006-10-121-2/+19
| | | | embedded in the string to convert.
* Forward-port of r52136,52138: a review of overflow-detecting code.Armin Rigo2006-10-041-2/+14
| | | | | | | | | | | | | | | | | | | | | | | * 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...