]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505...
authorChristian Heimes <christian@cheimes.de>
Tue, 12 Feb 2008 22:59:25 +0000 (22:59 +0000)
committerChristian Heimes <christian@cheimes.de>
Tue, 12 Feb 2008 22:59:25 +0000 (22:59 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r60735 | raymond.hettinger | 2008-02-11 23:53:01 +0100 (Mon, 11 Feb 2008) | 1 line

  Add notes on how decimal fits into the model.
........
  r60737 | raymond.hettinger | 2008-02-12 00:34:56 +0100 (Tue, 12 Feb 2008) | 1 line

  Fix markup
........
  r60738 | raymond.hettinger | 2008-02-12 00:38:00 +0100 (Tue, 12 Feb 2008) | 1 line

  Backport ABC docs
........
  r60739 | raymond.hettinger | 2008-02-12 01:15:32 +0100 (Tue, 12 Feb 2008) | 1 line

  Restore fractions.rst to the document tree.
........
  r60740 | raymond.hettinger | 2008-02-12 01:48:20 +0100 (Tue, 12 Feb 2008) | 1 line

  Fix typo in comments
........
  r60741 | raymond.hettinger | 2008-02-12 02:18:03 +0100 (Tue, 12 Feb 2008) | 1 line

  Bring decimal a bit closer to the spec for Reals.
........
  r60743 | martin.v.loewis | 2008-02-12 14:47:26 +0100 (Tue, 12 Feb 2008) | 2 lines

  Patch #1736: Fix file name handling of _msi.FCICreate.
........
  r60745 | kurt.kaiser | 2008-02-12 16:45:50 +0100 (Tue, 12 Feb 2008) | 2 lines

  what??! Correct r60225.
........
  r60747 | martin.v.loewis | 2008-02-12 19:47:34 +0100 (Tue, 12 Feb 2008) | 4 lines

  Patch #1966: Break infinite loop in httplib when the servers
  implements the chunked encoding incorrectly.
  Will backport to 2.5.
........
  r60749 | raymond.hettinger | 2008-02-12 20:05:36 +0100 (Tue, 12 Feb 2008) | 1 line

  dict.copy() rises from the ashes.  Revert r60687.
........

Doc/library/collections.rst
Doc/library/fractions.rst
Lib/decimal.py
Lib/httplib.py
Lib/idlelib/configHandler.py
Lib/numbers.py
Modules/_collectionsmodule.c
PC/_msi.c

index f70ccb699de4fd2e678640e6be1f8f1f491b0d5b..e18dfcfc34488127a91be85811302c8e61e13b70 100644 (file)
@@ -12,10 +12,18 @@ This module implements high-performance container datatypes.  Currently,
 there are two datatypes, :class:`deque` and :class:`defaultdict`, and
 one datatype factory function, :func:`namedtuple`. 
 
+Besides the containers provided here, the optional :mod:`bsddb`
+module offers the ability to create in-memory or file based ordered 
+dictionaries with string keys using the :meth:`bsddb.btopen` method.
+
+In addition to containers, the collections module provides some ABCs
+(abstract base classes) that can be used to test whether a class 
+provides a particular interface, for example, is it hashable or
+a mapping. 
+
 The specialized containers provided in this module provide alternatives
 to Python's general purpose built-in containers, :class:`dict`, 
 :class:`list`, :class:`set`, and :class:`tuple`.
-
 Besides the containers provided here, the optional :mod:`bsddb`
 module offers the ability to create in-memory or file based ordered 
 dictionaries with string keys using the :meth:`bsddb.btopen` method.
@@ -128,7 +136,6 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:
 (For more about ABCs, see the :mod:`abc` module and :pep:`3119`.)
 
 
-
 .. _deque-objects:
 
 :class:`deque` objects
index 5f30caf138d8543d48b692a641f4893e41069d81..1deea64cc6938c66fc13e40eda757a042847bada 100644 (file)
@@ -1,6 +1,6 @@
 
 :mod:`fractions` --- Rational numbers
-====================================
+=====================================
 
 .. module:: fractions
    :synopsis: Rational numbers.
index 873f7c069e094dbcc22113885c713386d33499e3..2745065910d71fce3f820997a11ab26eebce1216 100644 (file)
@@ -1518,6 +1518,20 @@ class Decimal(_numbers.Real, _numbers.Inexact):
 
     __trunc__ = __int__
 
+    @property
+    def real(self):
+        return self
+
+    @property
+    def imag(self):
+        return Decimal(0)
+
+    def conjugate(self):
+        return self
+
+    def __complex__(self):
+        return complex(float(self))
+
     def _fix_nan(self, context):
         """Decapitate the payload of a NaN to fit the context"""
         payload = self._int
index 932152277afffdd23216c50cd48cc62922c89b32..bb873e47609eba3e8dc8ede41a22d9baf57eed84 100644 (file)
@@ -596,6 +596,10 @@ class HTTPResponse:
         ### note: we shouldn't have any trailers!
         while True:
             line = self.fp.readline()
+            if not line:
+                # a vanishingly small number of sites EOF without
+                # sending the trailer
+                break
             if line == b"\r\n":
                 break
 
index 9c106eb1d170b11a395e289797d4caf3260a58db..49065789c1ab824bc03a187e32c56c26528bef7c 100644 (file)
@@ -143,7 +143,7 @@ class IdleUserConfParser(IdleConfParser):
             try:
                 cfgFile = open(fname, 'w')
             except IOError:
-                fname.unlink()
+                os.unlink(fname)
                 cfgFile = open(fname, 'w')
             self.write(cfgFile)
         else:
index b5150d22ff0006810193061d677ea9505d57cc85..a4b7a6d260b20f0292f944d0565b3422bcb01daf 100644 (file)
@@ -46,6 +46,32 @@ Inexact.register(float)
 # Inexact.register(decimal.Decimal)
 
 
+## Notes on Decimal and it how relates to the numeric tower
+## --------------------------------------------------------
+## Decimal is Real except that it does not support rich comparisons.
+##
+## Decimal has some of the characteristics of Integrals.  It provides
+## logical operations but not as operators.  The logical operations only apply
+## to a subset of decimals (those that are non-negative, have a zero exponent,
+## and have digits that are only 0 or 1).  It does provide __long__() and
+## a three argument form of __pow__ that includes exactness guarantees.
+## It does not provide an __index__() method.
+##
+## Depending on context, decimal operations may be exact or inexact.
+##
+## When decimal is run in a context with small precision and automatic rounding,
+## it is Inexact.  See the "Floating point notes" section of the decimal docs
+## for an example of losing the associative and distributive properties of
+## addition.
+##
+## When decimal is used for high precision integer arithmetic, it is Exact.
+## When the decimal used as fixed-point, it is Exact.
+## When it is run with sufficient precision, it is Exact.
+## When the decimal.Inexact trap is set, decimal operations are Exact.
+## For an example, see the float_to_decimal() recipe in the "Decimal FAQ"
+## section of the docs -- it shows an how traps are used in conjunction
+## with variable precision to reliably achieve exact results.
+
 class Complex(Number):
     """Complex defines the operations that work on the builtin complex type.
 
index 74b3ea28ff2884806d8c6ea6042af8026a4cb2b5..db07537de199bc905c2b1948ead23e9241210fd8 100644 (file)
@@ -1127,7 +1127,7 @@ defdict_copy(defdictobject *dd)
 {
        /* This calls the object's class.  That only works for subclasses
           whose class constructor has the same signature.  Subclasses that
-          define a different constructor signature must override __copy__().
+          define a different constructor signature must override copy().
        */
        return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd),
                                            dd->default_factory, dd, NULL);
index 80c3cae9a4ffd1a90636bb59b942bbdf69115aa1..43fe32b387662445be36d8cb23376bea8eba238a 100644 (file)
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -180,12 +180,12 @@ static FNFCIGETOPENINFO(cb_getopeninfo)
 
 static PyObject* fcicreate(PyObject* obj, PyObject* args)
 {
-    char *cabname;
+    char *cabname, *p;
     PyObject *files;
     CCAB ccab;
     HFCI hfci;
     ERF erf;
-    int i;
+    Py_ssize_t i;
 
 
     if (!PyArg_ParseTuple(args, "sO:FCICreate", &cabname, &files))
@@ -208,22 +208,22 @@ static PyObject* fcicreate(PyObject* obj, PyObject* args)
     ccab.setID = 0;
     ccab.szDisk[0] = '\0';
 
-    for (i=0; cabname[i]; i++)
-       if (cabname[i] == '\\' || cabname[i] == '/')
-           break;
+    for (i = 0, p = cabname; *p; p = CharNext(p))
+       if (*p == '\\' || *p == '/')
+           i = p - cabname + 1;
 
-    if (i > sizeof(ccab.szCabPath) ||
-       strlen(cabname+i) > sizeof(ccab.szCab)) {
+    if (i >= sizeof(ccab.szCabPath) ||
+       strlen(cabname+i) >= sizeof(ccab.szCab)) {
        PyErr_SetString(PyExc_ValueError, "path name too long");
        return 0;
     }
 
-    if (cabname[i]) {
+    if (i > 0) {
        memcpy(ccab.szCabPath, cabname, i);
        ccab.szCabPath[i] = '\0';
        strcpy(ccab.szCab, cabname+i);
     } else {
-       strcpy(ccab.szCabPath, ".");
+       strcpy(ccab.szCabPath, ".\\");
        strcpy(ccab.szCab, cabname);
     }