Commit Graph

2620 Commits

Author SHA1 Message Date
Georg Brandl dfe5dc8455 Make Python compile with --disable-unicode. 2008-01-07 18:16:36 +00:00
Georg Brandl aed6c66aa8 patch #1668: clarify envvar docs; rename THREADDEBUG to PYTHONTHREADDEBUG. 2008-01-07 17:25:53 +00:00
Georg Brandl 2da0fceba7 Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode. 2008-01-07 17:09:35 +00:00
Georg Brandl 882ed5595b #1755: typo. 2008-01-07 16:41:57 +00:00
Georg Brandl 9fcd8ceb74 Fix C++-style comment. 2008-01-05 17:49:17 +00:00
Jeffrey Yasskin 9871d8fe22 Continue rolling back pep-3141 changes that changed behavior from 2.5. This
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.
2008-01-05 08:47:13 +00:00
Guido van Rossum 3b83549ea0 Patch #1725 by Mark Dickinson, fixes incorrect conversion of -1e1000
and adds errors for -0x.
2008-01-05 00:59:59 +00:00
Christian Heimes 123d5c9396 Moved include "Python.h" in front of other imports to silence a warning. 2008-01-04 03:15:05 +00:00
Amaury Forgeot d'Arc e0b7695286 Partial port of r59682 from py3k.
On Windows, when import fails to load a dll module, the message says
"error code 193" instead of a more informative text.

It turns out that FormatMessage needs additional parameters for some error codes.
For example: 193 means "%1 is not a valid Win32 application".
Since it is impossible to know which parameter to pass, we use
FORMAT_MESSAGE_IGNORE_INSERTS to get the raw message, which is still better
than the number.
2008-01-04 02:04:15 +00:00
Christian Heimes 000a074c95 Modified PyImport_Import and PyImport_ImportModule to always use absolute imports by calling __import__ with an explicit level of 0
Added a new API function PyImport_ImportModuleNoBlock. It solves the problem with dead locks when mixing threads and imports
2008-01-03 22:16:32 +00:00
Jeffrey Yasskin 2f3c16be73 Backport PEP 3141 from the py3k branch to the trunk. This includes r50877 (just
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.
2008-01-03 02:21:52 +00:00
Guido van Rossum 01dbc109a8 Improve performance of built-in any()/all() by avoiding PyIter_Next() --
using a trick found in ifilter().
Feel free to backport to 2.5.
2007-12-20 23:48:28 +00:00
Raymond Hettinger dff1fd93ef Add comments 2007-12-20 01:25:05 +00:00
Raymond Hettinger 70fcfd03bc Bigger range for non-extended opargs. 2007-12-19 22:14:34 +00:00
Christian Heimes e93237dfcc #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available. 2007-12-19 02:37:44 +00:00
Raymond Hettinger eca274367e Zap a duplicate line 2007-12-19 00:27:21 +00:00
Christian Heimes 0a8143f646 Applied patch #1635: Float patch for inf and nan on Windows (and other platforms).
The patch unifies float("inf") and repr(float("inf")) on all platforms.
2007-12-18 23:22:54 +00:00
Raymond Hettinger fd7ed407d7 Give meaning to the oparg for BUILD_MAP: estimated size of the dictionary.
Allows dictionaries to be pre-sized (upto 255 elements) saving time lost
to re-sizes with their attendant mallocs and re-insertions.

Has zero effect on small dictionaries (5 elements or fewer), a slight
benefit for dicts upto 22 elements (because they had to resize once
anyway), and more benefit for dicts upto 255 elements (saving multiple
resizes during the build-up and reducing the number of collisions on
the first insertions).  Beyond 255 elements, there is no addional benefit.
2007-12-18 21:24:09 +00:00
Raymond Hettinger effde12f5f Speed-up dictionary constructor by about 10%.
New opcode, STORE_MAP saves the compiler from awkward stack manipulations
and specializes for dicts using PyDict_SetItem instead of PyObject_SetItem.

Old disassembly:
              0 BUILD_MAP                0
              3 DUP_TOP
              4 LOAD_CONST               1 (1)
              7 ROT_TWO
              8 LOAD_CONST               2 ('x')
             11 STORE_SUBSCR
             12 DUP_TOP
             13 LOAD_CONST               3 (2)
             16 ROT_TWO
             17 LOAD_CONST               4 ('y')
             20 STORE_SUBSCR

New disassembly:
              0 BUILD_MAP                0
              3 LOAD_CONST               1 (1)
              6 LOAD_CONST               2 ('x')
              9 STORE_MAP
             10 LOAD_CONST               3 (2)
             13 LOAD_CONST               4 ('y')
             16 STORE_MAP
2007-12-18 18:26:18 +00:00
Christian Heimes 52729ac856 Silence a warning about an unsed variable in debug builds 2007-12-14 02:33:57 +00:00
Skip Montanaro 4e3ebe0bae Note that open() is the preferred way to open files (issue 1510). 2007-12-08 14:37:43 +00:00
Raymond Hettinger 4e2f714031 Fix Issue 1045.
Factor-out common calling code by simplifying the length_hint API.
Speed-up the function by caching the PyObject_String for the attribute lookup.
2007-12-06 00:56:53 +00:00
Georg Brandl 2d3953bd78 Fix typo. 2007-12-05 07:02:47 +00:00
Nick Coghlan ef01d822aa Implement PEP 366 2007-12-03 12:55:17 +00:00
Christian Heimes dfdfaab1c5 Feature #1534
Added PyFloat_GetMax(), PyFloat_GetMin() and PyFloat_GetInfo() to the float API.
Added a dictionary sys.float_info with information about the internal floating point type to the sys module.
2007-12-01 11:20:10 +00:00
Amaury Forgeot d'Arc dafd32b730 Issue #1521: on 64bit platforms, str.decode fails on very long strings.
The t# and w# formats were not correctly handled.

Will backport.
2007-11-30 20:51:40 +00:00
Amaury Forgeot d'Arc 025c347d61 Issue #1402: PyInterpreterState_Clear() may still invoke user code
(in deallocation of running threads, for example), so the PyGILState_Release()
function must still be functional.
On the other hand, _PyGILState_Fini() only frees memory, and can be called later.

Backport candidate, but only after some experts comment on it.
2007-11-29 23:35:25 +00:00
Christian Heimes 28104c58d2 Expose Py_Py3kWarningFlag as sys.py3kwarning as discussed in #1504
Also added a warning.warnpy3k() as convenient method for Python 3.x related deprecation warnings.
2007-11-27 23:16:44 +00:00
Christian Heimes ffcd1e10b6 Added filename to compiling struct based on Martin's suggestion.
I'm wonder why I was trying to add the filename to the node all the time. The compiling struct is more obvious.
2007-11-24 01:36:02 +00:00
Christian Heimes 6d8fb1a444 And yet another fix for the patch. Paul Moore has send me a note that I've missed a declaration. The additional code has moved the declaration in the middle of the block. 2007-11-23 13:25:31 +00:00
Christian Heimes e36fe53d68 How did the comment get there? 2007-11-23 12:16:35 +00:00
Christian Heimes 02c9ab568d Fixed problems in the last commit. Filenames and line numbers weren't reported correctly.
Backquotes still don't report the correct file. The AST nodes only contain the line number but not the file name.
2007-11-23 12:12:02 +00:00
Christian Heimes 729ab15370 Applied patch #1754273 and #1754271 from Thomas Glee
The patches are adding deprecation warnings for back ticks and <>
2007-11-23 09:10:36 +00:00
Christian Heimes e8954f8ce7 Backport of the PCbuild9 directory from the py3k branch.
I've finished the last task for the PCbuild9 directory today. I don't think there is much left to do. Now you can all play around with the shiny new VS 2008 and try the PGO builds. I was able to get a speed improvement of about 10% on py3k.
Have fun! :)
2007-11-22 11:21:16 +00:00
Nick Coghlan 327a39b047 Patch #1739468: Directories and zipfiles containing __main__.py are now executable 2007-11-18 11:56:28 +00:00
Amaury Forgeot d'Arc 0d75f09177 Merge from py3k branch:
Correction for issue1265 (pdb bug with "with" statement).

