mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Merged revisions 68633,68648,68667,68706,68718,68720-68721,68724-68727,68739 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r68633 | thomas.heller | 2009-01-16 12:53:44 -0600 (Fri, 16 Jan 2009) | 3 lines Change an example in the docs to avoid a mistake when the code is copy pasted and changed afterwards. ........ r68648 | benjamin.peterson | 2009-01-16 22:28:57 -0600 (Fri, 16 Jan 2009) | 1 line use enumerate ........ r68667 | amaury.forgeotdarc | 2009-01-17 14:18:59 -0600 (Sat, 17 Jan 2009) | 3 lines #4077: No need to append \n when calling Py_FatalError + fix a declaration to make it match the one in pythonrun.h ........ r68706 | benjamin.peterson | 2009-01-17 19:28:46 -0600 (Sat, 17 Jan 2009) | 1 line fix grammar ........ r68718 | georg.brandl | 2009-01-18 04:42:35 -0600 (Sun, 18 Jan 2009) | 1 line #4976: union() and intersection() take multiple args, but talk about "the other". ........ r68720 | georg.brandl | 2009-01-18 04:45:22 -0600 (Sun, 18 Jan 2009) | 1 line #4974: fix redundant mention of lists and tuples. ........ r68721 | georg.brandl | 2009-01-18 04:48:16 -0600 (Sun, 18 Jan 2009) | 1 line #4914: trunc is in math. ........ r68724 | georg.brandl | 2009-01-18 07:24:10 -0600 (Sun, 18 Jan 2009) | 1 line #4979: correct result range for some random functions. ........ r68725 | georg.brandl | 2009-01-18 07:47:26 -0600 (Sun, 18 Jan 2009) | 1 line #4857: fix augmented assignment target spec. ........ r68726 | georg.brandl | 2009-01-18 08:41:52 -0600 (Sun, 18 Jan 2009) | 1 line #4923: clarify what was added. ........ r68727 | georg.brandl | 2009-01-18 12:25:30 -0600 (Sun, 18 Jan 2009) | 1 line #4986: augassigns are not expressions. ........ r68739 | benjamin.peterson | 2009-01-18 15:11:38 -0600 (Sun, 18 Jan 2009) | 1 line fix test that wasn't working as expected #4990 ........
This commit is contained in:
parent
b547979515
commit
b58dda7bdb
13 changed files with 48 additions and 45 deletions
|
@ -2406,10 +2406,10 @@ other data types containing pointer type fields.
|
||||||
("hreftype", HREFTYPE)]
|
("hreftype", HREFTYPE)]
|
||||||
|
|
||||||
class TYPEDESC(Structure):
|
class TYPEDESC(Structure):
|
||||||
|
_anonymous_ = ("u",)
|
||||||
_fields_ = [("u", _U),
|
_fields_ = [("u", _U),
|
||||||
("vt", VARTYPE)]
|
("vt", VARTYPE)]
|
||||||
|
|
||||||
_anonymous_ = ("u",)
|
|
||||||
|
|
||||||
The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field
|
The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field
|
||||||
specifies which one of the union fields is valid. Since the ``u`` field
|
specifies which one of the union fields is valid. Since the ``u`` field
|
||||||
|
|
|
@ -1494,10 +1494,6 @@ For :class:`date` objects, the format codes for hours, minutes, seconds, and
|
||||||
microseconds should not be used, as :class:`date` objects have no such
|
microseconds should not be used, as :class:`date` objects have no such
|
||||||
values. If they're used anyway, ``0`` is substituted for them.
|
values. If they're used anyway, ``0`` is substituted for them.
|
||||||
|
|
||||||
:class:`time` and :class:`datetime` objects support a ``%f`` format code
|
|
||||||
which expands to the number of microseconds in the object, zero-padded on
|
|
||||||
the left to six places.
|
|
||||||
|
|
||||||
For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty
|
For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty
|
||||||
strings.
|
strings.
|
||||||
|
|
||||||
|
@ -1616,7 +1612,9 @@ Notes:
|
||||||
(1)
|
(1)
|
||||||
When used with the :func:`strptime` function, the ``%f`` directive
|
When used with the :func:`strptime` function, the ``%f`` directive
|
||||||
accepts from one to six digits and zero pads on the right. ``%f`` is
|
accepts from one to six digits and zero pads on the right. ``%f`` is
|
||||||
an extension to the set of format characters in the C standard.
|
an extension to the set of format characters in the C standard (but
|
||||||
|
implemented separately in datetime objects, and therefore always
|
||||||
|
available).
|
||||||
|
|
||||||
(2)
|
(2)
|
||||||
When used with the :func:`strptime` function, the ``%p`` directive only affects
|
When used with the :func:`strptime` function, the ``%p`` directive only affects
|
||||||
|
|
|
@ -149,13 +149,13 @@ be found in any statistics text.
|
||||||
|
|
||||||
.. function:: uniform(a, b)
|
.. function:: uniform(a, b)
|
||||||
|
|
||||||
Return a random floating point number *N* such that ``a <= N < b`` for
|
Return a random floating point number *N* such that ``a <= N <= b`` for
|
||||||
``a <= b`` and ``b <= N < a`` for ``b < a``.
|
``a <= b`` and ``b <= N <= a`` for ``b < a``.
|
||||||
|
|
||||||
|
|
||||||
.. function:: triangular(low, high, mode)
|
.. function:: triangular(low, high, mode)
|
||||||
|
|
||||||
Return a random floating point number *N* such that ``low <= N < high`` and
|
Return a random floating point number *N* such that ``low <= N <= high`` and
|
||||||
with the specified *mode* between those bounds. The *low* and *high* bounds
|
with the specified *mode* between those bounds. The *low* and *high* bounds
|
||||||
default to zero and one. The *mode* argument defaults to the midpoint
|
default to zero and one. The *mode* argument defaults to the midpoint
|
||||||
between the bounds, giving a symmetric distribution.
|
between the bounds, giving a symmetric distribution.
|
||||||
|
@ -163,8 +163,8 @@ be found in any statistics text.
|
||||||
|
|
||||||
.. function:: betavariate(alpha, beta)
|
.. function:: betavariate(alpha, beta)
|
||||||
|
|
||||||
Beta distribution. Conditions on the parameters are ``alpha > 0`` and ``beta >
|
Beta distribution. Conditions on the parameters are ``alpha > 0`` and
|
||||||
0``. Returned values range between 0 and 1.
|
``beta > 0``. Returned values range between 0 and 1.
|
||||||
|
|
||||||
|
|
||||||
.. function:: expovariate(lambd)
|
.. function:: expovariate(lambd)
|
||||||
|
@ -178,14 +178,15 @@ be found in any statistics text.
|
||||||
|
|
||||||
.. function:: gammavariate(alpha, beta)
|
.. function:: gammavariate(alpha, beta)
|
||||||
|
|
||||||
Gamma distribution. (*Not* the gamma function!) Conditions on the parameters
|
Gamma distribution. (*Not* the gamma function!) Conditions on the
|
||||||
are ``alpha > 0`` and ``beta > 0``.
|
parameters are ``alpha > 0`` and ``beta > 0``.
|
||||||
|
|
||||||
|
|
||||||
.. function:: gauss(mu, sigma)
|
.. function:: gauss(mu, sigma)
|
||||||
|
|
||||||
Gaussian distribution. *mu* is the mean, and *sigma* is the standard deviation.
|
Gaussian distribution. *mu* is the mean, and *sigma* is the standard
|
||||||
This is slightly faster than the :func:`normalvariate` function defined below.
|
deviation. This is slightly faster than the :func:`normalvariate` function
|
||||||
|
defined below.
|
||||||
|
|
||||||
|
|
||||||
.. function:: lognormvariate(mu, sigma)
|
.. function:: lognormvariate(mu, sigma)
|
||||||
|
|
|
@ -343,19 +343,19 @@ Notes:
|
||||||
All :class:`numbers.Real` types (:class:`int` and
|
All :class:`numbers.Real` types (:class:`int` and
|
||||||
:class:`float`) also include the following operations:
|
:class:`float`) also include the following operations:
|
||||||
|
|
||||||
+--------------------+--------------------------------+--------+
|
+--------------------+------------------------------------+--------+
|
||||||
| Operation | Result | Notes |
|
| Operation | Result | Notes |
|
||||||
+====================+================================+========+
|
+====================+====================================+========+
|
||||||
| ``trunc(x)`` | *x* truncated to Integral | |
|
| ``math.trunc(x)`` | *x* truncated to Integral | |
|
||||||
+--------------------+--------------------------------+--------+
|
+--------------------+------------------------------------+--------+
|
||||||
| ``round(x[, n])`` | *x* rounded to n digits, | |
|
| ``round(x[, n])`` | *x* rounded to n digits, | |
|
||||||
| | rounding half to even. If n is | |
|
| | rounding half to even. If n is | |
|
||||||
| | omitted, it defaults to 0. | |
|
| | omitted, it defaults to 0. | |
|
||||||
+--------------------+--------------------------------+--------+
|
+--------------------+------------------------------------+--------+
|
||||||
| ``math.floor(x)`` | the greatest Integral <= *x* | |
|
| ``math.floor(x)`` | the greatest integral float <= *x* | |
|
||||||
+--------------------+--------------------------------+--------+
|
+--------------------+------------------------------------+--------+
|
||||||
| ``math.ceil(x)`` | the least Integral >= *x* | |
|
| ``math.ceil(x)`` | the least integral float >= *x* | |
|
||||||
+--------------------+--------------------------------+--------+
|
+--------------------+------------------------------------+--------+
|
||||||
|
|
||||||
For additional numeric operations see the :mod:`math` and :mod:`cmath`
|
For additional numeric operations see the :mod:`math` and :mod:`cmath`
|
||||||
modules.
|
modules.
|
||||||
|
@ -595,10 +595,10 @@ Sequence Types --- :class:`str`, :class:`bytes`, :class:`bytearray`, :class:`lis
|
||||||
==================================================================================================================
|
==================================================================================================================
|
||||||
|
|
||||||
There are six sequence types: strings, byte sequences (:class:`bytes` objects),
|
There are six sequence types: strings, byte sequences (:class:`bytes` objects),
|
||||||
byte arrays (:class:`bytearray` objects), lists, tuples, and range objects.
|
byte arrays (:class:`bytearray` objects), lists, tuples, and range objects. For
|
||||||
|
other containers see the built in :class:`dict` and :class:`set` classes, and
|
||||||
|
the :mod:`collections` module.
|
||||||
|
|
||||||
For other containers see the built-in :class:`dict`, :class:`list`,
|
|
||||||
:class:`set`, and :class:`tuple` classes, and the :mod:`collections` module.
|
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
object: sequence
|
object: sequence
|
||||||
|
@ -1623,12 +1623,12 @@ The constructors for both classes work the same:
|
||||||
.. method:: union(other, ...)
|
.. method:: union(other, ...)
|
||||||
set | other | ...
|
set | other | ...
|
||||||
|
|
||||||
Return a new set with elements from both sets.
|
Return a new set with elements from the set and all others.
|
||||||
|
|
||||||
.. method:: intersection(other, ...)
|
.. method:: intersection(other, ...)
|
||||||
set & other & ...
|
set & other & ...
|
||||||
|
|
||||||
Return a new set with elements common to both sets.
|
Return a new set with elements common to the set and all others.
|
||||||
|
|
||||||
.. method:: difference(other, ...)
|
.. method:: difference(other, ...)
|
||||||
set - other - ...
|
set - other - ...
|
||||||
|
|
|
@ -317,7 +317,7 @@ Sequences
|
||||||
slicing notations can be used as the target of assignment and :keyword:`del`
|
slicing notations can be used as the target of assignment and :keyword:`del`
|
||||||
(delete) statements.
|
(delete) statements.
|
||||||
|
|
||||||
There is currently a single intrinsic mutable sequence type:
|
There are currently two intrinsic mutable sequence types:
|
||||||
|
|
||||||
Lists
|
Lists
|
||||||
.. index:: object: list
|
.. index:: object: list
|
||||||
|
@ -1777,13 +1777,13 @@ left undefined.
|
||||||
object.__ixor__(self, other)
|
object.__ixor__(self, other)
|
||||||
object.__ior__(self, other)
|
object.__ior__(self, other)
|
||||||
|
|
||||||
These methods are called to implement the augmented arithmetic operations
|
These methods are called to implement the augmented arithmetic assignments
|
||||||
(``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``, ``>>=``,
|
(``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``, ``>>=``,
|
||||||
``&=``, ``^=``, ``|=``). These methods should attempt to do the operation
|
``&=``, ``^=``, ``|=``). These methods should attempt to do the operation
|
||||||
in-place (modifying *self*) and return the result (which could be, but does
|
in-place (modifying *self*) and return the result (which could be, but does
|
||||||
not have to be, *self*). If a specific method is not defined, the augmented
|
not have to be, *self*). If a specific method is not defined, the augmented
|
||||||
operation falls back to the normal methods. For instance, to evaluate the
|
assignment falls back to the normal methods. For instance, to execute the
|
||||||
expression ``x += y``, where *x* is an instance of a class that has an
|
statement ``x += y``, where *x* is an instance of a class that has an
|
||||||
:meth:`__iadd__` method, ``x.__iadd__(y)`` is called. If *x* is an instance
|
:meth:`__iadd__` method, ``x.__iadd__(y)`` is called. If *x* is an instance
|
||||||
of a class that does not define a :meth:`__iadd__` method, ``x.__add__(y)``
|
of a class that does not define a :meth:`__iadd__` method, ``x.__add__(y)``
|
||||||
and ``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``.
|
and ``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``.
|
||||||
|
|
|
@ -246,7 +246,8 @@ Augmented assignment is the combination, in a single statement, of a binary
|
||||||
operation and an assignment statement:
|
operation and an assignment statement:
|
||||||
|
|
||||||
.. productionlist::
|
.. productionlist::
|
||||||
augmented_assignment_stmt: `target` `augop` (`expression_list` | `yield_expression`)
|
augmented_assignment_stmt: `augtarget` `augop` (`expression_list` | `yield_expression`)
|
||||||
|
augtarget: `identifier` | `attributeref` | `subscription` | `slicing`
|
||||||
augop: "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="
|
augop: "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="
|
||||||
: | ">>=" | "<<=" | "&=" | "^=" | "|="
|
: | ">>=" | "<<=" | "&=" | "^=" | "|="
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
#
|
#
|
||||||
# 01/2009, Georg Brandl
|
# 01/2009, Georg Brandl
|
||||||
|
|
||||||
|
# TODO: - wrong versions in versionadded/changed
|
||||||
|
# - wrong markup after versionchanged directive
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -881,8 +881,8 @@ def formatargspec(args, varargs=None, varkw=None, defaults=None,
|
||||||
specs = []
|
specs = []
|
||||||
if defaults:
|
if defaults:
|
||||||
firstdefault = len(args) - len(defaults)
|
firstdefault = len(args) - len(defaults)
|
||||||
for i in range(len(args)):
|
for i, arg in enumerate(args):
|
||||||
spec = strseq(args[i], formatargandannotation, join)
|
spec = strseq(arg, formatargandannotation, join)
|
||||||
if defaults and i >= firstdefault:
|
if defaults and i >= firstdefault:
|
||||||
spec = spec + formatvalue(defaults[i - firstdefault])
|
spec = spec + formatvalue(defaults[i - firstdefault])
|
||||||
specs.append(spec)
|
specs.append(spec)
|
||||||
|
|
|
@ -592,7 +592,7 @@ class CodecCallbackTest(unittest.TestCase):
|
||||||
encs = ("ascii", "latin-1", "iso-8859-1", "iso-8859-15")
|
encs = ("ascii", "latin-1", "iso-8859-1", "iso-8859-15")
|
||||||
|
|
||||||
for res in results:
|
for res in results:
|
||||||
codecs.register_error("test.badhandler", lambda: res)
|
codecs.register_error("test.badhandler", lambda x: res)
|
||||||
for enc in encs:
|
for enc in encs:
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
TypeError,
|
TypeError,
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
/* ffi_prep_args is called by the assembly routine once stack space
|
/* ffi_prep_args is called by the assembly routine once stack space
|
||||||
has been allocated for the function's arguments */
|
has been allocated for the function's arguments */
|
||||||
|
|
||||||
extern void Py_FatalError(char *msg);
|
extern void Py_FatalError(const char *msg);
|
||||||
|
|
||||||
/*@-exportheader@*/
|
/*@-exportheader@*/
|
||||||
void ffi_prep_args(char *stack, extended_cif *ecif)
|
void ffi_prep_args(char *stack, extended_cif *ecif)
|
||||||
|
|
|
@ -1923,7 +1923,7 @@ _PyExc_Init(void)
|
||||||
|
|
||||||
PyExc_MemoryErrorInst = BaseException_new(&_PyExc_MemoryError, NULL, NULL);
|
PyExc_MemoryErrorInst = BaseException_new(&_PyExc_MemoryError, NULL, NULL);
|
||||||
if (!PyExc_MemoryErrorInst)
|
if (!PyExc_MemoryErrorInst)
|
||||||
Py_FatalError("Cannot pre-allocate MemoryError instance\n");
|
Py_FatalError("Cannot pre-allocate MemoryError instance");
|
||||||
|
|
||||||
PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
|
PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
|
||||||
if (!PyExc_RecursionErrorInst)
|
if (!PyExc_RecursionErrorInst)
|
||||||
|
|
|
@ -191,7 +191,7 @@ num_stmts(const node *n)
|
||||||
default: {
|
default: {
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
sprintf(buf, "Non-statement found: %d %d\n",
|
sprintf(buf, "Non-statement found: %d %d",
|
||||||
TYPE(n), NCH(n));
|
TYPE(n), NCH(n));
|
||||||
Py_FatalError(buf);
|
Py_FatalError(buf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1239,7 +1239,7 @@ get_ref_type(struct compiler *c, PyObject *name)
|
||||||
char buf[350];
|
char buf[350];
|
||||||
PyOS_snprintf(buf, sizeof(buf),
|
PyOS_snprintf(buf, sizeof(buf),
|
||||||
"unknown scope for %.100s in %.100s(%s) in %s\n"
|
"unknown scope for %.100s in %.100s(%s) in %s\n"
|
||||||
"symbols: %s\nlocals: %s\nglobals: %s\n",
|
"symbols: %s\nlocals: %s\nglobals: %s",
|
||||||
PyBytes_AS_STRING(name),
|
PyBytes_AS_STRING(name),
|
||||||
PyBytes_AS_STRING(c->u->u_name),
|
PyBytes_AS_STRING(c->u->u_name),
|
||||||
PyObject_REPR(c->u->u_ste->ste_id),
|
PyObject_REPR(c->u->u_ste->ste_id),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue