Commit Graph

1514 Commits

Author SHA1 Message Date
Mark Dickinson d3e323215c Refactor some longobject internals: PyLong_AsDouble and _PyLong_AsScaledDouble
(the latter renamed to _PyLong_Frexp) now use the same core code.  The
exponent produced by _PyLong_Frexp now has type Py_ssize_t instead of the
previously used int, and no longer needs scaling by PyLong_SHIFT.  This
frees the math module from having to know anything about the PyLong
implementation.  This closes issue #5576.
2010-01-02 14:45:40 +00:00
Georg Brandl 740cdc3a9f #7033: add new API function PyErr_NewExceptionWithDoc, for easily giving new exceptions a docstring. 2009-12-28 08:34:58 +00:00
Mark Dickinson 12748b003c Issue #7518: Move substitute definitions of C99 math functions from
pymath.c to Modules/_math.c.
2009-12-21 15:22:00 +00:00
Mark Dickinson e31d300664 Issue #7528: Backport PyLong_AsLongAndOverflow from py3k to trunk.
Thanks Case Van Horsen for the patch.
2009-12-21 11:21:25 +00:00
Benjamin Peterson 3095d20a53 initialize to NULL 2009-12-13 21:21:43 +00:00
Mark Dickinson fd25634715 Replace the size check for PyMem_MALLOC and PyMem_REALLOC with an almost
equivalent[*] check that doesn't produce compiler warnings about a 'x < 0'
check on an unsigned type.

[*] it's equivalent for inputs of type size_t or Py_ssize_t, or any smaller
unsigned or signed integer type.
2009-12-10 10:36:32 +00:00
Ronald Oussoren a254302f52 Fix for issue 7452: HAVE_GCC_ASM_FOR_X87 gets set when doing a universal build on
an i386 based machine, but should only be active when compiling the x86 part of
the universal binary.
2009-12-08 16:32:52 +00:00
Benjamin Peterson 4f51baf466 post release version bump 2009-12-05 18:40:02 +00:00
Benjamin Peterson d78cec5f39 bump version to 2.7a1 2009-12-05 17:47:56 +00:00
Ronald Oussoren 7072f74dc8 Fix for issue #7416: SIZEOF_UINTPTR_T can be invalid when configuring a
multi-architecture build (in particular when the architectures don't share
a common pointer size).

Fixed the same issue for SIZEOF_PTHREAD_T.

(No update to the NEWS file because this is a bugfix for an as yet unreleased
feature)
2009-12-01 15:54:01 +00:00
Mark Dickinson 31f0cfef0e Include ieeefp.h (when available) in pyport.h instead of individually in
Objects/floatobject.c and Objects/complexobject.c.  This should silence
compiler warnings about implicit declaration of the 'finite' function
on Solaris.
2009-11-28 12:30:36 +00:00
Mark Dickinson 845688d0c6 Enable short float repr! 2009-11-18 20:14:57 +00:00
Mark Dickinson bd15a06fd3 Issue #7117, continued: Change round implementation to use the correctly-rounded
string <-> float conversions;  this makes sure that the result of the round
operation is correctly rounded, and hence displays nicely using the new float
repr.
2009-11-18 19:33:35 +00:00
Mark Dickinson 82864d1ab1 Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
PyFormat_FromStringV and PyErr_Format.
2009-11-15 16:18:58 +00:00
Mark Dickinson 3e1eb0f715 Issue #7117: Backport missing pystrtod.h declarations from py3k. 2009-10-26 21:09:09 +00:00
Eric Smith c1bdf89145 Finished removing _PyOS_double_to_string, as mentioned in issue 7117. 2009-10-26 17:46:17 +00:00
Mark Dickinson f325407038 Issue #7117: temporarily disable the short float repr while the
pieces are being assembled.  To re-enable, define the preprocessor
symbol PY_SHORT_FLOAT_REPR
2009-10-24 15:54:35 +00:00
Mark Dickinson 1d6e2e1833 Issue #7117 (backport py3k float repr) continued:
- add double endianness detection to configure script
 - add configure-time check to see whether we can use inline
   assembly to get and set x87 control word in configure script
 - add functions to get and set x87 control word in Python/pymath.c
 - add pyport.h logic to determine whether it's safe to use the
   short float repr or not
