Commit Graph

3070 Commits

Author SHA1 Message Date
Benjamin Peterson d692a71fdd revert r74699 since it loses useful error information 2009-09-07 13:02:15 +00:00
Benjamin Peterson 5515990ee1 PyObject_GetIter can set an error for its self just fine 2009-09-06 22:43:39 +00:00
Benjamin Peterson c0ba828857 better col_offsets for "for" statements with tuple unpacking #6704
Patch from Frank Wierzbicki.
2009-08-15 22:59:21 +00:00
Sean Reifscheider 9279e7d177 - Issue #6624: yArg_ParseTuple with "s" format when parsing argument with
NUL: Bogus TypeError detail string.
2009-08-01 23:54:55 +00:00
Amaury Forgeot d'Arc 982b2fa32d Better name a variable: 'buf' seems to imply a mutable buffer. 2009-07-25 16:22:06 +00:00
Benjamin Peterson 4879c907ce the Slice in x[::] has to have step as None to help the interpreter 2009-07-20 20:28:08 +00:00
Hirokazu Yamamoto e78e5d2e51 Issue #6415: Fixed warnings.warn sagfault on bad formatted string. 2009-07-17 06:20:46 +00:00
R. David Murray 3310a10a68 Update issue 6070 patch to match the patch that was actually tested
on Windows.
2009-07-07 09:54:16 +00:00
R. David Murray 23a736a4f0 Issue 6070: when creating a compiled file, after copying the mode bits, on
posix zap the execute bit in case it was set on the .py file, since the
compiled files are not directly executable on posix.  Patch by Marco N.
2009-07-07 01:06:13 +00:00
Benjamin Peterson 753d16234f when print() gets unicode arguments, sep and end should be unicode by default #4618 2009-07-02 18:16:45 +00:00
Benjamin Peterson 4a3cf191f4 small optimization: avoid popping the current block until we have to 2009-07-01 23:45:19 +00:00
Georg Brandl e323e0e91a Fix error handling in PyCode_Optimize, by Alexander Schremmer at EuroPython sprint. 2009-06-29 14:44:49 +00:00
Alexandre Vassalotti 7274cffa9e Update docstrings for sys.getdlopenflags() and sys.setdlopenflags(). 2009-06-29 01:01:51 +00:00
Benjamin Peterson 8f7b94eae9 use stack macros 2009-06-28 16:14:07 +00:00
Benjamin Peterson b8338ab92c add two generic macros for peeking and setting in the stack 2009-06-28 16:08:02 +00:00
Benjamin Peterson 1a4ceb2f4b fix grammar 2009-06-23 01:18:57 +00:00
Benjamin Peterson d9920c255d remove tmpname support since it's no longer used 2009-06-21 23:03:36 +00:00
Benjamin Peterson f67caf8523 don't need to add the name 'lambda' as assigned 2009-06-21 23:01:07 +00:00
Benjamin Peterson 5ecf57adcf remove unused 'encoding' member from the compiler struct 2009-06-17 03:23:04 +00:00
Benjamin Peterson 8fa3e933c1 update ast version 2009-06-13 20:30:48 +00:00
Benjamin Peterson a72be3b325 when no module is given in a 'from' relative import, make ImportFrom.module NULL 2009-06-13 20:23:33 +00:00
Benjamin Peterson 52c4bec76b give a better error message when deleting () 2009-06-13 17:08:53 +00:00
Benjamin Peterson 5d1ff94b9e set Print.values to NULL if there are no values 2009-06-13 16:19:19 +00:00
Benjamin Peterson d1f5a59edb allow importing from a module named None if it has an 'as' clause 2009-06-13 13:06:21 +00:00
Benjamin Peterson 565e1b6bb7 prevent import statements from assigning to None 2009-06-13 03:46:30 +00:00
Benjamin Peterson 4afbba3d34 keep the slice.step field as NULL if no step expression is given 2009-06-13 01:40:00 +00:00
Alexandre Vassalotti a6e3474d02 Add const qualifier to PyErr_SetFromErrnoWithFilename and to
PyErr_SetFromErrnoWithUnicodeFilename.
2009-06-12 20:57:12 +00:00
Benjamin Peterson 4efb5d0b82 remove check for case handled in sub-function 2009-06-11 22:29:23 +00:00
Benjamin Peterson b266481ed8 revert r73361 2009-06-11 17:49:38 +00:00
Benjamin Peterson e5fa5fe8fc remove duplicate check 2009-06-11 16:25:52 +00:00
Benjamin Peterson a5a5728cf0 remove error checks already done in set_context() 2009-06-08 23:44:13 +00:00
Benjamin Peterson 8ea4ded9a6 remove useless assertion 2009-06-08 22:18:32 +00:00
Antoine Pitrou 46dbe27f7e Issue #5330: C functions called with keyword arguments were not reported by
the various profiling modules (profile, cProfile). Patch by Hagen Fürstenau.
2009-05-30 21:27:00 +00:00
Jeffrey Yasskin 7937d939b1 Fix nearly all compilation warnings under Apple gcc-4.0. Tested with OPT="-g
-Wall -Wstrict-prototypes -Werror" in both --with-pydebug mode and --without.
There's still a batch of non-prototype warnings in Xlib.h that I don't know how
to fix.
2009-05-29 03:44:31 +00:00
Philip Jenvey dd0388a1c2 further hint to where the open docs really are 2009-05-28 03:12:16 +00:00
Benjamin Peterson aafa18aa05 teach the peepholer about SETUP_WITH 2009-05-26 12:49:59 +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 49a6b0ef70 take into account the fact that SETUP_WITH pushes a finally block 2009-05-25 20:12:57 +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
Benjamin Peterson 87e5006d8c handle errors from _PyObject_LookupSpecial when __get__ fails 2009-05-25 02:40:21 +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
Benjamin Peterson e5afa3b24b support building with subversion 1.7 #6094 2009-05-23 19:24:37 +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
R. David Murray 525cffcd7e Move news item to correct section, remove spurious 'see below'
from docstring.
2009-05-13 13:07:14 +00:00
R. David Murray a3ec697cbd Issue 5994: add docstrings to marshal. 2009-05-13 00:30:29 +00:00
Benjamin Peterson 4c1fe51ca0 don't ignore exceptions from _PyObject_LengthHint 2009-05-09 19:17:59 +00:00
Benjamin Peterson af1692a266 convert some more special methods to use _PyObject_LookupSpecial 2009-05-09 16:36:39 +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
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
Mark Dickinson 01fce5adc0 Don't use PyOS_strnicmp for NaN and Inf detection: it's locale-aware. 2009-05-03 22:33:34 +00:00
Mark Dickinson 777e4ff503 Eliminate some locale-dependent calls to isspace and tolower. 2009-05-03 20:59:48 +00:00
Eric Smith 9139cc6a3b Issue #1588: Add complex.__format__. 2009-04-30 00:58:58 +00:00
Mark Dickinson df108ca324 Remove format_float and use _PyOS_double_to_string instead. 2009-04-29 21:56:53 +00:00
Mark Dickinson 92fcc9c991 Issue #5864: format(1234.5, '.4') gives misleading result
(Backport of r72109 from py3k.)
2009-04-29 20:41:00 +00:00
Eric Smith 94cc00ce4d Silence warning on Windows. 2009-04-28 07:33:09 +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
Mark Dickinson e73cbe7a4e Fix typo in function name 2009-04-26 19:54:55 +00:00
Mark Dickinson 6d6b220215 Backport r71967 changes from py3k to trunk.
(Internal plumbing changes for float parsing.)
2009-04-26 16:04:05 +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
Mark Dickinson 95bc980d9e Issue #5816:
- simplify parsing and printing of complex numbers
 - make complex(repr(z)) round-tripping work for complex
   numbers involving nans, infs, or negative zeros
 - don't accept some of the stranger complex strings
   that were previously allowed---e.g., complex('1..1j')
