Victor Stinner
5dcc06f6e0
bpo-38858: Allocate small integers on the heap (GH-17301)
...
Allocate small Python integers (small_ints of longobject.c) on the
heap, rather than using static objects.
2019-11-21 08:51:59 +01:00
Victor Stinner
6314abcc08
bpo-37802: Fix a compiler warning in longobject.c (GH-16517)
...
bpo-37802, bpo-38321: Fix the following warnings:
longobject.c(420): warning C4244: 'function': conversion from
'unsigned __int64' to 'sdigit', possible loss of data
longobject.c(428): warning C4267: 'function': conversion from
'size_t' to 'sdigit', possible loss of data
2019-10-01 13:29:53 +02:00
HongWeipeng
42acb7b8d2
bpo-35696: Simplify long_compare() (GH-16146)
2019-09-19 00:10:15 +09:00
Sergey Fedoseev
c6734ee7c5
bpo-37802: Slightly improve perfomance of PyLong_FromUnsigned*() (GH-15192)
2019-09-12 15:41:14 +01:00
Raymond Hettinger
7117074410
bpo-38096: Clean up the "struct sequence" / "named tuple" docs (GH-15895)
...
* bpo-38096: Clean up the "struct sequence" / "named tuple" docs
* Fix remaining occurrences of "struct sequence"
* Repair a user visible docstring
2019-09-11 15:17:32 +01:00
Jordon Xu
2ec7010206
bpo-37752: Delete redundant Py_CHARMASK in normalizestring() (GH-15095)
2019-09-10 17:04:08 +01:00
animalize
6b519985d2
replace inline function `is_small_int` with a macro version (GH-15710)
2019-09-05 23:00:56 -07:00
Victor Stinner
bed4817d52
Make PyXXX_Fini() functions private (GH-15531)
...
For example, rename PyTuple_Fini() to _PyTuple_Fini().
These functions are only declared in the internal C API.
2019-08-27 00:12:32 +02:00
Greg Price
5e63ab05f1
bpo-37812: Convert CHECK_SMALL_INT macro to a function so the return is explicit. (GH-15216)
2019-08-24 10:19:37 -07:00
Jeroen Demeyer
196a530e00
bpo-37483: add _PyObject_CallOneArg() function ( #14558 )
2019-07-04 19:31:34 +09:00
Zackery Spytz
dc2476500d
bpo-37170: Fix the cast on error in PyLong_AsUnsignedLongLongMask() (GH-13860)
2019-06-06 22:39:23 +02:00
Petr Viktorin
1e375c6269
bpo-36027: Really fix "incompatible pointer type" compiler warning (GH-13761)
...
Apologies for the earlier hasty attempt.
2019-06-03 02:28:29 +02:00
Petr Viktorin
e584cbff1e
bpo-36027 bpo-36974: Fix "incompatible pointer type" compiler warnings (GH-13758)
2019-06-03 01:08:14 +02:00
Mark Dickinson
c52996785a
bpo-36027: Extend three-argument pow to negative second argument (GH-13266)
2019-06-02 10:24:06 +01:00
Jeroen Demeyer
530f506ac9
bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async (GH-13464)
...
Automatically replace
tp_print -> tp_vectorcall_offset
tp_compare -> tp_as_async
tp_reserved -> tp_as_async
2019-05-30 19:13:39 -07:00
Inada Naoki
7d408697a9
remove unnecessary tp_dealloc (GH-13647)
2019-05-29 17:23:27 +09:00
Serhiy Storchaka
a5119e7d75
bpo-36957: Add _PyLong_Rshift() and _PyLong_Lshift(). (GH-13416)
2019-05-19 14:14:38 +03:00
Serhiy Storchaka
96aeaec647
bpo-36793: Remove unneeded __str__ definitions. (GH-13081)
...
Classes that define __str__ the same as __repr__ can
just inherit it from object.
2019-05-06 22:29:40 +03:00
stratakis
a10d426bab
bpo-36292: Mark unreachable code as such in long bitwise ops (GH-12333)
2019-03-18 18:59:20 +01:00
Serhiy Storchaka
6a44f6eef3
bpo-36048: Use __index__() instead of __int__() for implicit conversion if available. (GH-11952)
...
Deprecate using the __int__() method in implicit conversions of Python
numbers to C integers.
2019-02-25 17:57:58 +02:00
Sergey Fedoseev
ea6207d593
bpo-36063: Minor performance tweak in long_divmod(). (GH-11915)
2019-02-21 12:01:11 +02:00
Victor Stinner
6d43f6f081
bpo-35713: Split _Py_InitializeCore into subfunctions (GH-11650)
...
* Split _Py_InitializeCore_impl() into subfunctions: add multiple pycore_init_xxx() functions
* Preliminary sys.stderr is now set earlier to get an usable
sys.stderr ealier.
* Move code into _Py_Initialize_ReconfigureCore() to be able to call
it from _Py_InitializeCore().
* Split _PyExc_Init(): create a new _PyBuiltins_AddExceptions()
function.
* Call _PyExc_Init() earlier in _Py_InitializeCore_impl()
and new_interpreter() to get working exceptions earlier.
* _Py_ReadyTypes() now returns _PyInitError rather than calling
Py_FatalError().
* Misc code cleanup
2019-01-22 21:18:05 +01:00
Victor Stinner
b509d52083
bpo-35059: PyObject_INIT() casts to PyObject* (GH-10674)
...
PyObject_INIT() and PyObject_INIT_VAR() now cast their first argument
to PyObject*, as done in Python 3.7.
Revert partially commit b4435e20a9
.
2018-11-23 14:27:38 +01:00
Pablo Galindo
49c75a8086
bpo-35064 prefix smelly symbols that appear with COUNT_ALLOCS with _Py_ (GH-10152)
...
Configuring python with ./configure --with-pydebug CFLAGS="-D COUNT_ALLOCS -O0"
makes "make smelly" fail as some symbols were being exported without the "Py_" or
"_Py" prefixes.
2018-10-28 15:02:17 +00:00
Victor Stinner
b4435e20a9
bpo-35059: Convert PyObject_INIT() to function (GH-10077)
...
* Convert PyObject_INIT() and PyObject_INIT_VAR() macros to static
inline functions.
* Fix usage of these functions: cast to PyObject* or PyVarObject*.
2018-10-26 14:35:00 +02:00
Serhiy Storchaka
b2e2025941
bpo-33073: Rework int.as_integer_ratio() implementation (GH-9303)
...
* Simplify the C code.
* Simplify tests and make them more strict and robust.
* Add references in the documentation.
2018-10-19 23:46:31 +02:00
Zackery Spytz
7bb9cd0a67
bpo-34899: Fix a possible assertion failure due to int_from_bytes_impl() (GH-9705)
...
The _PyLong_FromByteArray() call in int_from_bytes_impl() was
unchecked.
2018-10-06 00:02:23 +03:00
Raymond Hettinger
73820a60cc
Fix compiler warning with a type cast (GH-9300)
2018-09-14 01:35:59 -07:00
Raymond Hettinger
00bc08ec11
Fix-up parenthesis, organization, and NULL check (GH-9297)
2018-09-14 01:00:11 -07:00
Lisa Roach
5ac704306f
bpo-33073: Adding as_integer_ratio to ints. (GH-8750)
2018-09-13 23:56:23 -07:00
Serhiy Storchaka
7cb7bcff20
bpo-20260: Implement non-bitwise unsigned int converters for Argument Clinic. (GH-8434)
2018-07-26 13:22:16 +03:00
Serhiy Storchaka
6405feecda
bpo-33012: Fix invalid function casts for long_long. (GH-6652)
...
long_long() was used with three function types:
PyCFunction, getter and unaryfunction.
2018-04-30 15:35:08 +03:00
Siddhesh Poyarekar
55edd0c185
bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. (GH-6030)
...
METH_NOARGS functions need only a single argument but they are cast
into a PyCFunction, which takes two arguments. This triggers an
invalid function cast warning in gcc8 due to the argument mismatch.
Fix this by adding a dummy unused argument.
2018-04-29 21:59:33 +03:00
Victor Stinner
dd431b32f4
PyLong_FromString(): fix Coverity CID 1424951 ( #4738 )
...
Explicitly cast digits (Py_ssize_t) to double to fix the following
false-alarm warning from Coverity:
"fsize_z = digits * log_base_BASE[base] + 1;"
CID 1424951: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
Dividing integer expressions "9223372036854775783UL" and "4UL", and
then converting the integer quotient to type "double". Any remainder,
or fractional part of the quotient, is ignored.
2017-12-08 00:06:55 +01:00
Serhiy Storchaka
29ba688034
bpo-31619: Fixed integer overflow in converting huge strings to int. ( #3884 )
2017-12-03 22:16:21 +02:00
Sanyam Khurana
28b624825e
bpo-16055: Fixes incorrect error text for int('1', base=1000) ( #4376 )
...
* bpo-16055: Fixes incorrect error text for int('1', base=1000)
* bpo-16055: Address review comments
2017-11-13 13:49:26 -08: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
stratakis
e8b1965639
bpo-23699: Use a macro to reduce boilerplate code in rich comparison functions (GH-793)
2017-11-02 20:32:54 +10:00
Serhiy Storchaka
85c0b8941f
bpo-31619: Fixed a ValueError when convert a string with large number of underscores ( #3827 )
...
to integer with binary base.
2017-10-03 14:13:44 +03:00
Barry Warsaw
b2e5794870
bpo-31338 ( #3374 )
...
* Add Py_UNREACHABLE() as an alias to abort().
* Use Py_UNREACHABLE() instead of assert(0)
* Convert more unreachable code to use Py_UNREACHABLE()
* Document Py_UNREACHABLE() and a few other macros.
2017-09-14 18:13:16 -07:00
Serhiy Storchaka
918403cfc3
bpo-29816: Shift operation now has less opportunity to raise OverflowError. ( #680 )
...
ValueError always is raised rather than OverflowError for negative counts.
Shifting zero with non-negative count always returns zero.
2017-03-30 09:47:07 +03:00
Serhiy Storchaka
ba85d69a3e
bpo-29878: Add global instances of int for 0 and 1. ( #852 )
2017-03-30 09:09:41 +03:00
Serhiy Storchaka
18b250f844
bpo-29793: Convert some builtin types constructors to Argument Clinic. ( #615 )
2017-03-19 08:51:07 +02:00
svelankar
390a0969c1
bpo-29749: Update int() docstring (GH-565)
...
The docstring did not properly represent the fact that the argument to int() was positional-only.
2017-03-08 16:29:01 -08: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
orenmn
86aa269646
remove 3 redundant casts in Objects/longobject.c ( #445 )
2017-03-06 08:42:47 +00: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
Serhiy Storchaka
196a7bc1ea
Issue #29421 : Make int.to_bytes() and int.from_bytes() slightly faster
...
(10-20% for small integers).
2017-02-02 16:54:45 +02:00
Serhiy Storchaka
495e8808d7
Issue #20185 : Converted the int class to Argument Clinic.
...
Based on patch by Vajrasky Kok.
2017-02-01 23:12:20 +02:00
Victor Stinner
de4ae3d486
Backed out changeset b9c9691c72c5
...
Issue #28858 : The change b9c9691c72c5 introduced a regression. It seems like
_PyObject_CallArg1() uses more stack memory than
PyObject_CallFunctionObjArgs().
2016-12-04 22:59:09 +01:00
Victor Stinner
27580c1fb5
Replace PyObject_CallFunctionObjArgs() with fastcall
...
* PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func)
* PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg)
PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires
extra work to "parse" C arguments to build a C array of PyObject*.
_PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate
memory on the C stack.
This change is part of the fastcall project. The change on listsort() is
related to the issue #23507 .
2016-12-01 14:43:22 +01:00
Serhiy Storchaka
460bd0d284
Issue #19569 : Compiler warnings are now emitted if use most of deprecated
...
functions.
2016-11-20 12:16:46 +02:00
Serhiy Storchaka
85b0f5beb1
Added the const qualifier to char* variables that refer to readonly internal
...
UTF-8 represenatation of Unicode objects.
2016-11-20 10:16:47 +02:00
Serhiy Storchaka
1a73bf365e
Issue #28701 : Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString.
...
The latter function is more readable, faster and doesn't raise exceptions.
2016-11-16 10:19:57 +02:00
Serhiy Storchaka
3b73ea1278
Issue #28701 : Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString.
...
The latter function is more readable, faster and doesn't raise exceptions.
2016-11-16 10:19:20 +02:00
Serhiy Storchaka
f4934ea77d
Issue #28701 : Replace PyUnicode_CompareWithASCIIString with _PyUnicode_EqualToASCIIString.
...
The latter function is more readable, faster and doesn't raise exceptions.
2016-11-16 10:17:58 +02:00
Serhiy Storchaka
b2e64f903d
Issue #28621 : Sped up converting int to float by reusing faster bits counting
...
implementation. Patch by Adrian Wielgosik.
2016-11-08 20:34:22 +02:00
Mark Dickinson
c1c4a64edb
Issue #27111 : Minor simplication to long_add and long_sub fast path code. Thanks Oren Milman.
2016-09-17 20:01:56 +01:00
Mark Dickinson
fba121fe9d
Issue #27441 : Remove some redundant assignments to ob_size in longobject.c. Thanks Oren Milman.
2016-09-17 19:44:13 +01:00
Mark Dickinson
92ca535626
Issue #27222 : various cleanups in long_rshift. Thanks Oren Milman.
2016-09-17 17:50:50 +01:00
Mark Dickinson
82cb124300
Issue #25221 : merge from 3.5.
2016-09-10 20:20:08 +01:00
Mark Dickinson
36820dd5a9
Issue #25221 : Fix corrupted result from PyLong_FromLong(0) when Python is compiled with NSMALLPOSINTS = 0.
2016-09-10 20:17:36 +01: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
Martin Panter
0be894b2f6
Issue #27895 : Spelling fixes (Contributed by Ville Skyttä).
2016-09-07 12:03:06 +00:00
Benjamin Peterson
2f8bfef158
replace PY_SIZE_MAX with SIZE_MAX
2016-09-07 09:26:18 -07:00
Benjamin Peterson
ca47063998
replace Py_(u)intptr_t with the c99 standard types
2016-09-06 13:47:26 -07:00
Benjamin Peterson
d953f8e10b
remove some silly defined() tests
2016-09-06 10:51:19 -07:00
Benjamin Peterson
af580dff4a
replace PY_LONG_LONG with long long
2016-09-06 10:46:49 -07:00
Benjamin Peterson
ed4aa83ff7
require a long long data type ( closes #27961 )
2016-09-05 17:44:18 -07:00
Raymond Hettinger
15f44ab043
Issue #27895 : Spelling fixes (Contributed by Ville Skyttä).
2016-08-30 10:47:49 -07:00
Mark Dickinson
82a95277b8
Issue #27870 : A left shift of zero by a large integer no longer attempts to allocate large amounts of memory.
2016-08-29 19:27:06 +01:00
Mark Dickinson
4e1de16f88
Issue #25402 : in int-to-decimal-string conversion, reduce intermediate storage requirements and relax restriction on converting large integers. Patch by Serhiy Storchaka.
2016-08-29 17:26:43 +01:00
Mark Dickinson
583c6e860c
Issue #27214 : Fix potential bug and remove useless optimization in long_invert. Thanks Oren Milman.
2016-08-29 16:40:29 +01:00
Mark Dickinson
b820d7f631
Issue #27792 : force int return type for modulo operations involving bools.
2016-08-22 12:24:46 +01:00
Mark Dickinson
1dc3c898a8
Untabify Objects/longobject.c.
2016-08-21 10:33:36 +01:00
Mark Dickinson
dc590a4cc3
Issue #25604 : Fix minor bug in integer true division, which could
...
have caused off-by-one-ulp results on certain platforms.
2016-08-21 10:23:23 +01:00
Victor Stinner
8bcf312d09
Issue #27786 : Simplify x_sub()
...
The z variable is known to be a fresh number which cannot be shared, Py_SIZE()
can be used directly to negate the number.
2016-08-17 19:48:33 +02:00
Martin Panter
8bde911115
Issue #27626 : Merge spelling fixes from 3.5
2016-07-28 01:30:58 +00:00
Martin Panter
eb9957065a
Issue #27626 : Spelling fixes in docs, comments and internal names
...
Based on patch by Ville Skyttä.
2016-07-28 01:11:04 +00:00
Serhiy Storchaka
e63e5d60ee
Issue #27073 : Removed redundant checks in long_add and long_sub.
...
Patch by Oren Milman.
2016-06-04 00:06:45 +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
1f364438ad
Issue #23640 : int.from_bytes() no longer bypasses constructors for subclasses.
2016-05-12 10:39:32 +03:00
Victor Stinner
f963c13597
longobject.c: fix compilation warning on Windows 64-bit
...
We know that Py_SIZE(b) is -1 or 1 an so fits into the sdigit type.
2016-03-23 18:36:54 +01:00
Yury Selivanov
e0b23095ee
Issues #26289 and #26315 : Optimize floor/modulo div for single-digit longs
...
Microbenchmarks show 2-2.5x improvement. Built-in 'divmod' function
is now also ~10% faster.
-m timeit -s "x=22331" "x//2;x//-3;x//4;x//5;x//-6;x//7;x//8;x//-99;x//100;"
with patch: 0.321 without patch: 0.633
-m timeit -s "x=22331" "x%2;x%3;x%-4;x%5;x%6;x%-7;x%8;x%99;x%-100;"
with patch: 0.224 without patch: 0.66
Big thanks to Serhiy Storchaka, Mark Dickinson and Victor Stinner for
thorow code reviews and algorithms improvements.
2016-02-11 10:26:27 -05:00
Yury Selivanov
a0fcaca4e1
Issue #26288 : Fix comment
2016-02-06 12:21:33 -05:00
Yury Selivanov
186c30b7ae
Issue #26288 : Optimize PyLong_AsDouble.
2016-02-05 19:40:01 -05:00
Serhiy Storchaka
bb6e4a0b31
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:53:19 +02: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
Victor Stinner
1285e5c805
Fix compiler warnings (uninitialized variables), false alarms in fact
2015-10-14 12:10:20 +02:00
Victor Stinner
199c9a6f4b
Fix long_format_binary()
...
Issue #25399 : Fix long_format_binary(), allocate bytes for the bytes writer.
2015-10-14 09:47:23 +02:00
Victor Stinner
be75b8cf23
Issue #25349 : Optimize bytes % int
...
Optimize bytes.__mod__(args) for integere formats: %d (%i, %u), %o, %x and %X.
_PyBytesWriter is now used to format directly the integer into the writer
buffer, instead of using a temporary bytes object.
Formatting is between 30% and 50% faster on a microbenchmark.
2015-10-09 22:43:24 +02:00
Victor Stinner
5783fd2c58
Issue #24999 : In longobject.c, use two shifts instead of ">> 2*PyLong_SHIFT" to
...
avoid undefined behaviour when LONG_MAX type is smaller than 60 bits.
This change should fix a warning with the ICC compiler.
2015-09-19 13:39:03 +02:00
Serhiy Storchaka
48e47aaa28
Issue #22486 : Added the math.gcd() function. The fractions.gcd() function now is
...
deprecated. Based on patch by Mark Dickinson.
2015-05-13 00:19:51 +03:00
R David Murray
861470c836
#16518 : Bring error messages in harmony with docs ("bytes-like object")
...
Some time ago we changed the docs to consistently use the term 'bytes-like
object' in all the contexts where bytes, bytearray, memoryview, etc are used.
This patch (by Ezio Melotti) completes that work by changing the error
messages that previously reported that certain types did "not support the
buffer interface" to instead say that a bytes-like object is required. (The
glossary entry for bytes-like object references the discussion of the buffer
protocol in the docs.)
2014-10-05 11:47:01 -04:00
Serhiy Storchaka
20b39b27d9
Removed redundant casts to `char *`.
...
Corresponding functions now accept `const char *` (issue #1772673 ).
2014-09-28 11:27:24 +03:00
Victor Stinner
12174a5dca
Issue #22156 : Fix "comparison between signed and unsigned integers" compiler
...
warnings in the Objects/ subdirectory.
PyType_FromSpecWithBases() and PyType_FromSpec() now reject explicitly negative
slot identifiers.
2014-08-15 23:17:38 +02:00
Victor Stinner
45e8e2f218
Issue #21490 : Add new C macros: Py_ABS() and Py_STRINGIFY()
...
Keep _Py_STRINGIZE() in PC/pyconfig.h to not introduce a dependency between
pyconfig.h and pymacros.h.
2014-05-14 17:24:35 +02:00
Mark Dickinson
0c346d827d
Issue #21193 : Make (e.g.,) pow(2, -3, 5) raise ValueError rather than TypeError. Patch by Josh Rosenberg.
2014-04-11 14:34:40 -04:00
Benjamin Peterson
1aca78da62
merge 3.3
2014-03-14 21:54:41 -05:00
Benjamin Peterson
45c9dceb56
fix c89 declaration order
2014-03-14 21:53:51 -05:00
Benjamin Peterson
dfa822811a
merge 3.3
2014-03-14 21:47:36 -05:00
Benjamin Peterson
041c38a790
don't do pointer arithmetic with signed numbers
2014-03-14 21:47:23 -05:00
Serhiy Storchaka
c836a28cc1
Issue #17576 : Removed deprecation warnings added in changeset 618cca51a27e.
2013-12-14 21:07:09 +02:00
Serhiy Storchaka
c4f3212abc
Issue #17576 : Deprecation warning emitted now when __int__() or __index__()
...
return not int instance. Introduced _PyLong_FromNbInt() and refactored
PyLong_As*() functions.
2013-12-11 21:26:36 +02:00
Serhiy Storchaka
31a655411a
Issue #17576 : Deprecation warning emitted now when __int__() or __index__()
...
return not int instance. Introduced _PyLong_FromNbInt() and refactored
PyLong_As*() functions.
2013-12-11 21:07:54 +02:00
Christian Heimes
d3afe781b1
Silence expression result unused warnings with clang.
...
The PyObject_INIT() macros returns obj:
../cpython/Objects/methodobject.c:32:23: warning: expression result unused [-Wunused-value]
PyObject_INIT(op, &PyCFunction_Type);
^~
../cpython/Include/objimpl.h:139:69: note: expanded from macro 'PyObject_INIT'
( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
^
1 warning generated.
2013-12-04 09:27:47 +01:00
Serhiy Storchaka
c679227e31
Issue #1772673 : The type of `char*` arguments now changed to `const char*`.
2013-10-19 21:03:34 +03:00
Tim Peters
9259c21a63
Issue #19171 : speed some cases of 3-argument long pow().
...
Reduce the base by the modulus when the base is larger than
the modulus. This can unboundedly speed the "startup costs"
of doing modular exponentiation, particularly in cases where
the base is much larger than the modulus. Original patch
by Armin Rigo, inspired by https://github.com/pyca/ed25519 .
Merged from 3.3.
2013-10-05 16:55:38 -05:00
Tim Peters
81a93159d7
Issue #19171 : speed some cases of 3-argument long pow().
...
Reduce the base by the modulus when the base is larger than
the modulus. This can unboundedly speed the "startup costs"
of doing modular exponentiation, particularly in cases where
the base is much larger than the modulus. Original patch
by Armin Rigo, inspired by https://github.com/pyca/ed25519 .
2013-10-05 16:53:52 -05:00
Serhiy Storchaka
46e1ce214b
Issue #18783 : Removed existing mentions of Python long type in docstrings,
...
error messages and comments.
2013-08-27 20:17:03 +03:00
Serhiy Storchaka
9594942716
Issue #18783 : Removed existing mentions of Python long type in docstrings,
...
error messages and comments.
2013-08-27 19:40:23 +03:00
Antoine Pitrou
9ed5f27266
Issue #18722 : Remove uses of the "register" keyword in C code.
2013-08-13 20:18:52 +02:00
Serhiy Storchaka
579ddc2fd4
Issue #16741 : Fix an error reporting in int().
2013-08-03 21:14:05 +03:00
Serhiy Storchaka
f6d0aeeadc
Issue #16741 : Fix an error reporting in int().
2013-08-03 20:55:06 +03:00
Mark Dickinson
02515f7a3a
Minor consistency fixes for some longobject.c exception messages:
...
- replace 'long int' / 'long' by 'int'
- fix capitalization of "Python" in PyLong_AsUnsignedLong
- "is too large" -> "too large", for consistency with other messages.
2013-08-03 12:08:22 +01:00
Victor Stinner
1c8f059019
Issue #18520 : Add a new PyStructSequence_InitType2() function, same than
...
PyStructSequence_InitType() except that it has a return value (0 on success,
-1 on error).
* PyStructSequence_InitType2() now raises MemoryError on memory allocation failure
* Fix also some calls to PyDict_SetItemString(): handle error
2013-07-22 22:24:54 +02:00
Victor Stinner
08a80b11ad
longobject.c: add an assertion to ensure that MEDIUM_VALUE() is only called on
...
small integers (0 or 1 digit)
2013-07-17 22:33:42 +02:00
Victor Stinner
8aed6f1c7d
Issue #18408 : Rewrite NEGATE() macro in longobject.c to handle PyLong_FromLong() failure
2013-07-17 22:31:17 +02:00
Victor Stinner
640c35ce13
Reuse Py_MIN and Py_MAX macros: remove duplicate MIN/MAX macros
...
multiprocessing.h: remove unused MIN and MAX macros
2013-06-04 23:14:37 +02:00
Victor Stinner
8f674ccd64
Close #17694 : Add minimum length to _PyUnicodeWriter
...
* Add also min_char attribute to _PyUnicodeWriter structure (currently unused)
* _PyUnicodeWriter_Init() has no more argument (except the writer itself):
min_length and overallocate must be set explicitly
* In error handlers, only enable overallocation if the replacement string
is longer than 1 character
* CJK decoders don't use overallocation anymore
* Set min_length, instead of preallocating memory using
_PyUnicodeWriter_Prepare(), in many decoders
* _PyUnicode_DecodeUnicodeInternal() checks for integer overflow
2013-04-17 23:02:17 +02:00
Antoine Pitrou
8ad5b07ccb
Issue #17173 : Remove uses of locale-dependent C functions (isalpha() etc.) in the interpreter.
...
I've left a couple of them in: zlib (third-party lib), getaddrinfo.c
(doesn't include Python.h, and probably obsolete), _sre.c (legitimate
use for the re.LOCALE flag), mpdecimal (needs to build without Python.h).
2013-02-09 23:16:51 +01:00
Antoine Pitrou
c73c561181
Issue #17173 : Remove uses of locale-dependent C functions (isalpha() etc.) in the interpreter.
...
I've left a couple of them in: zlib (third-party lib), getaddrinfo.c
(doesn't include Python.h, and probably obsolete), _sre.c (legitimate
use for the re.LOCALE flag), mpdecimal (needs to build without Python.h).
2013-02-09 23:14:42 +01:00
Antoine Pitrou
4de7457009
Issue #17173 : Remove uses of locale-dependent C functions (isalpha() etc.) in the interpreter.
...
I've left a couple of them in: zlib (third-party lib), getaddrinfo.c
(doesn't include Python.h, and probably obsolete), _sre.c (legitimate
use for the re.LOCALE flag).
2013-02-09 23:11:27 +01:00
Mark Dickinson
07c7136524
Issue #16772 : in int(x, base), non-integer bases must have an __index__ method.
2013-01-27 10:17:52 +00:00
Serhiy Storchaka
9101e23ff6
Issue #15989 : Fix several occurrences of integer overflow
...
when result of PyLong_AsLong() narrowed to int without checks.
This is a backport of changesets 13e2e44db99d and 525407d89277.
2013-01-19 12:41:45 +02:00
Serhiy Storchaka
441d30fac7
Issue #15989 : Fix several occurrences of integer overflow
...
when result of PyLong_AsLong() narrowed to int without checks.
This is a backport of changesets 13e2e44db99d and 525407d89277.
2013-01-19 12:26:26 +02:00
Serhiy Storchaka
7898043868
Issue #15989 : Fix several occurrences of integer overflow
...
when result of PyLong_AsLong() narrowed to int without checks.
2013-01-15 01:12:17 +02:00
Serhiy Storchaka
c819b077bb
Issue #16761 : Raise TypeError when int() called with base argument only.
2012-12-28 10:09:54 +02:00
Serhiy Storchaka
00e2843115
Issue #16761 : Raise TypeError when int() called with base argument only.
2012-12-28 10:02:42 +02:00
Serhiy Storchaka
0b386d5247
Issue #16761 : Raise TypeError when int() called with base argument only.
2012-12-28 09:42:11 +02:00
Benjamin Peterson
513762fe9c
use more specific type
2012-12-26 16:43:33 -06:00
Gregory P. Smith
a689e524e7
Test for issue16772 and redoes the previous fix to accept __index__-aware
...
objects as the base by using PyNumber_AsSsize_t similar to round().
2012-12-25 22:38:32 -08:00
Gregory P. Smith
4fbbf8c0a3
Fixes issue #16772 : int() constructor second argument (base) must be an int.
...
Consistent with the behavior in Python 2.
2012-12-25 13:05:31 -08:00
Mark Dickinson
e453e4c007
Issue 16280: Drop questionable special-casing of null pointer in PyLong_FromVoidPtr.
2012-10-18 22:18:42 +01:00
Mark Dickinson
5cb65917e1
Issue #16277 : merge fix from 3.3
2012-10-18 19:53:45 +01:00
Mark Dickinson
44362a88ad
Issue #16277 : merge fix from 3.2
2012-10-18 19:53:28 +01:00
Mark Dickinson
91044799f7
Issue #16277 : in PyLong_FromVoidPtr, add missing branch for sizeof(void*) <= sizeof(long).
2012-10-18 19:21:43 +01:00
Christian Heimes
743e0cd6b5
Issue #16166 : Add PY_LITTLE_ENDIAN and PY_BIG_ENDIAN macros and unified
...
endianess detection and handling.
2012-10-17 23:52:17 +02:00
Chris Jerdonek
4a7df9aba9
Issue #14783 : Merge changes from 3.3.
2012-10-07 15:02:16 -07:00
Chris Jerdonek
042fa653ab
Issue #14783 : Merge changes from 3.2.
2012-10-07 14:56:27 -07:00
Chris Jerdonek
83fe2e1c22
Issue #14783 : Improve int() docstring and also str(), range(), and slice().
...
This commit rewrites the docstring for int() to incorporate the documentation
changes made in issue #16036 . It also switches the docstrings for int(),
str(), range(), and slice() to use multi-line signatures.
2012-10-07 14:48:36 -07:00
Mark Dickinson
cf46d62fcb
Issue #16096 : port fix from 3.3
2012-10-06 18:50:19 +01:00
Mark Dickinson
fc9adb62fb
Issue #16096 : Fix signed overflow in Objects/longobject.c. Thanks Serhiy Storchaka.
2012-10-06 18:50:02 +01:00
Victor Stinner
9cc98c93a7
long_to_decimal_string_internal() doesn't need to write the final NULL character
2012-10-04 02:43:02 +02:00
Mark Dickinson
5710c2a3e8
Issue 15959: Merge from 3.2.
2012-09-20 21:30:34 +01:00
Mark Dickinson
c286e58044
Issue 15959: Fix type mismatch for quick{_neg}_int_allocs. Thanks Serhiy Storchaka.
2012-09-20 21:29:28 +01:00
Christian Heimes
7ae251a025
Fix out of bounds read in long_new() for empty bytes with an explicit base. int(b'', somebase) calls PyLong_FromString() with char* of length 1 but the function accesses the first argument at offset 1. CID 715359
2012-09-12 15:32:06 +02:00
Christian Heimes
79b97ee2ab
Fix out of bounds read in long_new() for empty bytes with an explicit base. int(b'', somebase) calls PyLong_FromString() with char* of length 1 but the function accesses the first argument at offset 1. CID 715359
2012-09-12 15:31:43 +02:00
Christian Heimes
110ac16b9f
Fixed resource leak to scratch when _PyUnicodeWriter_Prepare fails
2012-09-10 02:51:27 +02:00