2009-10-24 13:28:38 +00:00
Mark Dickinson bb28285ea2 Issue #7117: Prepare for backport of py3k float repr.
Add the Python/dtoa.c file containing the main algorithms;
add corresponding include file and include in Python.h;
include license information for Python/dtoa.c;
add dtoa.c and dtoa.h to Makefile.
2009-10-24 12:13:30 +00:00
Kristján Valur Jónsson 02ca57ce4c http://bugs.python.org/issue6836
The debug memory api now keeps track of which external API (PyMem_* or PyObject_*) was used to allocate each block and treats any API violation as an error.  Added separate _PyMem_DebugMalloc functions for the Py_Mem API instead of having it use the _PyObject_DebugMalloc functions.
2009-09-28 13:12:38 +00:00
Mark Dickinson aa2adc828a Issue #6713: Improve performance of str(n) and repr(n) for integers n
(up to 3.1 times faster in tests), by special-casing base 10 in
_PyLong_Format.  (Backport of r74851 from py3k.)
2009-09-16 22:10:56 +00:00
Thomas Wouters c4dcb3801e Fix issue #1590864, multiple threads and fork() can cause deadlocks, by
acquiring the import lock around fork() calls. This prevents other threads
from having that lock while the fork happens, and is the recommended way of
dealing with such issues. There are two other locks we care about, the GIL
and the Thread Local Storage lock. The GIL is obviously held when calling
Python functions like os.fork(), and the TLS lock is explicitly reallocated
instead, while also deleting now-orphaned TLS data.

This only fixes calls to os.fork(), not extension modules or embedding
programs calling C's fork() directly. Solving that requires a new set of API
functions, and possibly a rewrite of the Python/thread_*.c mess. Add a
warning explaining the problem to the documentation in the mean time.

This also changes behaviour a little on AIX. Before, AIX (but only AIX) was
getting the import lock reallocated, seemingly to avoid this very same
problem. This is not the right approach, because the import lock is a
re-entrant one, and reallocating would do the wrong thing when forking while
holding the import lock.

Will backport to 2.6, minus the tiny AIX behaviour change.
2009-09-16 19:55:54 +00:00
Mark Dickinson 6b3f1ef190 Issue #6848: Fix curses module build failure on OS X 10.6. 2009-09-06 21:21:05 +00:00
Mark Dickinson 2f865b962c Issue #6347: Add inttypes.h to the pyport.h #includes; fixes a build
failure on HP-UX 11.00.
2009-06-30 15:32:30 +00:00
Mark Dickinson 1dcc38456f Remove unused stdint.h includes 2009-06-28 22:37:13 +00:00
Benjamin Peterson 94819cf47c remove some unused symtable constants 2009-06-23 03:01:56 +00:00
Benjamin Peterson d9920c255d remove tmpname support since it's no longer used 2009-06-21 23:03:36 +00:00
Alexandre Vassalotti a6e3474d02 Add const qualifier to PyErr_SetFromErrnoWithFilename and to
PyErr_SetFromErrnoWithUnicodeFilename.
2009-06-12 20:57:12 +00:00
Georg Brandl 944f684ce6 Allow multiple context managers in one with statement, as proposed
in http://codereview.appspot.com/53094 and accepted by Guido.

The construct is transformed into multiple With AST nodes so that
there should be no problems with the semantics.
2009-05-25 21:02:56 +00:00
Benjamin Peterson 1880d8b823 add a SETUP_WITH opcode
It speeds up the with statement and correctly looks up the special
methods involved.
2009-05-25 13:13:44 +00:00
Jeffrey Yasskin 655d835415 Issue #6042:
lnotab-based tracing is very complicated and isn't documented very well.  There
were at least 3 comment blocks purporting to document co_lnotab, and none did a
very good job. This patch unifies them into Objects/lnotab_notes.txt which
tries to completely capture the current state of affairs.