2009-04-24 12:46:53 +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
Mark Dickinson 1bdf7e9cab Issue #1869: Fix a couple of minor round() issues. 2009-04-18 14:59:42 +00:00
Mark Dickinson 8e5446f902 Backport r71704 (add configure check for C99 round function) to trunk. 2009-04-18 14:41:37 +00:00
Mark Dickinson 4beb89b9f7 copysign shouldn't be declared as static in pymath.c 2009-04-18 14:13:43 +00:00
Georg Brandl 6c59e72576 #5580: no need to use parentheses when converterr() argument is actually a type description. 2009-04-05 11:54:07 +00:00
Matthias Klose edb5e1e09e - Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
short file names.
2009-04-04 14:18:13 +00:00
Antoine Pitrou 789be0c0a0 Issue #2396: backport the memoryview object. 2009-04-02 21:18:34 +00:00
Georg Brandl d3f03fa715 PyErr_NormalizeException may not set an error, so convert the PyErr_SetObject
call on hitting the recursion limit into just assigning it to the arguments provided.
2009-04-02 18:09:04 +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
Brett Cannon c4f90ebea7 PyImport_AppendInittab() took a char * as a first argument even though that
string was stored beyond the life of the call. Changed the signature to be
const char * to help make this point.

Closes issue #1419652.
2009-04-02 03:17:39 +00:00
Benjamin Peterson 985951df7f fix error handling 2009-04-02 02:52:46 +00:00
Georg Brandl 4b5c53aba5 In PyErr_GivenExceptionMatches, temporarily bump the recursion
limit, so that in the most common case PyObject_IsSubclass will
not raise a recursion error we have to ignore anyway.
2009-04-02 02:47:44 +00:00
Brett Cannon 15ba4dae5a _warnings was importing itself to get an attribute. That's bad if warnings gets
called in a thread that was spawned by an import itself.

