Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93dc9eb

Browse files
committed
Merged revisions 78760,78771-78773,78802,78922,78952 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r78760 | georg.brandl | 2010-03-07 16:23:59 +0100 (So, 07 Mär 2010) | 1 line python#5341: more built-in vs builtin fixes. ........ r78771 | georg.brandl | 2010-03-07 21:58:31 +0100 (So, 07 Mär 2010) | 1 line python#8085: The function is called PyObject_NewVar, not PyObject_VarNew. ........ r78772 | georg.brandl | 2010-03-07 22:12:28 +0100 (So, 07 Mär 2010) | 1 line python#8039: document conditional expressions better, giving them their own section. ........ r78773 | georg.brandl | 2010-03-07 22:32:06 +0100 (So, 07 Mär 2010) | 1 line python#8044: document Py_{Enter,Leave}RecursiveCall functions. ........ r78802 | georg.brandl | 2010-03-08 17:28:40 +0100 (Mo, 08 Mär 2010) | 1 line Fix typo. ........ r78922 | georg.brandl | 2010-03-13 14:41:58 +0100 (Sa, 13 Mär 2010) | 1 line Update for new download location. ........ r78952 | georg.brandl | 2010-03-14 10:55:08 +0100 (So, 14 Mär 2010) | 1 line python#8137: add iso-8859-16 to the standard encodings table. ........
1 parent c0e22b7 commit 93dc9eb

10 files changed

Lines changed: 114 additions & 65 deletions

File tree

Doc/c-api/exceptions.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,36 @@ Exception Objects
471471
This steals a reference to *ctx*.
472472

473473

474+
Recursion Control
475+
=================
476+
477+
These two functions provide a way to perform safe recursive calls at the C
478+
level, both in the core and in extension modules. They are needed if the
479+
recursive code does not necessarily invoke Python code (which tracks its
480+
recursion depth automatically).
481+
482+
.. cfunction:: int Py_EnterRecursiveCall(char *where)
483+
484+
Marks a point where a recursive C-level call is about to be performed.
485+
486+
If :const:`USE_STACKCHECK` is defined, this function checks if the the OS
487+
stack overflowed using :cfunc:`PyOS_CheckStack`. In this is the case, it
488+
sets a :exc:`MemoryError` and returns a nonzero value.
489+
490+
The function then checks if the recursion limit is reached. If this is the
491+
case, a :exc:`RuntimeError` is set and a nonzero value is returned.
492+
Otherwise, zero is returned.
493+
494+
*where* should be a string such as ``" in instance check"`` to be
495+
concatenated to the :exc:`RuntimeError` message caused by the recursion depth
496+
limit.
497+
498+
.. cfunction:: void Py_LeaveRecursiveCall()
499+
500+
Ends a :cfunc:`Py_EnterRecursiveCall`. Must be called once for each
501+
*successful* invocation of :cfunc:`Py_EnterRecursiveCall`.
502+
503+
474504
.. _standardexceptions:
475505

476506
Standard Exceptions

Doc/c-api/gcsupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ include the :const:`Py_TPFLAGS_HAVE_GC` and provide an implementation of the
2828
Constructors for container types must conform to two rules:
2929

3030
#. The memory for the object must be allocated using :cfunc:`PyObject_GC_New`
31-
or :cfunc:`PyObject_GC_VarNew`.
31+
or :cfunc:`PyObject_GC_NewVar`.
3232

3333
#. Once all the fields which may contain references to other containers are
3434
initialized, it must call :cfunc:`PyObject_GC_Track`.

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ type objects) *must* have the :attr:`ob_size` field.
182182
instance; this is normally :cfunc:`PyObject_Del` if the instance was allocated
183183
using :cfunc:`PyObject_New` or :cfunc:`PyObject_VarNew`, or
184184
:cfunc:`PyObject_GC_Del` if the instance was allocated using
185-
:cfunc:`PyObject_GC_New` or :cfunc:`PyObject_GC_VarNew`.
185+
:cfunc:`PyObject_GC_New` or :cfunc:`PyObject_GC_NewVar`.
186186

187187
This field is inherited by subtypes.
188188

Doc/library/argparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ By default, ArgumentParser objects read command-line args in as simple strings.
855855
However, quite often the command-line string should instead be interpreted as
856856
another type, like a :class:`float`, :class:`int` or :class:`file`. The
857857
``type`` keyword argument of :meth:`add_argument` allows any necessary
858-
type-checking and type-conversions to be performed. Many common builtin types
858+
type-checking and type-conversions to be performed. Many common built-in types
859859
can be used directly as the value of the ``type`` argument::
860860

861861
>>> parser = argparse.ArgumentParser()