I also discovered that we've attached 2 layers of patches to the basic tracing
scheme. The first layer avoids jumping to instructions that don't start a line,
to avoid problems in if statements and while loops.  The second layer
discovered that jumps backward do need to trace at instructions that don't
start a line, so it added extra lnotab entries for 'while' and 'for' loops, and
added a special case for backward jumps within the same line. I replaced these
patches by just treating forward and backward jumps differently.
2009-05-23 23:23:01 +00:00
Hirokazu Yamamoto b24bb27d22 Issue #3527: Removed Py_WIN_WIDE_FILENAMES which is not used any more. 2009-05-17 02:52:09 +00:00
Jeffrey Yasskin f7f858d141 Issue 5954, PyFrame_GetLineNumber:
Most uses of PyCode_Addr2Line
(http://www.google.com/codesearch?q=PyCode_Addr2Line) are just trying to get
the line number of a specified frame, but there's no way to do that directly.
Forcing people to go through the code object makes them know more about the
guts of the interpreter than they should need.

The remaining uses of PyCode_Addr2Line seem to be getting the line from a
traceback (for example,
http://www.google.com/codesearch/p?hl=en#u_9_nDrchrw/pygame-1.7.1release/src/base.c&q=PyCode_Addr2Line),
which is replaced by the tb_lineno field.  So we may be able to deprecate
PyCode_Addr2Line entirely for external use.
2009-05-08 22:23:21 +00:00
Jeffrey Yasskin 1aa4700234 PyCode_NewEmpty:
Most uses of PyCode_New found by http://www.google.com/codesearch?q=PyCode_New
are trying to build an empty code object, usually to put it in a dummy frame
object. This patch adds a PyCode_NewEmpty wrapper which lets the user specify
just the filename, function name, and first line number, instead of also
requiring lots of code internals.
2009-05-08 21:51:06 +00:00
Benjamin Peterson 399e4c4f8f add _PyObject_LookupSpecial to handle fetching special method lookup 2009-05-08 03:06:00 +00:00
Eric Smith a985a3aee4 Issue #5920: Changed format.__float__ and complex.__float__ to use a precision of 12 when using the empty presentation type. This more closely matches str()'s behavior and reduces surprises when adding alignment flags to an empty format string. Patch by Mark Dickinson. 2009-05-05 18:26:08 +00:00
Antoine Pitrou 653dece278 Issue #4426: The UTF-7 decoder was too strict and didn't accept some legal sequences.
Patch by Nick Barnes and Victor Stinner.
2009-05-04 18:32:32 +00:00
Eric Smith 9139cc6a3b Issue #1588: Add complex.__format__. 2009-04-30 00:58:58 +00:00
Eric Smith cac7af6863 Issue #5793: rationalize isdigit / isalpha / tolower, etc. Will port to py3k. Should fix Windows buildbot errors. 2009-04-27 19:04:37 +00:00
Eric Smith 068f06568b Issue #5835, deprecate PyOS_ascii_formatd.
If anyone wants to clean up the documentation, feel free. It's my first documentation foray, and it's not that great.

Will port to py3k with a different strategy.
2009-04-25 21:40:15 +00:00
Eric Smith aca19e6a74 Backport of some of the work in r71665 to trunk. This reworks much of
int, long, and float __format__(), and it keeps their implementation
in sync with py3k.

Also added PyOS_double_to_string. This is the "fallback" version
that's also available in trunk, and should be kept in sync with that
code. I'll add an issue to document PyOS_double_to_string in the C
API.

There are many internal cleanups. Externally visible changes include:

- Implement PEP 378, Format Specifier for Thousands Separator, for
  floats, ints, and longs.

- Issue #5515: 'n' formatting for ints, longs, and floats handles
  leading zero formatting poorly.

- Issue #5772: For float.__format__, don't add a trailing ".0" if
  we're using no type code and we have an exponent.
2009-04-22 13:29:05 +00:00
Ronald Oussoren 6c0b872f85 Fix for issue5657. 2009-04-19 10:38:20 +00:00
Benjamin Peterson 01c6e6fb35 many more types to initialize (I had to expose some of them) 2009-04-18 22:15:26 +00:00
Mark Dickinson 8e5446f902 Backport r71704 (add configure check for C99 round function) to trunk. 2009-04-18 14:41:37 +00:00
Matthias Klose 91a3b9e4f0 Issue #1113244: Py_XINCREF, Py_DECREF, Py_XDECREF: Add `do { ... } while (0)'
to avoid compiler warnings.
2009-04-05 21:19:13 +00:00
Matthias Klose 0610e0808b - Py_DECREF: Add `do { ... } while (0)' to avoid compiler warnings.
(avoiding brown paper typo this time)
2009-04-05 12:43:08 +00:00
Benjamin Peterson ea0d7444c8 revert r71159 since it broke the build 2009-04-04 16:05:51 +00:00
Matthias Klose 8212a82371 - Py_DECREF: Add `do { ... } while (0)' to avoid compiler warnings. 2009-04-04 15:51:23 +00:00
Antoine Pitrou 789be0c0a0 Issue #2396: backport the memoryview object. 2009-04-02 21:18:34 +00:00
Brett Cannon 238cedcd63 Fix two issues introduced by issue #71031 by changing the signature of
PyImport_AppendInittab() to take a const char *.
2009-04-02 03:34:53 +00:00
Antoine Pitrou f8387af262 Issue #4688: Add a heuristic so that tuples and dicts containing only
untrackable objects are not tracked by the garbage collector. This can
reduce the size of collections and therefore the garbage collection overhead
on long-running programs, depending on their particular use of datatypes.

(trivia: this makes the "binary_trees" benchmark from the Computer Language
Shootout 40% faster)
2009-03-23 18:41:45 +00:00
Mark Dickinson f35f8044e4 Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
integer types T, not just those for which "unsigned T" is legal.
2009-03-20 23:16:14 +00:00
Mark Dickinson efc82f7e8e Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Backport of r70459.
2009-03-20 15:51:55 +00:00
Jeffrey Yasskin 68d6852006 Backport r69961 to trunk, replacing JUMP_IF_{TRUE,FALSE} with
POP_JUMP_IF_{TRUE,FALSE} and JUMP_IF_{TRUE,FALSE}_OR_POP. This avoids executing
a POP_TOP on each conditional and sometimes allows the peephole optimizer to
skip a JUMP_ABSOLUTE entirely. It speeds up list comprehensions significantly.
2009-02-28 19:03:21 +00:00
Benjamin Peterson 5781f32b4f remove some PyBytes_* aliases that are not in 3.x 2009-02-16 21:09:09 +00:00
Mark Dickinson bcf6b18eb7 A few more minor fixes in longobject.c 2009-02-15 15:48:39 +00:00
Mark Dickinson 2ffb26fb83 Issue #5260: Various portability and standards compliance fixes, optimizations
and cleanups in Objects/longobject.c.  The most significant change is that
longs now use less memory:  average savings are 2 bytes per long on 32-bit
systems and 6 bytes per long on 64-bit systems.  (This memory saving already
exists in py3k.)
2009-02-15 10:13:41 +00:00
Hirokazu Yamamoto bcd3ea86a3 Issue #5204: Define _PyVerify_fd on VC6 to make
test_fdopen (test_os.py) pass.
2009-02-11 04:13:06 +00:00
Kristján Valur Jónsson 6a743d3694 Issue 4804. Add a function to test the validity of file descriptors on Windows, and stop using global runtime settings to silence the warnings / assertions. 2009-02-10 13:32:24 +00:00
Mark Dickinson c97c9096ed Issue #4575: fix Py_IS_INFINITY macro to work correctly on x87 FPUs.
It now forces its argument to double before testing for infinity.
2009-02-09 14:18:43 +00:00
Raymond Hettinger b516370bcb Issue 1242657: list(obj) can swallow KeyboardInterrupt. 2009-02-02 21:50:13 +00:00
Amaury Forgeot d'Arc a40d573664 #3720: Interpreter crashes when an evil iterator removes its own next function.
Now the slot is filled with a function that always raises.

Will not backport: extensions compiled with 2.6.x would not run on 2.6.0.
2009-01-12 23:36:55 +00:00
Jeffrey Yasskin d89f5b20b2 Fix issue 4884, preventing a crash in the socket code when python is compiled
with llvm-gcc and run with a glibc <2.10.
2009-01-09 16:47:07 +00:00
Marc-André Lemburg 3741bfdd3c Fix #4846 (Py_UNICODE_ISSPACE causes linker error) by moving the declaration
into the extern "C" section.

Add a few more comments and apply some minor edits to make the file contents
fit the original structure again.
2009-01-05 19:43:35 +00:00
Mark Dickinson 1bf6401ab2 Use C99 'isfinite' macro in preference to BSD-derived 'finite' function. 2009-01-04 19:53:00 +00:00
Mark Dickinson 0ebfedf38e Fix HAVE_DECL_ISINF/ISNAN test (again). 2009-01-04 17:02:05 +00:00
Mark Dickinson 41fbae1ac9 Oops. Need to check not only that HAVE_DECL_ISINF is defined, but also
that it's equal to 1.  (If isinf isn't defined, HAVE_DECL_ISINF is
defined to be 0, rather than being undefined.)
2009-01-04 16:06:40 +00:00
Mark Dickinson d181e3a246 isinf and isnan are macros, not functions; fix configure script
to use AC_CHECK_DECLS instead of AC_CHECK_FUNCS for these.
(See discussion in issue #4506)
2009-01-04 13:57:26 +00:00
Benjamin Peterson fd9633ed36 fix WORD_BIGEDIAN declaration in Universal builds; fixes #4060 and #4728 2008-12-28 15:37:31 +00:00
Alexandre Vassalotti a925bed208 Sort UCS-2/UCS-4 name mangling list. 2008-12-28 02:10:35 +00:00
Alexandre Vassalotti d8f8ee4af8 Fix name mangling of PyUnicode_ClearFreeList. 2008-12-28 01:52:58 +00:00
Antoine Pitrou d0c3515bc5 Issue #2183: Simplify and optimize bytecode for list comprehensions. 2008-12-17 00:38:28 +00:00
Benjamin Peterson 44a90c95ce move unprefixed error into .c file 2008-10-30 23:59:18 +00:00
Amaury Forgeot d'Arc 07d539d08b #4122: On Windows, Py_UNICODE_ISSPACE cannot be used in an extension module:
compilation fails with "undefined reference to _Py_ascii_whitespace"

Will backport to 2.6.
2008-10-14 21:47:22 +00:00
Barry Warsaw 12582c9225 Bump to 2.7a0 2008-10-02 03:33:51 +00:00
Barry Warsaw afa1436958 Bumping to 2.6 final. 2008-10-01 21:46:40 +00:00
Andrew MacIntyre 41c56b5ea1 build_os2emx.patch in issue 3868 - update OS/2 EMX makefile and config files
Part of source_os2emx.patch in issue 3868:
  Include/pystrcmp.h:  OS/2 has same C APIs as Windows
  Lib/test/test_io.py: OS/2 has same behaviour as Windows for this test

Reviewed by Amaury Forgeot d'Arc
2008-09-22 14:23:45 +00:00
Barry Warsaw 0c5ca57369 done with 2.6rc2 2008-09-18 05:34:31 +00:00
Barry Warsaw 6af16190f6 Bumping to 2.6rc2 2008-09-18 04:33:43 +00:00
Barry Warsaw dfd6b86d6b post release updates 2008-09-13 01:12:18 +00:00
Barry Warsaw f5f9d99974 Fix the release level 2008-09-12 23:35:48 +00:00
Barry Warsaw 1e62aec3ed Bumping to 2.6rc1 2008-09-12 23:25:57 +00:00
Antoine Pitrou d4ae97bc38 #3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
exception afterwards (for a subsequent parameter), the user code will
not call PyBuffer_Release() and memory will leak.

Reviewed by Amaury Forgeot d'Arc.
2008-08-29 18:39:48 +00:00
Antoine Pitrou 0668c62677 Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
match Python 2.5 speed despite the __instancecheck__ / __subclasscheck__
mechanism. In the process, fix a bug where isinstance() and issubclass(),
when given a tuple of classes as second argument, were looking up
__instancecheck__ / __subclasscheck__ on the tuple rather than on each
type object.

Reviewed by Benjamin Peterson and Raymond Hettinger.
2008-08-26 22:42:08 +00:00
Benjamin Peterson 14cb6bcf2b sort of backport 66038 by aliasing PyObject_Bytes to PyObject_Str 2008-08-26 17:08:40 +00:00
Barry Warsaw 6a0b559d26 done with the release 2008-08-21 02:12:56 +00:00
Barry Warsaw 07a4a3851d Bump to 2.6b3. 2008-08-21 01:15:08 +00:00
Guido van Rossum 69ed1011aa Hopeful fix for issue 1878: remove Py_TPFLAGS_HAVE_VERSION_TAG from
Py_TPFLAGS_DEFAULT when not building the core.
2008-08-19 20:13:02 +00:00
Benjamin Peterson 6b094a4258 fix a little typo 2008-08-19 19:27:53 +00:00
Benjamin Peterson 025d9392a6 fix compile errors 2008-08-17 01:27:30 +00:00
Benjamin Peterson e0d4c7b5bd expose PySTEntry.nested so the symtable module will work 2008-08-17 01:09:17 +00:00
Martin v. Löwis f91d46a17d Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
by denying s# to parse objects that have a releasebuffer procedure,
and introducing s*.

More module might need to get converted to use s*.
2008-08-12 14:49:50 +00:00
Gregory P. Smith 0470bab697 Issue #2620: Overflow checking when allocating or reallocating memory
was not always being done properly in some python types and extension
modules.  PyMem_MALLOC, PyMem_REALLOC, PyMem_NEW and PyMem_RESIZE have
all been updated to perform better checks and places in the code that
would previously leak memory on the error path when such an allocation
failed have been fixed.
2008-07-22 04:46:32 +00:00
Barry Warsaw ecb8c7991d Post release cleanup 2008-07-18 03:36:18 +00:00
Barry Warsaw daddf03f77 Bumping to 2.6b2 2008-07-18 03:20:07 +00:00
Nick Coghlan 53663a695e Issue 2235: __hash__ is once again inherited by default, but inheritance can be blocked explicitly so that collections.Hashable remains meaningful 2008-07-15 14:27:37 +00:00
Alexandre Vassalotti 8d412f36b5 Issue #3274: Use a less common identifier for the temporary variable
in Py_CLEAR().
2008-07-13 20:42:44 +00:00
Amaury Forgeot d'Arc 2252d11c08 #3342: In tracebacks, printed source lines were not indented since r62555.
#3343: Py_DisplaySourceLine should be a private function. Rename it to _Py_DisplaySourceLine.
2008-07-11 21:45:06 +00:00
Gregory P. Smith 2fe77060eb - Issue #2862: Make int and float freelist management consistent with other
freelists.  Changes their CompactFreeList apis into ClearFreeList apis and
  calls them via gc.collect().
2008-07-06 03:35:58 +00:00
Raymond Hettinger 9c437af4eb Revert 64424, 64438, and 64439. 2008-06-24 22:46:07 +00:00