Last part to close #1665206.
2009-04-01 18:03:59 +00:00
Jesse Noller 42f9b4e5b4 Issue 5619: Pass MS CRT debug flags into subprocesses 2009-03-31 22:20:35 +00:00
Jeremy Hylton 2696275348 Add check for PyDict_Update() error. 2009-03-31 15:04:15 +00:00
Jeremy Hylton 88f1c04215 Global statements from one function leaked into parallel functions.
Re http://bugs.python.org/issue4315

The symbol table used the same name dictionaries to recursively
analyze each of its child blocks, even though the dictionaries are
modified during analysis.  The fix is to create new temporary
dictionaries via the analyze_child_block().  The only information that
needs to propagate back up is the names of the free variables.

Add more comments and break out a helper function.  This code doesn't
get any easier to understand when you only look at it once a year.
2009-03-31 13:48:15 +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
Benjamin Peterson 6ffe852f90 fix strange errors when setting attributes on tracebacks #4034 2009-03-18 20:52:15 +00:00
Nick Coghlan 8eba5ed0d9 Make marshalling errors a little more informative as to what went wrong 2009-03-15 03:24:46 +00:00
Brett Cannon 6c4cff0f32 Require implementations for warnings.showwarning() support the 'line' argument.
Was a DeprecationWarning for not supporting it since Python 2.6.

