summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/collections.rst11
-rw-r--r--Doc/library/fractions.rst2
-rw-r--r--Lib/decimal.py14
-rw-r--r--Lib/httplib.py4
-rw-r--r--Lib/idlelib/configHandler.py2
-rw-r--r--Lib/numbers.py26
-rw-r--r--Modules/_collectionsmodule.c2
-rw-r--r--PC/_msi.c18
8 files changed, 65 insertions, 14 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index f70ccb6..e18dfcf 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -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
diff --git a/Doc/library/fractions.rst b/Doc/library/fractions.rst
index 5f30caf..1deea64 100644
--- a/Doc/library/fractions.rst
+++ b/Doc/library/fractions.rst
@@ -1,6 +1,6 @@
:mod:`fractions` --- Rational numbers
-====================================
+=====================================
.. module:: fractions
:synopsis: Rational numbers.
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 873f7c0..2745065 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -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
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 9321522..bb873e4 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -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
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
index 9c106eb..4906578 100644
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -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:
diff --git a/Lib/numbers.py b/Lib/numbers.py
index b5150d2..a4b7a6d 100644
--- a/Lib/numbers.py
+++ b/Lib/numbers.py
@@ -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.
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 74b3ea2..db07537 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -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);
diff --git a/PC/_msi.c b/PC/_msi.c
index 80c3cae..43fe32b 100644
--- 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);
}