When an unfinished generator-iterator is garbage collected, PyEval_EvalFrameEx
is called with a GeneratorExit exception set.  This leads to funny results
if the sys.settrace function itself makes use of generators.
A visible effect is that the settrace function is reset to None.
Another is that the eventual "finally" block of the generator is not called.

It is necessary to save/restore the exception around the call to the trace
function.

This happens a lot with py3k: isinstance() of an ABCMeta instance runs
    def __instancecheck__(cls, instance):
        """Override for isinstance(instance, cls)."""
        return any(cls.__subclasscheck__(c)
                   for c in {instance.__class__, type(instance)})
which lets an opened generator expression each time it returns True.

Backport candidate, even if the case is less frequent in 2.5.
2007-11-13 21:54:28 +00:00
Martin v. Löwis 63bf149a26 Patch #1418: Make the AC_REPLACE_FUNCS object files actually work. 2007-11-12 05:14:05 +00:00
Christian Heimes 004c1c1562 Backport of Guido's review of my patch. 2007-11-07 18:30:22 +00:00
Christian Heimes cea681be19 Backported fix for bug #1392 from py3k branch r58903. 2007-11-07 17:50:54 +00:00
Raymond Hettinger dc1d1ba9cf Add build option for faster loop execution. 2007-11-07 02:45:46 +00:00
Raymond Hettinger 12e94200c0 Fix marshal's incorrect handling of subclasses of builtin types (backport candidate). 2007-11-07 01:13:09 +00:00
Raymond Hettinger a45c4873fc Missing DECREFs 2007-10-25 02:26:58 +00:00
Raymond Hettinger 3a8daf5b56 Fixup error return and add support for intermixed ints and floats/ 2007-10-24 02:05:51 +00:00
Raymond Hettinger 3f8caa3ba7 Optimize sum() for integer and float inputs. 2007-10-24 01:28:33 +00:00
Neal Norwitz 15f2661758 Fix Coverity 185-186: If the passed in FILE is NULL, uninitialized memory
would be accessed.

Will backport.
2007-10-12 03:05:19 +00:00
Neal Norwitz 3adac21762 Fix Coverity #158: Check the correct variable. 2007-10-05 03:41:19 +00:00
Thomas Wouters e2176020f9 Try harder to stay within the 79-column limit. There's still two places that go (way) over, but those are harder to fix without suffering in readability. 2007-09-20 17:35:10 +00:00
Thomas Wouters ae406c6018 Whitespace cleanup. 2007-09-19 17:27:43 +00:00
Georg Brandl 5a5bc7b10d Fix #1169: remove docstrings in functions for -OO. 2007-09-19 06:37:19 +00:00
Brett Cannon 1e534b5425 Fix a crasher where Python code managed to infinitely recurse in C code without
ever going back out to Python code in PyObject_Call().  Required introducing a
static RuntimeError instance so that normalizing an exception there is no
reliance on a recursive call that would put the exception system over the
recursion check itself.
2007-09-07 04:18:30 +00:00