Closes issue #3652.
2009-03-11 04:51:06 +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
Collin Winter 8725dce2ae Issue 5176: special-case string formatting in BINARY_MODULO implementation. This shows a modest (1-3%) speed-up in templating systems, for example. 2009-02-20 19:30:41 +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
Mark Dickinson 9e58a37252 Silence 'arg may be used uninitialized in this function' warning from gcc. 2009-02-08 17:33:11 +00:00
Eric Smith 81fe09344c Implement issue #4285, convert sys.version_info to a named
tuple. Patch by Ross Light.
2009-02-06 00:48:26 +00:00
Raymond Hettinger b516370bcb Issue 1242657: list(obj) can swallow KeyboardInterrupt. 2009-02-02 21:50:13 +00:00
Benjamin Peterson 12554cb224 more flags which only work for function blocks 2009-01-31 23:54:38 +00:00
Benjamin Peterson da9327faf7 add explanatory comment 2009-01-31 23:43:25 +00:00
Mark Hammond 9f4f56d4e8 On Windows, use the Python 'Activation Context' when loading extensions
to avoid problems loading the CRT from a private assembly.  Via bug 4566.
2009-01-27 23:12:23 +00:00
Benjamin Peterson 78821ddf8c fix building the core with --disable-unicode
I changed some bytearray methods to use strings instead of unicode like bytes_repr
Also, bytearray.fromhex() can take strings as well as unicode
2009-01-25 17:15:10 +00:00
Benjamin Peterson e18ef194d9 allow unicode keyword arguments for the ** syntax #4978 2009-01-20 14:21:16 +00:00
Amaury Forgeot d'Arc 59ce042766 #4077: No need to append \n when calling Py_FatalError
+ fix a declaration to make it match the one in pythonrun.h
2009-01-17 20:18:59 +00:00
Martin v. Löwis e3422fae8a Issue #4893: Use NT threading on CE. 2009-01-12 08:11:24 +00:00
Martin v. Löwis 1b3bef21b0 Issue #4915: Port sysmodule to Windows CE. 2009-01-12 07:57:11 +00:00
Martin v. Löwis b3b7d859b3 Issue #4279: Fix build of parsermodule under Cygwin. 2009-01-11 09:26:54 +00:00
Kristján Valur Jónsson abb70e9c9f Issue 4906: Preserve windows error state across PyThread_get_key_value 2009-01-10 12:14:31 +00:00
Kristján Valur Jónsson 0e91938e58 Issue 4293: Make Py_AddPendingCall() thread safe 2009-01-09 20:31:26 +00:00
Kristján Valur Jónsson 3b2a6b819d Issue 3677: Fix import from UNC paths on Windows. 2009-01-09 20:10:59 +00:00
Kristján Valur Jónsson 00f2df495a Issue 3582. Improved thread support and TLS for Windows 2009-01-09 20:03:27 +00:00
Antoine Pitrou e96d4ea4e2 Issue #1180193: When importing a module from a .pyc (or .pyo) file with
an existing .py counterpart, override the co_filename attributes of all
code objects if the original filename is obsolete (which can happen if the
file has been renamed, moved, or if it is accessed through different paths).
Patch by Ziga Seilnacht and Jean-Paul Calderone.
2009-01-06 18:10:47 +00:00
Martin v. Löwis 0fa10b3cd5 Issue #4817: Remove unused function PyOS_GetLastModificationTime. 2009-01-03 17:19:26 +00:00
Benjamin Peterson 796798b29c fix compilation on non-Windows platforms 2009-01-02 20:47:27 +00:00
Martin v. Löwis 5344c99734 Issue #4075: Use OutputDebugStringW in Py_FatalError. 2009-01-02 20:32:55 +00:00
Benjamin Peterson d6baa70b96 welcome to 2009, Python! 2009-01-01 17:29:49 +00:00
Benjamin Peterson 8d5934b25d #4748 lambda generators shouldn't return values 2008-12-27 18:24:11 +00:00
Benjamin Peterson 4caef5c7e2 fix #4720: the format to PyArg_ParseTupleAndKeywords can now start with '|' 2008-12-22 20:51:15 +00:00
Antoine Pitrou d0c3515bc5 Issue #2183: Simplify and optimize bytecode for list comprehensions. 2008-12-17 00:38:28 +00:00
Amaury Forgeot d'Arc ad9b5992e3 #4559: When a context manager's __exit__() method returns an object whose
conversion to bool raises an exception, 'with' loses that exception.

Reviewed by Jeffrey Yasskin.
Already ported to 2.5, will port to 2.6 and 3.0
2008-12-10 23:22:49 +00:00
Jeffrey Yasskin 2d873bd68b Issue 4597: Fix several cases in EvalFrameEx where an exception could be
"raised" without setting x, err, or why to let the eval loop know.
2008-12-08 18:55:24 +00:00
Mark Dickinson 422ce06b9c Issue #4461: Safety check in parsenumber (ast.c) 2008-12-05 17:59:46 +00:00
Jeffrey Yasskin fd8a1ec486 Speed up Python (according to pybench and 2to3-on-itself) by 1-2% by caching
whether any thread has tracing turned on, which saves one load instruction in
the fast_next_opcode path in PyEval_EvalFrameEx().  See issue 4477.
2008-12-03 06:46:45 +00:00
Benjamin Peterson 9e6310d936 always check the return value of NEW_IDENTIFIER 2008-11-25 03:43:14 +00:00
Amaury Forgeot d'Arc dc61901dd2 #3996: On Windows, PyOS_CheckStack is supposed to protect the interpreter from
stack overflow. But doing this, it always crashes when the stack is nearly full.

Reviewed by Martin von Loewis. Will backport to 2.6.
2008-11-22 20:01:18 +00:00
Benjamin Peterson c078f929cb don't segfault when \N escapes are used and unicodedata fails to load
Fixes #4367
2008-11-21 22:27:24 +00:00
Benjamin Peterson 2c98faada6 check for assignment to __debug__ during AST generation
Also, give assignment to None a better error message
2008-11-08 18:38:54 +00:00
Benjamin Peterson dcee09d920 make sure the parser flags and passed onto the compiler
This fixes "from __future__ import unicode_literals" in an exec statment
See #4225
2008-10-31 02:16:05 +00:00
Benjamin Peterson 44a90c95ce move unprefixed error into .c file 2008-10-30 23:59:18 +00:00
Benjamin Peterson 399b1fe8df give a py3k warning when 'nonlocal' is used as a variable name 2008-10-25 02:53:28 +00:00
Benjamin Peterson aff36f1295 fix compiler warning 2008-10-19 13:59:01 +00:00
Armin Ronacher 35e01fbeaa Fixed #4067 by implementing _attributes and _fields for the AST root node. 2008-10-19 08:27:43 +00:00
Christian Heimes 32a66a0410 Fixed a couple more C99 comments and one occurence of inline. 2008-10-02 19:47:50 +00:00
Andrew MacIntyre f8db82242b any platform without HAVE_LOG1P should have DBL_EPSILON in <float.h>
Part of source_os2emx.patch in issue 3868
Reviewed by Amaury Forgeot d'Arc
2008-09-22 14:11:41 +00:00
Amaury Forgeot d'Arc 05e344954d #3743: PY_FORMAT_SIZE_T is designed for the OS "printf" functions, not for
PyString_FromFormat which has an independent implementation, and uses "%zd".

This makes a difference on win64, where printf needs "%Id" to display
64bit values. For example, queue.__repr__ was incorrect.

Reviewed by Martin von Loewis.
2008-09-10 22:04:45 +00:00
Brett Cannon 1eaf0742d8 Move test.test_support.catch_warning() to the warnings module, rename it
catch_warnings(), and clean up the API.

While expanding the test suite, a bug was found where a warning about the
'line' argument to showwarning() was not letting functions with '*args' go
without a warning.

Closes issue 3602.
Code review by Benjamin Peterson.
2008-09-02 01:25:16 +00:00
Benjamin Peterson 17f03ca962 Fix compilation when --without-threads is given #3683
Reviewer: Georg Brandl, Benjamin Peterson
2008-09-01 14:18:30 +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
Neal Norwitz 18aa388ca0 Fix:
* crashes on memory allocation failure found with failmalloc
 * memory leaks found with valgrind
 * compiler warnings in opt mode which would lead to invalid memory reads
 * problem using wrong name in decimal module reported by pychecker

Update the valgrind suppressions file with new leaks that are small/one-time
leaks we don't care about (ie, they are too hard to fix).

TBR=barry
TESTED=./python -E -tt ./Lib/test/regrtest.py -uall (both debug and opt modes)
  in opt mode:
  valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
    ./python -E -tt ./Lib/test/regrtest.py -uall,-bsddb,-compiler \
                        -x test_logging test_ssl test_multiprocessing
  valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
    ./python -E -tt ./Lib/test/regrtest.py test_multiprocessing
  for i in `seq 1 4000` ; do
    LD_PRELOAD=~/local/lib/libfailmalloc.so FAILMALLOC_INTERVAL=$i \
        ./python -c pass
  done

At least some of these fixes should probably be backported to 2.5.
2008-08-24 05:04:52 +00:00
Benjamin Peterson 80f0ed5bb1 allow keyword args to be passed in after *args #3473 2008-08-19 19:52:46 +00:00
Benjamin Peterson 08336e30ad follup to #3473: don't duplicate the reduce code 2008-08-18 02:01:21 +00:00
Benjamin Peterson 25f2d89f32 uhh PySTEntry->ste_unoptimized has to be exposed too 2008-08-17 02:23:43 +00:00
Benjamin Peterson e0d4c7b5bd expose PySTEntry.nested so the symtable module will work 2008-08-17 01:09:17 +00:00
Benjamin Peterson e0d12eb85c PySTEntry's constructor is static; there's no point in a fancy API name 2008-08-16 23:29:40 +00:00
Benjamin Peterson 0847332716 include filename and line number in SyntaxError 2008-08-16 22:11:33 +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
Brett Cannon 3aa2a49ec9 Add imp.reload(). This to help with transitioning to 3.0 the reload() built-in
has been removed there.
2008-08-06 22:28:09 +00:00
Gregory P. Smith d868be8805 Adds a sanity check to avoid a *very rare* infinite loop due to a corrupt tls
key list data structure in the thread startup path.

