[Python-checkins] r79863 - in python/branches/py3k-jit: Doc/library/math.rst Doc/reference/expressions.rst Doc/whatsnew/2.7.rst Lib/test/test_structmembers.py Lib/test/test_zlib.py Lib/threading.py Misc/NEWS Objects/longobject.c Objects/object.c Python/getargs.c
collin.winter
python-checkins at python.org
Tue Apr 6 23:17:54 CEST 2010
Author: collin.winter
Date: Tue Apr 6 23:17:54 2010
New Revision: 79863
Log:
Merged revisions 79819,79823,79829,79831,79835,79839,79841,79845,79849,79853,79857,79860 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r79819 | senthil.kumaran | 2010-04-05 20:30:18 -0700 (Mon, 05 Apr 2010) | 9 lines
Merged revisions 79817 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79817 | senthil.kumaran | 2010-04-06 08:53:33 +0530 (Tue, 06 Apr 2010) | 2 lines
Fix Issue8262 - changing RuntimeError wording to "Threads can only be started once"
........
................
r79823 | mark.dickinson | 2010-04-06 03:29:17 -0700 (Tue, 06 Apr 2010) | 9 lines
Merged revisions 79809 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79809 | mark.dickinson | 2010-04-05 19:54:51 +0100 (Mon, 05 Apr 2010) | 1 line
Use a better NaN test in _Py_HashDouble as well.
........
................
r79829 | mark.dickinson | 2010-04-06 07:36:52 -0700 (Tue, 06 Apr 2010) | 9 lines
Recorded merge of revisions 79609 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79609 | raymond.hettinger | 2010-04-02 19:39:24 +0100 (Fri, 02 Apr 2010) | 1 line
Issue 8257: Decimal constructor to accept float.
........
................
r79831 | eric.smith | 2010-04-06 07:57:57 -0700 (Tue, 06 Apr 2010) | 9 lines
Merged revisions 79826 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79826 | eric.smith | 2010-04-06 10:30:15 -0400 (Tue, 06 Apr 2010) | 1 line
Fixed PEP 378 example.
........
................
r79835 | eric.smith | 2010-04-06 08:21:59 -0700 (Tue, 06 Apr 2010) | 9 lines
Merged revisions 79833 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79833 | eric.smith | 2010-04-06 11:17:33 -0400 (Tue, 06 Apr 2010) | 1 line
Note that PEP 378 also applies to int.
........
................
r79839 | mark.dickinson | 2010-04-06 08:47:14 -0700 (Tue, 06 Apr 2010) | 1 line
Remove out-of-date comment.
................
r79841 | antoine.pitrou | 2010-04-06 09:01:57 -0700 (Tue, 06 Apr 2010) | 23 lines
Merged revisions 79837 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79837 | antoine.pitrou | 2010-04-06 17:38:25 +0200 (mar., 06 avril 2010) | 19 lines
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 at 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).
........
................
r79845 | mark.dickinson | 2010-04-06 09:53:17 -0700 (Tue, 06 Apr 2010) | 15 lines
Merged revisions 79843-79844 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79843 | mark.dickinson | 2010-04-06 17:46:09 +0100 (Tue, 06 Apr 2010) | 4 lines
Issue #8259: Get rid of 'outrageous left shift count' error when
left-shifting an integer by more than 2**31 on a 64-bit machine. Also
convert shift counts to a Py_ssize_t instead of a C long.
........
r79844 | mark.dickinson | 2010-04-06 17:47:55 +0100 (Tue, 06 Apr 2010) | 1 line
Misc/NEWS entry for r79843.
........
................
r79849 | antoine.pitrou | 2010-04-06 10:23:13 -0700 (Tue, 06 Apr 2010) | 9 lines
Merged revisions 79848 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79848 | antoine.pitrou | 2010-04-06 19:21:09 +0200 (mar., 06 avril 2010) | 3 lines
Issue #8193: Fix test_zlib failure with zlib 1.2.4.
........
................
r79853 | mark.dickinson | 2010-04-06 11:22:06 -0700 (Tue, 06 Apr 2010) | 9 lines
Merged revisions 79852 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79852 | mark.dickinson | 2010-04-06 19:20:11 +0100 (Tue, 06 Apr 2010) | 1 line
Issue #8259: Clarify that there's an upper bound on the right-hand operand of a shift operator.
........
................
r79857 | mark.dickinson | 2010-04-06 12:02:54 -0700 (Tue, 06 Apr 2010) | 9 lines
Merged revisions 79856 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79856 | mark.dickinson | 2010-04-06 19:58:54 +0100 (Tue, 06 Apr 2010) | 1 line
Silence a 'comparison between signed and unsigned integer expressions' gcc warning.
........
................
r79860 | mark.dickinson | 2010-04-06 12:55:03 -0700 (Tue, 06 Apr 2010) | 10 lines
Merged revisions 79858 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79858 | mark.dickinson | 2010-04-06 20:50:03 +0100 (Tue, 06 Apr 2010) | 3 lines
Issue #7947: Clarify math module behaviour for IEEE 754 special cases, along
with a number of additional minor edits and typo corrections.
........
................
Modified:
python/branches/py3k-jit/ (props changed)
python/branches/py3k-jit/Doc/library/math.rst
python/branches/py3k-jit/Doc/reference/expressions.rst
python/branches/py3k-jit/Doc/whatsnew/2.7.rst
python/branches/py3k-jit/Lib/test/test_structmembers.py
python/branches/py3k-jit/Lib/test/test_zlib.py
python/branches/py3k-jit/Lib/threading.py
python/branches/py3k-jit/Misc/NEWS
python/branches/py3k-jit/Objects/longobject.c
python/branches/py3k-jit/Objects/object.c
python/branches/py3k-jit/Python/getargs.c
Modified: python/branches/py3k-jit/Doc/library/math.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/math.rst (original)
+++ python/branches/py3k-jit/Doc/library/math.rst Tue Apr 6 23:17:54 2010
@@ -33,8 +33,8 @@
.. function:: copysign(x, y)
- Return *x* with the sign of *y*. ``copysign`` copies the sign bit of an IEEE
- 754 float, ``copysign(1, -0.0)`` returns *-1.0*.
+ Return *x* with the sign of *y*. On a platform that supports
+ signed zeros, ``copysign(1.0, -0.0)`` returns *-1.0*.
.. function:: fabs(x)
@@ -99,15 +99,13 @@
.. function:: isinf(x)
- Checks if the float *x* is positive or negative infinite.
+ Check if the float *x* is positive or negative infinity.
.. function:: isnan(x)
- Checks if the float *x* is a NaN (not a number). NaNs are part of the
- IEEE 754 standards. Operation like but not limited to ``inf * 0``,
- ``inf / inf`` or any operation involving a NaN, e.g. ``nan * 1``, return
- a NaN.
+ Check if the float *x* is a NaN (not a number). For more information
+ on NaNs, see the IEEE 754 standards.
.. function:: ldexp(x, i)
@@ -223,7 +221,7 @@
The vector in the plane from the origin to point ``(x, y)`` makes this angle
with the positive X axis. The point of :func:`atan2` is that the signs of both
inputs are known to it, so it can compute the correct quadrant for the angle.
- For example, ``atan(1``) and ``atan2(1, 1)`` are both ``pi/4``, but ``atan2(-1,
+ For example, ``atan(1)`` and ``atan2(1, 1)`` are both ``pi/4``, but ``atan2(-1,
-1)`` is ``-3*pi/4``.
@@ -331,28 +329,31 @@
.. data:: pi
- The mathematical constant *pi*.
+ The mathematical constant π = 3.141592..., to available precision.
.. data:: e
- The mathematical constant *e*.
+ The mathematical constant e = 2.718281..., to available precision.
.. impl-detail::
The :mod:`math` module consists mostly of thin wrappers around the platform C
- math library functions. Behavior in exceptional cases is loosely specified
- by the C standards, and Python inherits much of its math-function
- error-reporting behavior from the platform C implementation. As a result,
- the specific exceptions raised in error cases (and even whether some
- arguments are considered to be exceptional at all) are not defined in any
- useful cross-platform or cross-release way.
-
- All functions return a quiet *NaN* if at least one of the args is *NaN*.
- Signaling *NaN*\s raise an exception. The exception type still depends on the
- platform and libm implementation. It's usually :exc:`ValueError` for *EDOM*
- and :exc:`OverflowError` for errno *ERANGE*.
+ math library functions. Behavior in exceptional cases follows Annex F of
+ the C99 standard where appropriate. The current implementation will raise
+ :exc:`ValueError` for invalid operations like ``sqrt(-1.0)`` or ``log(0.0)``
+ (where C99 Annex F recommends signaling invalid operation or divide-by-zero),
+ and :exc:`OverflowError` for results that overflow (for example,
+ ``exp(1000.0)``). A *NaN* will not be returned from any of the functions
+ above unless one or more of the input arguments was a *NaN*; in that case,
+ most functions will return a *NaN*, but (again following C99 Annex F) there
+ are some exceptions to this rule, for example ``pow(float('nan'), 0.0)`` or
+ ``hypot(float('nan'), float('inf'))``.
+
+ Note that Python makes no effort to distinguish signaling nans from
+ quiet nans, and behavior for signaling nans remains unspecified.
+ Typical behavior is to treat all nans as though they were quiet.
.. seealso::
Modified: python/branches/py3k-jit/Doc/reference/expressions.rst
==============================================================================
--- python/branches/py3k-jit/Doc/reference/expressions.rst (original)
+++ python/branches/py3k-jit/Doc/reference/expressions.rst Tue Apr 6 23:17:54 2010
@@ -914,6 +914,9 @@
A right shift by *n* bits is defined as division by ``pow(2,n)``. A left shift
by *n* bits is defined as multiplication with ``pow(2,n)``.
+.. note:: In the current implementation, the right-hand operand is required
+ to be at most :attr:`sys.maxsize`. If the right-hand operand is larger than
+ :attr:`sys.maxsize` an :exc:`OverflowError` exception is raised.
.. _bitwise:
Modified: python/branches/py3k-jit/Doc/whatsnew/2.7.rst
==============================================================================
--- python/branches/py3k-jit/Doc/whatsnew/2.7.rst (original)
+++ python/branches/py3k-jit/Doc/whatsnew/2.7.rst Tue Apr 6 23:17:54 2010
@@ -207,9 +207,14 @@
formatting a floating-point number, simply include a comma between the
width and the precision::
- >>> '{:20,.2}'.format(f)
+ >>> '{:20,.2f}'.format(18446744073709551616.0)
'18,446,744,073,709,551,616.00'
+When formatting an integer, include the comma after the width:
+
+ >>> '{:20,d}'.format(18446744073709551616)
+ '18,446,744,073,709,551,616'
+
This mechanism is not adaptable at all; commas are always used as the
separator and the grouping is always into three-digit groups. The
comma-formatting mechanism isn't as general as the :mod:`locale`
Modified: python/branches/py3k-jit/Lib/test/test_structmembers.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_structmembers.py (original)
+++ python/branches/py3k-jit/Lib/test/test_structmembers.py Tue Apr 6 23:17:54 2010
@@ -88,8 +88,6 @@
self.assertEquals(ts.T_ULONGLONG, 4)
def test_bad_assignments(self):
- # XXX testing of T_UINT and T_ULONG temporarily disabled;
- # see issue 8014.
integer_attributes = [
'T_BOOL',
'T_BYTE', 'T_UBYTE',
Modified: python/branches/py3k-jit/Lib/test/test_zlib.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_zlib.py (original)
+++ python/branches/py3k-jit/Lib/test/test_zlib.py Tue Apr 6 23:17:54 2010
@@ -85,7 +85,7 @@
def test_baddecompressobj(self):
# verify failure on building decompress object with bad params
- self.assertRaises(ValueError, zlib.decompressobj, 0)
+ self.assertRaises(ValueError, zlib.decompressobj, -1)
def test_decompressobj_badflush(self):
# verify failure on calling decompressobj.flush with bad params
Modified: python/branches/py3k-jit/Lib/threading.py
==============================================================================
--- python/branches/py3k-jit/Lib/threading.py (original)
+++ python/branches/py3k-jit/Lib/threading.py Tue Apr 6 23:17:54 2010
@@ -460,7 +460,7 @@
raise RuntimeError("thread.__init__() not called")
if self._started.is_set():
- raise RuntimeError("thread already started")
+ raise RuntimeError("threads can only be started once")
if __debug__:
self._note("%s.start(): starting thread", self)
with _active_limbo_lock:
Modified: python/branches/py3k-jit/Misc/NEWS
==============================================================================
--- python/branches/py3k-jit/Misc/NEWS (original)
+++ python/branches/py3k-jit/Misc/NEWS Tue Apr 6 23:17:54 2010
@@ -12,6 +12,10 @@
Core and Builtins
-----------------
+- Issue #8259: 1L << (2**31) no longer produces an 'outrageous shift error'
+ on 64-bit machines. The shift count for either left or right shift is
+ permitted to be up to sys.maxsize.
+
- Ensure that tokenization of identifiers is not affected by locale.
- Issue #1222585: Added LDCXXSHARED for C++ support. Patch by Arfrever.
@@ -1011,6 +1015,8 @@
Tests
-----
+- Issue #8193: Fix test_zlib failure with zlib 1.2.4.
+
- Issue #8248: Add some tests for the bool type. Patch by Gregory Nofi.
- Issue #8263: Now regrtest.py will report a failure if it receives a
Modified: python/branches/py3k-jit/Objects/longobject.c
==============================================================================
--- python/branches/py3k-jit/Objects/longobject.c (original)
+++ python/branches/py3k-jit/Objects/longobject.c Tue Apr 6 23:17:54 2010
@@ -2428,7 +2428,7 @@
break;
}
}
- assert(1 <= x_size && x_size <= sizeof(x_digits)/sizeof(digit));
+ assert(1 <= x_size && x_size <= (Py_ssize_t)(sizeof(x_digits)/sizeof(digit)));
/* Round, and convert to double. */
x_digits[0] += half_even_correction[x_digits[0] & 7];
@@ -3779,8 +3779,7 @@
long_rshift(PyLongObject *a, PyLongObject *b)
{
PyLongObject *z = NULL;
- long shiftby;
- Py_ssize_t newsize, wordshift, loshift, hishift, i, j;
+ Py_ssize_t shiftby, newsize, wordshift, loshift, hishift, i, j;
digit lomask, himask;
CHECK_BINOP(a, b);
@@ -3799,8 +3798,7 @@
Py_DECREF(a2);
}
else {
-
- shiftby = PyLong_AsLong((PyObject *)b);
+ shiftby = PyLong_AsSsize_t((PyObject *)b);
if (shiftby == -1L && PyErr_Occurred())
goto rshift_error;
if (shiftby < 0) {
@@ -3841,27 +3839,21 @@
PyLongObject *a = (PyLongObject*)v;
PyLongObject *b = (PyLongObject*)w;
PyLongObject *z = NULL;
- long shiftby;
- Py_ssize_t oldsize, newsize, wordshift, remshift, i, j;
+ Py_ssize_t shiftby, oldsize, newsize, wordshift, remshift, i, j;
twodigits accum;
CHECK_BINOP(a, b);
- shiftby = PyLong_AsLong((PyObject *)b);
+ shiftby = PyLong_AsSsize_t((PyObject *)b);
if (shiftby == -1L && PyErr_Occurred())
goto lshift_error;
if (shiftby < 0) {
PyErr_SetString(PyExc_ValueError, "negative shift count");
goto lshift_error;
}
- if ((long)(int)shiftby != shiftby) {
- PyErr_SetString(PyExc_ValueError,
- "outrageous left shift count");
- goto lshift_error;
- }
/* wordshift, remshift = divmod(shiftby, PyLong_SHIFT) */
- wordshift = (int)shiftby / PyLong_SHIFT;
- remshift = (int)shiftby - wordshift * PyLong_SHIFT;
+ wordshift = shiftby / PyLong_SHIFT;
+ remshift = shiftby - wordshift * PyLong_SHIFT;
oldsize = ABS(Py_SIZE(a));
newsize = oldsize + wordshift;
Modified: python/branches/py3k-jit/Objects/object.c
==============================================================================
--- python/branches/py3k-jit/Objects/object.c (original)
+++ python/branches/py3k-jit/Objects/object.c Tue Apr 6 23:17:54 2010
@@ -656,9 +656,12 @@
* of mapping keys will turn out weird.
*/
- if (Py_IS_INFINITY(v))
- /* can't convert to long int -- arbitrary */
- v = v < 0 ? -271828.0 : 314159.0;
+ if (!Py_IS_FINITE(v)) {
+ if (Py_IS_INFINITY(v))
+ return v < 0 ? -271828 : 314159;
+ else
+ return 0;
+ }
fractpart = modf(v, &intpart);
if (fractpart == 0.0) {
/* This must return the same hash as an equal int or long. */
Modified: python/branches/py3k-jit/Python/getargs.c
==============================================================================
--- python/branches/py3k-jit/Python/getargs.c (original)
+++ python/branches/py3k-jit/Python/getargs.c Tue Apr 6 23:17:54 2010
@@ -1849,16 +1849,6 @@
(void) va_arg(*p_va, PyTypeObject*);
(void) va_arg(*p_va, PyObject **);
}
-#if 0
-/* I don't know what this is for */
- else if (*format == '?') {
- inquiry pred = va_arg(*p_va, inquiry);
- format++;
- if ((*pred)(arg)) {
- (void) va_arg(*p_va, PyObject **);
- }
- }
-#endif
else if (*format == '&') {
typedef int (*converter)(PyObject *, void *);
(void) va_arg(*p_va, converter);
More information about the Python-checkins
mailing list