Doc/library/codecs.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,11 +1065,13 @@ particular, the following variants typically exist:
10651065
+-----------------+--------------------------------+--------------------------------+
10661066
| iso8859_10 | iso-8859-10, latin6, L6 | Nordic languages |
10671067
+-----------------+--------------------------------+--------------------------------+
1068-
| iso8859_13 | iso-8859-13 | Baltic languages |
1068+
| iso8859_13 | iso-8859-13, latin7, L7 | Baltic languages |
10691069
+-----------------+--------------------------------+--------------------------------+
10701070
| iso8859_14 | iso-8859-14, latin8, L8 | Celtic languages |
10711071
+-----------------+--------------------------------+--------------------------------+
1072-
| iso8859_15 | iso-8859-15 | Western Europe |
1072+
| iso8859_15 | iso-8859-15, latin9, L9 | Western Europe |
1073+
+-----------------+--------------------------------+--------------------------------+
1074+
| iso8859_16 | iso-8859-16, latin10, L10 | South-Eastern Europe |
10731075
+-----------------+--------------------------------+--------------------------------+
10741076
| johab | cp1361, ms1361 | Korean |
10751077
+-----------------+--------------------------------+--------------------------------+

Doc/reference/executionmodel.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ namespace is searched. The global statement must precede all uses of the name.
120120
121121
.. index:: pair: restricted; execution
122122

123-
The built-in namespace associated with the execution of a code block is actually
123+
The builtins namespace associated with the execution of a code block is actually
124124
found by looking up the name ``__builtins__`` in its global namespace; this
125125
should be a dictionary or a module (in the latter case the module's dictionary
126126
is used). By default, when in the :mod:`__main__` module, ``__builtins__`` is
@@ -132,7 +132,7 @@ weak form of restricted execution.
132132
.. impl-detail::
133133

134134
Users should not touch ``__builtins__``; it is strictly an implementation
135-
detail. Users wanting to override values in the built-in namespace should
135+
detail. Users wanting to override values in the builtins namespace should
136136
:keyword:`import` the :mod:`builtins` module and modify its
137137
attributes appropriately.
138138

Doc/reference/expressions.rst

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,12 +1113,7 @@ Boolean operations
11131113
pair: Conditional; expression
11141114
pair: Boolean; operation
11151115

1116-
Boolean operations have the lowest priority of all Python operations:
1117-
11181116
.. productionlist::
1119-
expression: `conditional_expression` | `lambda_form`
1120-
expression_nocond: `or_test` | `lambda_form_nocond`
1121-
conditional_expression: `or_test` ["if" `or_test` "else" `expression`]
11221117
or_test: `and_test` | `or_test` "or" `and_test`
11231118
and_test: `not_test` | `and_test` "and" `not_test`
11241119
not_test: `comparison` | "not" `not_test`
@@ -1135,10 +1130,6 @@ truth value by providing a :meth:`__bool__` method.
11351130
The operator :keyword:`not` yields ``True`` if its argument is false, ``False``
11361131
otherwise.
11371132

1138-
The expression ``x if C else y`` first evaluates *C* (*not* *x*); if *C* is
1139-
true, *x* is evaluated and its value is returned; otherwise, *y* is evaluated
1140-
and its value is returned.
1141-
11421133
.. index:: operator: and
11431134

11441135
The expression ``x and y`` first evaluates *x*; if *x* is false, its value is
@@ -1158,6 +1149,30 @@ not bother to return a value of the same type as its argument, so e.g., ``not
11581149
'foo'`` yields ``False``, not ``''``.)
11591150

11601151

1152+
Conditional Expressions
1153+
=======================
1154+
1155+
.. versionadded:: 2.5
1156+
1157+
.. index::
1158+
pair: conditional; expression
1159+
pair: ternary; operator
1160+
1161+
.. productionlist::
1162+
conditional_expression: `or_test` ["if" `or_test` "else" `expression`]
1163+
expression: `conditional_expression` | `lambda_form`
1164+
expression_nocond: `or_test` | `lambda_form_nocond`
1165+
1166+
Conditional expressions (sometimes called a "ternary operator") have the lowest
1167+
priority of all Python operations.
1168+
1169+
The expression ``x if C else y`` first evaluates the condition, *C* (*not* *x*);
1170+
if *C* is true, *x* is evaluated and its value is returned; otherwise, *y* is
1171+
evaluated and its value is returned.
1172+
1173+
See :pep:`308` for more details about conditional expressions.
1174+
1175+
11611176
.. _lambdas:
11621177
.. _lambda:
11631178

@@ -1252,6 +1267,8 @@ groups from right to left).
12521267
+===============================================+=====================================+
12531268
| :keyword:`lambda` | Lambda expression |
12541269
+-----------------------------------------------+-------------------------------------+
1270+
| :keyword:`if` -- :keyword:`else` | Conditional expression |
1271+
+-----------------------------------------------+-------------------------------------+
12551272
| :keyword:`or` | Boolean OR |
12561273
+-----------------------------------------------+-------------------------------------+
12571274
| :keyword:`and` | Boolean AND |

Doc/whatsnew/2.6.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ are:
111111
:func:`reduce` function.
112112

113113
Python 3.0 adds several new built-in functions and changes the
114-
semantics of some existing built-ins. Functions that are new in 3.0
114+
semantics of some existing builtins. Functions that are new in 3.0
115115
such as :func:`bin` have simply been added to Python 2.6, but existing
116-
built-ins haven't been changed; instead, the :mod:`future_builtins`
116+
builtins haven't been changed; instead, the :mod:`future_builtins`
117117
module has versions with the new 3.0 semantics. Code written to be
118118
compatible with 3.0 can do ``from future_builtins import hex, map`` as
119119
necessary.
@@ -837,7 +837,7 @@ formatted. It receives a single argument, the format specifier::
837837
else:
838838
return str(self)
839839

840-
There's also a :func:`format` built-in that will format a single
840+
There's also a :func:`format` builtin that will format a single
841841
value. It calls the type's :meth:`__format__` method with the
842842
provided specifier::
843843

@@ -1168,7 +1168,7 @@ access protocol. Abstract Base Classes (or ABCs) are an equivalent
11681168
feature for Python. The ABC support consists of an :mod:`abc` module
11691169
containing a metaclass called :class:`ABCMeta`, special handling of
11701170
this metaclass by the :func:`isinstance` and :func:`issubclass`
1171-
built-ins, and a collection of basic ABCs that the Python developers
1171+
builtins, and a collection of basic ABCs that the Python developers
11721172
think will be widely useful. Future versions of Python will probably
11731173
add more ABCs.
11741174

@@ -1322,9 +1322,9 @@ an octal number, but it does add support for "0o" and "0b"::
13221322
>>> 0b101111
13231323
47
13241324

1325-
The :func:`oct` built-in still returns numbers
1325+
The :func:`oct` builtin still returns numbers
13261326
prefixed with a leading zero, and a new :func:`bin`
1327-
built-in returns the binary representation for a number::
1327+
builtin returns the binary representation for a number::
13281328

13291329
>>> oct(42)
13301330
'052'
@@ -1333,7 +1333,7 @@ built-in returns the binary representation for a number::
13331333
>>> bin(173)
13341334
'0b10101101'
13351335

1336-
The :func:`int` and :func:`long` built-ins will now accept the "0o"
1336+
The :func:`int` and :func:`long` builtins will now accept the "0o"
13371337
and "0b" prefixes when base-8 or base-2 are requested, or when the
13381338
*base* argument is zero (signalling that the base used should be
13391339
determined from the string)::
@@ -1419,7 +1419,7 @@ can be shifted left and right with ``<<`` and ``>>``,
14191419
combined using bitwise operations such as ``&`` and ``|``,
14201420
and can be used as array indexes and slice boundaries.
14211421

1422-
In Python 3.0, the PEP slightly redefines the existing built-ins
1422+
In Python 3.0, the PEP slightly redefines the existing builtins
14231423
:func:`round`, :func:`math.floor`, :func:`math.ceil`, and adds a new
14241424
one, :func:`math.trunc`, that's been backported to Python 2.6.
14251425
:func:`math.trunc` rounds toward zero, returning the closest
@@ -1527,7 +1527,7 @@ Some smaller changes made to the core Python language are:
15271527
Previously this would have been a syntax error.
15281528
(Contributed by Amaury Forgeot d'Arc; :issue:`3473`.)
15291529

1530-
* A new built-in, ``next(iterator, [default])`` returns the next item
1530+
* A new builtin, ``next(iterator, [default])`` returns the next item
15311531
from the specified iterator. If the *default* argument is supplied,
15321532
it will be returned if *iterator* has been exhausted; otherwise,
15331533
the :exc:`StopIteration` exception will be raised. (Backported
@@ -1956,9 +1956,9 @@ changes, or look through the Subversion logs for all the details.
19561956
(Contributed by Phil Schwartz; :issue:`1221598`.)
19571957

19581958
* The :func:`reduce` built-in function is also available in the
1959-
:mod:`functools` module. In Python 3.0, the built-in has been
1959+
:mod:`functools` module. In Python 3.0, the builtin has been
19601960
dropped and :func:`reduce` is only available from :mod:`functools`;
1961-
currently there are no plans to drop the built-in in the 2.x series.
1961+
currently there are no plans to drop the builtin in the 2.x series.
19621962
(Patched by Christian Heimes; :issue:`1739906`.)
19631963

19641964
* When possible, the :mod:`getpass` module will now use
@@ -2760,7 +2760,7 @@ The functions in this module currently include:
27602760

27612761
* ``filter(predicate, iterable)``,
27622762
``map(func, iterable1, ...)``: the 3.0 versions
2763-
return iterators, unlike the 2.x built-ins which return lists.
2763+
return iterators, unlike the 2.x builtins which return lists.
27642764

27652765
* ``hex(value)``, ``oct(value)``: instead of calling the
27662766
:meth:`__hex__` or :meth:`__oct__` methods, these versions will

0 commit comments

Comments
 (0)