This change is a companion to r60148 which already successfully dealt with a
similar issue on thread shutdown.

In particular this loop has been observed happening from this call path:
 #0  in find_key ()
 #1  in PyThread_set_key_value ()
 #2  in _PyGILState_NoteThreadState ()
 #3  in PyThreadState_New ()
 #4  in t_bootstrap ()
 #5  in pthread_start_thread ()

I don't know how this happens but it does, *very* rarely.  On more than
one hardware platform.  I have not been able to reproduce it manually.
(A flaky mutex implementation on the system in question is one hypothesis).

As with r60148, the spinning we managed to observe in the wild was due to a
single list element pointing back upon itself.
2008-08-04 07:33:37 +00:00
Amaury Forgeot d'Arc 39fd672dfe #3479: unichr(2**32) used to return u'\x00'.
The argument was fetched in a long, but PyUnicode_FromOrdinal takes an int.

(why doesn't gcc issue a truncation warning in this case?)
2008-07-31 21:28:03 +00:00
Amaury Forgeot d'Arc 246daedd11 #2542: now that issubclass() may call arbitrary code,
make sure that PyErr_ExceptionMatches returns 0 when an exception occurs there.
2008-07-31 00:42:16 +00:00
Antoine Pitrou c2cc80c64e Raymond's patch for #1819: speedup function calls with named parameters
(35% faster according to pybench)
2008-07-25 22:13:52 +00:00
Georg Brandl 1ad108db05 #3378: in case of no memory, don't leak even more memory. :) 2008-07-19 10:08:55 +00:00
Eric Smith f032a00271 Fix issue 3411: default float format spec fails on negative numbers. 2008-07-19 00:24:05 +00:00
Jesse Noller 5e62ca4fea Apply patch for 874900: threading module can deadlock after fork 2008-07-16 20:03:47 +00:00
Mark Dickinson 64b7e501f4 Issue #3360: Fix incorrect parsing of "020000000000.0". 2008-07-16 09:40:03 +00:00
Nick Coghlan b028f50911 Fix issue 3221 by emitting a RuntimeWarning instead of raising SystemError when the parent module can't be found during an absolute import (likely due to non-PEP 361 aware code which sets a module level __package__ attribute) 2008-07-13 14:52:36 +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
Robert Schuppenies 4762902998 Added garbage collector overhead and optional default return value to
sys.getsizeof.
2008-07-10 17:13:55 +00:00
Robert Schuppenies d2cd86ddd5 Fixed Issue3122 and extended sys.getsizeof tests for built-in types. 2008-07-10 13:43:26 +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
Georg Brandl 3c0fd5616f Fix tabs. 2008-07-05 10:07:18 +00:00
Raymond Hettinger afae11ea88 Update comment on prediction macros. 2008-07-05 02:11:55 +00:00
Georg Brandl aa76d77e2b Add a comment about incref'ing w. 2008-07-01 20:56:03 +00:00
Amaury Forgeot d'Arc bdd941fac3 #3242: fix a crash in "print", if sys.stdout is set to a custom object,
whose write() method installs another sys.stdout.

Will backport.
2008-07-01 20:38:04 +00:00
Benjamin Peterson 175e4d9663 #3219 repeated keyword arguments aren't allowed in function calls anymore 2008-07-01 19:34:52 +00:00
Brett Cannon dea1b5653f warnings.warn_explicit() did not have the proper TypeErrors in place to prevent
bus errors or SystemError being raised. As a side effect of fixing this, a bad
DECREF that could be triggered when 'message' and 'category' were both None was
fixed.

Closes issue 3211. Thanks JP Calderone for the bug report.
2008-06-27 00:31:13 +00:00
Raymond Hettinger 9c437af4eb Revert 64424, 64438, and 64439. 2008-06-24 22:46:07 +00:00
Eric Smith 65fe47b931 Modified interface to _Py_[String|Unicode]InsertThousandsGrouping, in anticipation of fixing issue 3140. 2008-06-24 00:42:10 +00:00
Raymond Hettinger e3ae655edf Make bin() implementation parallel oct() and hex() so that int/long subclasses can override or so that other classes can support. 2008-06-20 04:18:15 +00:00
Raymond Hettinger 305480c9dc Issue 3116: fix quadratic behavior in marshal.dumps(). 2008-06-16 01:42:40 +00:00
Benjamin Peterson 114f7e5fff #1683 prevent forking from interfering in threading storage
This should prevent some test_multiprocessing failures
2008-06-13 00:09:47 +00:00
Gregory P. Smith 9d53457e59 Merge in release25-maint r60793:
Added checks for integer overflows, contributed by Google. Some are
 only available if asserts are left in the code, in cases where they
 can't be triggered from Python code.
2008-06-11 07:41:16 +00:00
Gregory P. Smith dd96db63f6 This reverts r63675 based on the discussion in this thread:
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.
2008-06-09 04:58:54 +00:00
Benjamin Peterson f4fcdb6b8c warn about parameter tuple unpacking 2008-06-08 23:00:00 +00:00
Benjamin Peterson d5efd20406 Warn about assigning to Py3k keywords (True and False) 2008-06-08 22:52:37 +00:00
Benjamin Peterson cbd78133fa add an ast_warn helper function to make adding those Py3k warnings easier 2008-06-08 15:45:23 +00:00
Benjamin Peterson 2fe3ef8750 change Py3k backquote warning to a SyntaxWarning and add a test 2008-06-08 02:05:33 +00:00
Ronald Oussoren 5640ce2f1e MacOS X: Enable 4-way universal builds
This patch adds a new configure argument on OSX:
        --with-universal-archs=[32-bit|64-bit|all]

When used with the --enable-universalsdk option this controls which
CPU architectures are includes in the framework. The default is 32-bit,
meaning i386 and ppc. The most useful alternative is 'all', which includes
all 4 CPU architectures supported by MacOS X (i386, ppc, x86_64 and ppc64).

This includes limited support for the Carbon bindings in 64-bit mode as well,
limited because (a) I haven't done extensive testing and (b) a large portion
of the Carbon API's aren't available in 64-bit mode anyway.

I've also duplicated a feature of Apple's build of python: setting the
environment variable 'ARCHFLAGS' controls the '-arch' flags used for building
extensions using distutils.
2008-06-05 12:58:24 +00:00
Georg Brandl 7a6de8b0f4 Some style nits. Also clarify in the docstrings what __sizeof__ does. 2008-06-01 16:42:16 +00:00
Robert Schuppenies 51df064767 Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes. 2008-06-01 16:16:17 +00:00
Martin v. Löwis 6495c8da8f Typo: encoding -> codeset. 2008-06-01 08:19:02 +00:00
Martin v. Löwis b12d8579e3 Move sys_stream and sys_isatty out of the have-langinfo block. 2008-06-01 08:06:17 +00:00
Martin v. Löwis 99815892f6 New environment variable PYTHONIOENCODING. 2008-06-01 07:20:46 +00:00
Eric Smith dc13b79a38 Refactor and clean up str.format() code (and helpers) in advance of optimizations. 2008-05-30 18:10:04 +00:00
Raymond Hettinger 65856600ed Issue 2784: fix leaks in exception exit. 2008-05-30 06:37:27 +00:00
Gregory P. Smith 933d3731de Fix issue2588: Do not execute str[size-1] = '\0' when a 0 size is
passed in.  (The assert won't prevent this in non-debug builds).
2008-05-26 22:07:28 +00:00
Gregory P. Smith 23921f00e8 Fix issue2589: there was a potential integer overflow leading to
memory corruption on esoteric platforms and incorrect behavior on
normal platforms.
2008-05-26 21:16:34 +00:00
Benjamin Peterson dacde0d6ae turn PyErr_WarnPy3k into a macro 2008-05-26 17:43:53 +00:00
Christian Heimes 593daf545b Renamed PyString to PyBytes 2008-05-26 12:51:38 +00:00
Christian Heimes 3497f94476 First step of the C API rename:
renamed Include/bytesobject.h to Include/bytearrayobject.h
renamed Include/stringobject.h to Include/bytesobject.h
added Include/stringobject.h with aliases
2008-05-26 12:29:14 +00:00
Martin v. Löwis 4dd019fde3 Patch #2488: Add sys.maxsize. 2008-05-20 08:11:19 +00:00
Benjamin Peterson c6d64ec83f revert 63425 over Guido's Febuary message about this, that I missed 2008-05-17 20:09:42 +00:00
Benjamin Peterson d7943cb71d fix spelling 2008-05-17 19:51:10 +00:00
Benjamin Peterson 79a922d6df add Py3k warnings to oct and hex. backport hex behavior (because it's not different) 2008-05-17 19:21:20 +00:00
Georg Brandl 9c5b51541c Fix a refleak in the _warnings module. 2008-05-13 21:32:03 +00:00
Benjamin Peterson b9030f4f0d #2196 hasattr now allows SystemExit and KeyboardInterrupt to propagate 2008-05-12 00:41:23 +00:00
Eric Smith cf537ff39e Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats.  'n' is the same as
'd', but inserts the current locale-specific thousands grouping.

I added this as a stringlib function, but it's only used by str type,
not unicode.  This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion.  But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation.  As long as the unicode version isn't instantiated,
there's no overhead for this.
2008-05-11 19:52:48 +00:00
Georg Brandl b52a74b517 #2816: clarify error messages for EOF while scanning strings. 2008-05-11 15:07:39 +00:00
Andrew M. Kuchling 6c02916dfb #1792: Improve performance of marshal.dumps() on large objects by increasing
the size of the buffer more quickly.
2008-05-11 13:33:56 +00:00
Brett Cannon be1501b976 Fix sys.flags to properly expose bytes_warning.
Closes issue #2790.
2008-05-08 20:23:06 +00:00
Christian Heimes af748c3ab8 Implemented PEP 370 2008-05-06 22:41:46 +00:00
Benjamin Peterson d295032910 Fix logic error in Python/_warnings.c and add a test to verify 2008-05-06 22:18:11 +00:00
Brett Cannon e3dcb01bfc Fix a bug in the handling of the stacklevel argument in warnings.warn() where
the stack was being unwound by two levels instead of one each time.
2008-05-06 04:37:31 +00:00
Brett Cannon 8a232cc385 Add a DeprecationWarning for when warnings.showwarning() is set to a function
that lacks support for the new 'line' argument.
2008-05-05 05:32:07 +00:00
Benjamin Peterson 2b30ea068f The compiling struct is now passed around to all AST helpers (see issue 2720) 2008-05-03 15:56:42 +00:00
Brett Cannon 64a4bbeb25 Fix the C implementation of 'warnings' to infer the filename of the module that
raised an exception properly when __file__ is not set, __name__ == '__main__',
and sys.argv[0] is a false value.

Closes issue2743.
2008-05-03 03:19:39 +00:00
Brett Cannon ab9cc1b7ad Fix some indentation errors. 2008-05-03 01:02:41 +00:00
Brett Cannon b457ddaff2 Fix a backwards-compatibility mistake where a new optional argument for
warnings.showwarning() was being used. This broke pre-existing replacements for
the function since they didn't support the extra argument.

Closes issue 2705.
2008-05-02 02:25:09 +00:00
Georg Brandl 28e0873f1f #2719: backport next() from 3k. 2008-04-30 19:47:09 +00:00
Eric Smith 0a95063d73 Issue 2526, float.__format__ 'n' specifier does not support thousands grouping.
Implemented grouping, with tests.
Cleaned up PyOS_ascii_formatd by breaking reformatting into smaller functions.
2008-04-30 01:09:30 +00:00
Brett Cannon 141534e56f Fix a bug introduced by the warnings rewrite where tracebacks were being
improperly indented.

Closes issue #2699.
2008-04-28 03:23:50 +00:00