Commit Graph

3089 Commits

Author SHA1 Message Date
Benjamin Peterson c6660cf4d6 different spellings are just unacceptable 2010-06-11 21:40:37 +00:00
Benjamin Peterson 1056ca264f fix code formatting 2010-06-09 19:45:04 +00:00
Victor Stinner c49dfcc8dc Issue #3798: Write sys.exit() message to sys.stderr to use stderr encoding and
error handler, instead of writing to the C stderr file in utf-8
2010-05-25 22:30:32 +00:00
Antoine Pitrou 6a2656094d Issue #5753: A new C API function, :cfunc:`PySys_SetArgvEx`, allows
embedders of the interpreter to set sys.argv without also modifying
sys.path.  This helps fix `CVE-2008-5983
<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
2010-05-21 17:12:38 +00:00
Brett Cannon eb3cd301ae Turned out that if you used explicit relative import syntax
(e.g. from .os import sep) and it failed, import would still try the implicit
relative import semantics of an absolute import (from os import sep). That's
not right, so when level is negative, only do explicit relative import
semantics.

Fixes issue #7902. Thanks to Meador Inge for the patch.
2010-05-20 18:37:55 +00:00
Victor Stinner 3bea1ede7d Use 4-spaces for indentation (instead of tabs) in pgen outputs
Regenerate (reindent) Python/graminit.c
2010-05-15 22:55:28 +00:00
Antoine Pitrou c83ea137d7 Untabify C files. Will watch buildbots. 2010-05-09 14:46:46 +00:00
Jean-Paul Calderone e54ddf1ed2 Skip signal handler re-installation if it is not necessary. Issue 8354. 2010-05-08 20:06:02 +00:00
Brett Cannon f4f0bf850b Revert a change where an expression is not needed now, but could be in the future. 2010-05-05 23:11:08 +00:00
Brett Cannon 5335e77810 Remove an unneeded variable assignment.
Found using Clang's static analyzer.
2010-05-05 20:53:20 +00:00
Brett Cannon 0b64be2389 Explicitly add stdio.h and string.h to make strtod.c work standalone.
Found using Clang's static analyzer.
2010-05-05 20:50:03 +00:00
Brett Cannon c33e82d23c Change to a Py_XDECREF and fix some whitespace.
Found using Clang's static analyzer.
2010-05-05 20:38:52 +00:00
Brett Cannon 1771ecf879 Remove an unnecessary variable assignment.
Found using Clang's static analyzer.
2010-05-05 20:35:24 +00:00
Brett Cannon fa84d923ec Remove two unneeded branches to an 'if' statement by applying De Morgan's Law
and creating a single 'if' statement along with a NULL default value for a
variable.

Also clean up a bunch of whitespace.

Found using Clang's static analyzer.
2010-05-05 20:30:30 +00:00
Brett Cannon 2ee5183852 Remove an unneeded variable increment.
Found using Clang's static analyzer.
2010-05-05 20:27:49 +00:00
Brett Cannon 8b9c04941b Remove an unneeded variable and fix a little whitespace.
Found using Clang's static analyzer.
2010-05-05 20:26:58 +00:00
Brett Cannon b166afc17c Fix whitespace. 2010-05-05 20:25:47 +00:00
Brett Cannon 417439e6cd Partially revert the over-reaching r80813. 2010-05-05 20:24:30 +00:00
Brett Cannon 0b03f10afb Remove three unneeded variable assignments.
Found using Clang's static analyzer.
2010-05-05 20:20:19 +00:00
Mark Dickinson ef9b4abfea Fix trailing whitespace. 2010-05-04 16:19:06 +00:00
Mark Dickinson a8d2668818 Issue #1533: fix inconsistency in range function argument processing:
any non-float non-integer argument is now converted to an integer (if
possible) using its __int__ method.  Previously, only small arguments
were treated this way; larger arguments (those whose __int__ was
outside the range of a C long) would produce a TypeError.

Patch by Alexander Belopolsky (with minor modifications).
2010-05-04 16:18:25 +00:00
Brett Cannon 1994969c15 When DeprecationWarning was silenced by default, it also silenced any use of -Q
by default as well. This change fixes that by treating -Q like -3 when it comes
to DeprecationWarning; using it causes the silencing to not occur.

Fixes issue #7319.
2010-04-25 22:33:36 +00:00
Antoine Pitrou 18e63fbe64 Issue #7332: Remove the 16KB stack-based buffer in
PyMarshal_ReadLastObjectFromFile, which doesn't bring any noticeable
benefit compared to the dynamic memory allocation fallback.  Patch by
Charles-François Natali.
2010-04-21 22:53:29 +00:00
Antoine Pitrou 72ec2e2bdf 14 years later, we still don't know what it's for.
Spotted by the PyPy developers.

Original commit is:

branch:      trunk
user:        guido
date:        Mon Aug 19 21:32:04 1996 +0200
files:       Python/getargs.c
description:
[svn r6499] Support for keyword arguments (PyArg_ParseTupleAndKeywords) donated by
Geoff Philbrick <philbric@delphi.hks.com> (slightly changed by me).

Also a little change to make the file acceptable to K&R C compilers
(HPUX, SunOS 4.x).
2010-04-06 15:38:25 +00:00
Benjamin Peterson f5e7b3e826 fix tabs 2010-04-04 23:03:22 +00:00
Benjamin Peterson 1c7c11ef61 give TypeError when trying to set T_STRING_INPLACE 2010-04-03 01:28:57 +00:00
Benjamin Peterson bea424af98 more _PyString_Resize error checking 2010-04-03 00:57:33 +00:00
Antoine Pitrou 76c8649038 Issue #8276: PyEval_CallObject() is now only available in macro form. The
function declaration, which was kept for backwards compatibility reasons,
is now removed (the macro was introduced in 1997!).
2010-04-01 16:42:11 +00:00
Benjamin Peterson 06638735fc make naming convention consistent 2010-03-25 23:27:16 +00:00
Larry Hastings 402b73fb8d Backported PyCapsule from 3.1, and converted most uses of
CObject to PyCapsule.
2010-03-25 00:54:54 +00:00
Benjamin Peterson bb9d726357 take into account keyword arguments when passing too many args 2010-03-21 20:30:30 +00:00
Benjamin Peterson 965458931f improve error message from passing inadequate number of keyword arguments #6474
Note this removes the "non-keyword" or "keyword" phrases from these messages.
2010-03-21 20:21:00 +00:00
Benjamin Peterson 88e7ebac4c co_varnames is certainly a tuple, so let's not waste time finding out 2010-03-21 19:39:52 +00:00
Benjamin Peterson d51b259b31 remove pointless condition 2010-03-21 19:35:39 +00:00
Benjamin Peterson 56472c2463 flatten condition 2010-03-21 19:24:08 +00:00
Benjamin Peterson 0dee9c1b5c prevent lambda functions from having docstrings #8164 2010-03-17 20:41:42 +00:00
Mark Dickinson f1ff88f0e4 Fix incorrect error checks in structmember.c (backport of r78920 from py3k). 2010-03-13 14:18:34 +00:00
Victor Stinner 6664426d7c Issue #3137: Don't ignore errors at startup, especially a keyboard interrupt
(SIGINT). If an error occurs while importing the site module, the error is
printed and Python exits. Initialize the GIL before importing the site
module.
2010-03-10 22:30:19 +00:00
Benjamin Peterson 9c4742e6ce more specific exception for wrong kind of raise #8082 2010-03-07 00:00:37 +00:00
Victor Stinner 71fb87e64c Issue #7544: Preallocate thread memory before creating the thread to avoid a
fatal error in low memory condition.
2010-03-03 23:20:25 +00:00
Florent Xicluna 8af970ab58 Revert a nonexistent docstring typo, r42805. 2010-03-03 11:49:53 +00:00
Gregory P. Smith 9e5d1327f8 Issue #7242: On Solaris 9 and earlier calling os.fork() from within a
thread could raise an incorrect RuntimeError about not holding the import
lock.  The import lock is now reinitialized after fork.
2010-03-01 01:22:39 +00:00
Amaury Forgeot d'Arc adfc80bd81 #4852: Remove dead code in every thread implementation, unused for many years. 2010-02-23 23:19:39 +00:00
Benjamin Peterson ee46101e68 remove pointless error checking 2010-02-06 19:40:18 +00:00
Benjamin Peterson 565d78586b normalize exceptions passed to the __exit__ method #7853
In Python 2.x, exceptions in finally blocks are not normalized.  Since with
statements are implemented using finally blocks, ceval.c had to be tweaked to
distinguish between with finally blocks and normal ones.

A test for the finalization of generators containing with statements was also
added.
2010-02-05 02:12:14 +00:00
Victor Stinner b4b0a2935d Issue #7819: Check sys.call_tracing() arguments types.
py3k was already patched by issue #3661.
2010-01-31 22:32:15 +00:00
Eric Smith ee931b7253 Issue #7766: Change sys.getwindowsversion() return value to a named tuple and add the additional members returned in an OSVERSIONINFOEX structure. The new members are service_pack_major, service_pack_minor, suite_mask, and product_type. 2010-01-27 00:28:29 +00:00
Mark Dickinson 8cd0a66a0f dtoa.c fix from upstream that fixes incorrectly rounded results for certain subnormals that are also halfway cases. 2010-01-23 21:25:53 +00:00
Mark Dickinson fc5290458d Issue #7743: Add checks for zero inputs to the lshift and mult functions;
this fixes the first bug described in issue #7743.
2010-01-23 20:48:56 +00:00
Mark Dickinson adcda3400f Issue #7743: Fix a potential incorrect rounding bug in dtoa.c (2nd bug
in issue 7743).
2010-01-22 17:04:07 +00:00
Mark Dickinson 86db34207c Correct typo in comment. 2010-01-22 16:18:09 +00:00
Mark Dickinson ca6ea56718 Additional explanatory comments for _Py_dg_strtod. 2010-01-20 21:23:25 +00:00
Mark Dickinson 1942806013 Don't try to put a value into a NULL pointer. 2010-01-20 18:02:41 +00:00
Mark Dickinson 4141d65fb7 Various dtoa.c cleanups. 1. Despagghetify _Py_dg_strtod parsing code
and exit points.  2. Simplify bigcomp comparison loop.  3. Don't set
ERANGE on _Py_dg_strtod underflow (it was set inconsistently anyway).
4. Remove unused dsign field from BCinfo struct.
2010-01-20 17:36:31 +00:00
Mark Dickinson 9481c576cd Issue #7632: When Py_USING_MEMORY_DEBUGGER is defined, disable the
private memory allocation scheme in dtoa.c, along with a piece of code
that caches powers of 5 for future use.  This makes it easier to
detect dtoa.c memory leaks with Valgrind or similar tools.

Patch by Stefan Krah.
2010-01-17 20:57:56 +00:00
Mark Dickinson 23df3d270d Issue #7632: Fix a memory leak in _Py_dg_strtod. 2010-01-17 13:37:57 +00:00
Mark Dickinson 18a818bc63 Fix multiple uses of variable 'L' in _Py_dg_strtod, where one use requires an unsigned long and the other a signed long. See also r77421. 2010-01-16 18:06:17 +00:00
Mark Dickinson 811ff822f8 Issue #7632: Fix one more case of incorrect rounding for str -> float
conversion (see bug 5 in the issue tracker).
2010-01-16 17:57:49 +00:00
Mark Dickinson 476279f18b Issue #7632: Fix a serious wrong output bug for string -> float conversion.
Also remove some now unused variables, and add comments clarifying the
possible outputs of the parsing section of _Py_dg_strtod.  Thanks
Eric Smith for reviewing.
2010-01-16 10:44:00 +00:00
Brett Cannon 0bc77474aa Remove C++/C99-style comments. 2010-01-15 01:31:45 +00:00
Brett Cannon 3ffa43db48 The silencing of DeprecationWarning was not taking -3 into consideration. Since
Py3K warnings are DeprecationWarning by default this was causing -3 to
essentially be a no-op. Now DeprecationWarning is only silenced if -3 is not
used.

Closes issue #7700. Thanks Ezio Melotti and Florent Xicluna for patch help.
2010-01-14 20:00:28 +00:00
Mark Dickinson f8747c1f12 Issue 7632: fix incorrect rounding for long input strings with values very close to a power of 2. (See Bug 4 in the tracker discussion.) 2010-01-14 14:40:20 +00:00
Mark Dickinson 50b60c612e Issue 7632: fix a dtoa.c bug (bug 6) causing incorrect rounding. Tests to follow. 2010-01-14 13:14:49 +00:00
Mark Dickinson 03774fac62 Fix off-by-one error introduced in r77483. I have a test for this, but it currently fails due to a different dtoa.c bug; I'll add the test once that bug is fixed. 2010-01-14 13:02:36 +00:00
Mark Dickinson d2a9940acb More dtoa.c cleanup; remove the need for bc.dplen, bc.dp0 and bc.dp1. 2010-01-13 22:20:10 +00:00
Mark Dickinson 02139d74ba Fix buggy comparison: LHS of comparison was being treated as unsigned. 2010-01-13 22:15:53 +00:00
Mark Dickinson 6e0d3d67fb Simplify and annotate the bigcomp function, removing unused special cases. 2010-01-13 20:55:03 +00:00
Mark Dickinson 5818e01253 Clarify that sulp expects a nonnegative input, but that +0.0 is fine. 2010-01-13 19:02:37 +00:00
Mark Dickinson b26d56ac18 Add comments explaining the role of the bigcomp function in dtoa.c. 2010-01-13 18:21:53 +00:00
Mark Dickinson 5ff4f279e6 Issue #7632: Fix a bug in dtoa.c that could lead to incorrectly-rounded results. 2010-01-12 22:55:51 +00:00
Mark Dickinson 8efef5ce9f Issue #7632: Fix a problem with _Py_dg_strtod that could lead to
crashes in debug builds, for certain long numeric strings
corresponding to subnormal values.
2010-01-12 22:23:56 +00:00
Alexandre Vassalotti 102d70e06c Update version information for AST changes in r77422. 2010-01-11 22:46:43 +00:00
Alexandre Vassalotti b646547bb4 Issue #2333: Backport set and dict comprehensions syntax. 2010-01-11 22:36:12 +00:00
Mark Dickinson 0ca7452794 Change a variable type to avoid signed overflow; replace repeated '19999' constant by a define. 2010-01-11 17:15:13 +00:00
Mark Dickinson 5a0b399aa9 Remove unused BCinfo fields and an unused macro. 2010-01-10 13:06:31 +00:00
Brett Cannon 6fdd3dcb6a DeprecationWarning is now silent by default.
This was originally suggested by Guido, discussed on the stdlib-sig mailing
list, and given the OK by Guido directly to me. What this change essentially
means is that Python has taken a policy of silencing warnings that are only
of interest to developers by default. This should prevent users from seeing
warnings which are triggered by an application being run against a new
interpreter before the app developer has a chance to update their code.

Closes issue #7319. Thanks to Antoine Pitrou, Ezio Melotti, and Brian Curtin
for helping with the issue.
2010-01-10 02:56:19 +00:00
Brett Cannon 3ad57e2625 Update the version # of Python-ast.c based on the backport of set literals from
r77400.
2010-01-10 02:48:50 +00:00
Alexandre Vassalotti ee936a2130 Issue #2335: Backport set literals syntax from Python 3.x. 2010-01-09 23:35:54 +00:00
Mark Dickinson 2bcd177270 Fix typo in comment. 2010-01-04 21:32:02 +00:00
Mark Dickinson 1b34d2552c Issue #5080: turn the DeprecationWarning from float arguments passed
to integer PyArg_Parse* format codes into a TypeError.  Add a
DeprecationWarning for floats passed with the 'L' format code, which
didn't previously have a warning.
2010-01-01 17:27:30 +00:00
Benjamin Peterson 71380c3dfe update copyright year 2010-01-01 04:00:55 +00:00
Benjamin Peterson 0f02d3933b check if the attribute is set before deleting it with T_OBJECT_EX (fixes #7604)
Also, add a note to the docs about the better behavior of T_OBJECT_EX as
compared to T_OBJECT.
2009-12-30 19:34:10 +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
Benjamin Peterson 5f429e0227 account for PyObject_IsInstance's new ability to fail 2009-12-13 00:54:15 +00:00
Mark Dickinson 3dc254181a Issue #6985: number of range() items should be constrained to lie
in a Py_ssize_t, not an int.
2009-12-03 12:08:56 +00:00
Mark Dickinson 34398184eb Issue #7406: Fix some occurrences of potential signed overflow in int
arithmetic.
2009-12-02 17:33:41 +00:00
Mark Dickinson ccc690d650 Issue #1678380: When distinguishing between -0.0 and 0.0 in
compiler_add_o, use copysign instead of examining the first and last
bytes of the double.  The latter method fails for little-endian
ARM, OABI, where doubles are little-endian but with the words swapped.
2009-11-28 16:32:27 +00:00
Mark Dickinson bce783757f round(0, "ermintrude") succeeded instead of producing a TypeError. Fix this. 2009-11-24 10:54:58 +00:00
Benjamin Peterson cef9782810 turn goto into do while loop 2009-11-20 02:15:50 +00:00
Benjamin Peterson 009b89d22a genexps have linenos 2009-11-20 01:16:58 +00:00
Benjamin Peterson d16d0abf0b provide line number for lambdas 2009-11-20 01:15:53 +00:00
Benjamin Peterson 99a5023c80 improve several corner cases related with argument names in parenthesis
- Fix #7362: give a good error message for parenthesized arguments with
  defaults.

- Add a py3k warning for any parenthesized arguments since those are not allowed
  in Py3.  This warning is not given in tuple unpacking, since that incurs the
  tuple unpacking warning.
2009-11-19 22:54: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
Benjamin Peterson 90ed611f6d a better callable replacement 2009-11-17 21:24:54 +00:00
Mark Dickinson 51ae4921b3 Set retval on PyOS_string_to_double failure. 2009-10-31 12:47:47 +00:00
Mark Dickinson 504a151c82 Issue #6603: Fix --with-tsc build failures on x86-64 that resulted
from a gcc inline assembler peculiarity. (gcc's "A" constraint
apparently means 'rax or rdx' in 64-bit mode, not edx:eax
or rdx:rax as one might expect.)
2009-10-31 10:11:28 +00:00
Mark Dickinson 09823a2e21 Deprecate PyOS_ascii_strtod and PyOS_ascii_atof, and document the replacement function PyOS_string_to_double. 2009-10-31 09:42:39 +00:00
Benjamin Peterson ea0e3b0d60 do a backport of r75928
The added test does not fail without the patch, but we still fix the issue of
surrogates being used in wide builds where they should not be.
2009-10-29 01:49:07 +00:00
Eric Smith b218d289e6 Removed PyOS_ascii_atof from marshal.c, as mentioned in issue 7117. Also brings it more in line with py3k. 2009-10-27 19:42:57 +00:00