mirror of
https://github.com/python/cpython.git
synced 2025-09-28 11:15:17 +00:00
Merged revisions 75149,75260-75263,75265-75267,75292,75300,75376,75405,75429-75433,75437,75445,75501,75551,75572,75589-75591,75657,75742,75868,75952-75957,76057,76105,76139,76143,76162,76223 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r75149 | gregory.p.smith | 2009-09-29 16:56:31 -0500 (Tue, 29 Sep 2009) | 3 lines Mention issue6972 in extractall docs about overwriting things outside of the supplied path. ........ r75260 | andrew.kuchling | 2009-10-05 16:24:20 -0500 (Mon, 05 Oct 2009) | 1 line Wording fix ........ r75261 | andrew.kuchling | 2009-10-05 16:24:35 -0500 (Mon, 05 Oct 2009) | 1 line Fix narkup ........ r75262 | andrew.kuchling | 2009-10-05 16:25:03 -0500 (Mon, 05 Oct 2009) | 1 line Document 'skip' parameter to constructor ........ r75263 | andrew.kuchling | 2009-10-05 16:25:35 -0500 (Mon, 05 Oct 2009) | 1 line Note side benefit of socket.create_connection() ........ r75265 | andrew.kuchling | 2009-10-05 17:31:11 -0500 (Mon, 05 Oct 2009) | 1 line Reword sentence ........ r75266 | andrew.kuchling | 2009-10-05 17:32:48 -0500 (Mon, 05 Oct 2009) | 1 line Use standard comma punctuation; reword some sentences in the docs ........ r75267 | andrew.kuchling | 2009-10-05 17:42:56 -0500 (Mon, 05 Oct 2009) | 1 line Backport r73983: Document the thousands separator. ........ r75292 | benjamin.peterson | 2009-10-08 22:11:36 -0500 (Thu, 08 Oct 2009) | 1 line death to old CVS keyword ........ r75300 | benjamin.peterson | 2009-10-09 16:48:14 -0500 (Fri, 09 Oct 2009) | 1 line fix some coding style ........ r75376 | benjamin.peterson | 2009-10-11 20:26:07 -0500 (Sun, 11 Oct 2009) | 1 line platform we don't care about ........ r75405 | neil.schemenauer | 2009-10-14 12:17:14 -0500 (Wed, 14 Oct 2009) | 4 lines Issue #1754094: Improve the stack depth calculation in the compiler. There should be no other effect than a small decrease in memory use. Patch by Christopher Tur Lesniewski-Laas. ........ r75429 | benjamin.peterson | 2009-10-14 20:47:28 -0500 (Wed, 14 Oct 2009) | 1 line pep8ify if blocks ........ r75430 | benjamin.peterson | 2009-10-14 20:49:37 -0500 (Wed, 14 Oct 2009) | 1 line use floor division and add a test that exercises the tabsize codepath ........ r75431 | benjamin.peterson | 2009-10-14 20:56:25 -0500 (Wed, 14 Oct 2009) | 1 line change test to what I intended ........ r75432 | benjamin.peterson | 2009-10-14 22:05:39 -0500 (Wed, 14 Oct 2009) | 1 line some cleanups ........ r75433 | benjamin.peterson | 2009-10-14 22:06:55 -0500 (Wed, 14 Oct 2009) | 1 line make inspect.isabstract() always return a boolean; add a test for it, too #7069 ........ r75437 | benjamin.peterson | 2009-10-15 10:44:46 -0500 (Thu, 15 Oct 2009) | 1 line only clear a module's __dict__ if the module is the only one with a reference to it #7140 ........ r75445 | vinay.sajip | 2009-10-16 09:06:44 -0500 (Fri, 16 Oct 2009) | 1 line Issue #7120: logging: Removed import of multiprocessing which is causing crash in GAE. ........ r75501 | antoine.pitrou | 2009-10-18 13:37:11 -0500 (Sun, 18 Oct 2009) | 3 lines Add a comment about unreachable code, and fix a typo ........ r75551 | benjamin.peterson | 2009-10-19 22:14:10 -0500 (Mon, 19 Oct 2009) | 1 line use property api ........ r75572 | benjamin.peterson | 2009-10-20 16:55:17 -0500 (Tue, 20 Oct 2009) | 1 line clarify buffer arg #7178 ........ r75589 | benjamin.peterson | 2009-10-21 21:26:47 -0500 (Wed, 21 Oct 2009) | 1 line whitespace ........ r75590 | benjamin.peterson | 2009-10-21 21:36:47 -0500 (Wed, 21 Oct 2009) | 1 line rewrite to be nice to other implementations ........ r75591 | benjamin.peterson | 2009-10-21 21:50:38 -0500 (Wed, 21 Oct 2009) | 4 lines rewrite for style, clarify, and comments Also, use the hasattr() like scheme of allowing BaseException exceptions through. ........ r75657 | antoine.pitrou | 2009-10-24 07:41:27 -0500 (Sat, 24 Oct 2009) | 3 lines Fix compilation error in debug mode. ........ r75742 | benjamin.peterson | 2009-10-26 17:51:16 -0500 (Mon, 26 Oct 2009) | 1 line use 'is' instead of id() ........ r75868 | benjamin.peterson | 2009-10-27 15:59:18 -0500 (Tue, 27 Oct 2009) | 1 line test expect base classes ........ r75952 | georg.brandl | 2009-10-29 15:38:32 -0500 (Thu, 29 Oct 2009) | 1 line Use the correct function name in docstring. ........ r75953 | georg.brandl | 2009-10-29 15:39:50 -0500 (Thu, 29 Oct 2009) | 1 line Remove mention of the old -X command line switch. ........ r75954 | georg.brandl | 2009-10-29 15:53:00 -0500 (Thu, 29 Oct 2009) | 1 line Use constants instead of magic integers for test result. Do not re-run with --verbose3 for environment changing tests. ........ r75955 | georg.brandl | 2009-10-29 15:54:03 -0500 (Thu, 29 Oct 2009) | 1 line Use a single style for all the docstrings in the math module. ........ r75956 | georg.brandl | 2009-10-29 16:16:34 -0500 (Thu, 29 Oct 2009) | 1 line I do not think the "railroad" program mentioned is still available. ........ r75957 | georg.brandl | 2009-10-29 16:44:56 -0500 (Thu, 29 Oct 2009) | 1 line Fix constant name. ........ r76057 | benjamin.peterson | 2009-11-02 09:06:45 -0600 (Mon, 02 Nov 2009) | 1 line prevent a rather unlikely segfault ........ r76105 | georg.brandl | 2009-11-04 01:38:12 -0600 (Wed, 04 Nov 2009) | 1 line #7259: show correct equivalent for operator.i* operations in docstring; fix minor issues in operator docs. ........ r76139 | benjamin.peterson | 2009-11-06 19:04:38 -0600 (Fri, 06 Nov 2009) | 1 line spelling ........ r76143 | georg.brandl | 2009-11-07 02:26:07 -0600 (Sat, 07 Nov 2009) | 1 line #7271: fix typo. ........ r76162 | benjamin.peterson | 2009-11-08 22:10:53 -0600 (Sun, 08 Nov 2009) | 1 line discuss how to use -p ........ r76223 | georg.brandl | 2009-11-12 02:29:46 -0600 (Thu, 12 Nov 2009) | 1 line Give the profile module a module directive. ........
This commit is contained in:
parent
0089d75c56
commit
a0dfa82eca
33 changed files with 347 additions and 219 deletions
|
@ -1952,7 +1952,7 @@ This is described in more detail in :pep:`301`.
|
||||||
|
|
||||||
|
|
||||||
The ``check`` command performs some tests on the meta-data of a package.
|
The ``check`` command performs some tests on the meta-data of a package.
|
||||||
It makes sure for example that all required meta-data are provided through
|
For example, it verifies that all required meta-data are provided as
|
||||||
the arguments passed to the :func:`setup` function.
|
the arguments passed to the :func:`setup` function.
|
||||||
|
|
||||||
.. % todo
|
.. % todo
|
||||||
|
|
|
@ -236,10 +236,10 @@ With exactly the same source tree layout, this extension can be put in the
|
||||||
Checking a package
|
Checking a package
|
||||||
==================
|
==================
|
||||||
|
|
||||||
The ``check`` command allows you to verify if your package meta-data are
|
The ``check`` command allows you to verify if your package meta-data
|
||||||
meeting the minimum requirements to build a distribution.
|
meet the minimum requirements to build a distribution.
|
||||||
|
|
||||||
To run it, just call it over your :file:`setup.py` script. If something is
|
To run it, just call it using your :file:`setup.py` script. If something is
|
||||||
missing, ``check`` will display a warning.
|
missing, ``check`` will display a warning.
|
||||||
|
|
||||||
Let's take an example with a simple script::
|
Let's take an example with a simple script::
|
||||||
|
@ -252,7 +252,7 @@ Running the ``check`` command will display some warnings::
|
||||||
|
|
||||||
$ python setup.py check
|
$ python setup.py check
|
||||||
running check
|
running check
|
||||||
warning: check: missing required meta-data: version ,url
|
warning: check: missing required meta-data: version, url
|
||||||
warning: check: missing meta-data: either (author and author_email) or
|
warning: check: missing meta-data: either (author and author_email) or
|
||||||
(maintainer and maintainer_email) must be supplied
|
(maintainer and maintainer_email) must be supplied
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,14 @@ document could also be refactored with this option.
|
||||||
The :option:`-v` option enables output of more information on the translation
|
The :option:`-v` option enables output of more information on the translation
|
||||||
process.
|
process.
|
||||||
|
|
||||||
|
Since some print statements can be parsed as function calls or statements, 2to3
|
||||||
|
cannot always read files containing the print function. When 2to3 detects the
|
||||||
|
presence of the ``from __future__ import print_function`` compiler directive, it
|
||||||
|
modifies its internal grammar to interpert :func:`print` as a function. This
|
||||||
|
change can also be enabled manually with the :option:`-p` flag. Use
|
||||||
|
:option:`-p` to run fixers on code that already has had its print statements
|
||||||
|
converted.
|
||||||
|
|
||||||
|
|
||||||
.. _2to3-fixers:
|
.. _2to3-fixers:
|
||||||
|
|
||||||
|
|
|
@ -62,14 +62,22 @@ The :mod:`bdb` module also defines two classes:
|
||||||
* The breakpoint hit count.
|
* The breakpoint hit count.
|
||||||
|
|
||||||
|
|
||||||
.. class:: Bdb()
|
.. class:: Bdb(skip=None)
|
||||||
|
|
||||||
The :class:`Bdb` acts as a generic Python debugger base class.
|
The :class:`Bdb` class acts as a generic Python debugger base class.
|
||||||
|
|
||||||
This class takes care of the details of the trace facility; a derived class
|
This class takes care of the details of the trace facility; a derived class
|
||||||
should implement user interaction. The standard debugger class
|
should implement user interaction. The standard debugger class
|
||||||
(:class:`pdb.Pdb`) is an example.
|
(:class:`pdb.Pdb`) is an example.
|
||||||
|
|
||||||
|
The *skip* argument, if given, must be an iterable of glob-style
|
||||||
|
module name patterns. The debugger will not step into frames that
|
||||||
|
originate in a module that matches one of these patterns. Whether a
|
||||||
|
frame is considered to originate in a certain module is determined
|
||||||
|
by the ``__name__`` in the frame globals.
|
||||||
|
|
||||||
|
.. versionadded:: 2.7
|
||||||
|
The *skip* argument.
|
||||||
|
|
||||||
The following methods of :class:`Bdb` normally don't need to be overridden.
|
The following methods of :class:`Bdb` normally don't need to be overridden.
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,8 @@ Module Interface
|
||||||
|
|
||||||
*buffering* is an optional integer used to set the buffering policy. By
|
*buffering* is an optional integer used to set the buffering policy. By
|
||||||
default full buffering is on. Pass 0 to switch buffering off (only allowed
|
default full buffering is on. Pass 0 to switch buffering off (only allowed
|
||||||
in binary mode), 1 to set line buffering, and an integer > 1 for full
|
in binary mode), 1 to set line buffering, and an integer > 1 to indicate the
|
||||||
buffering.
|
size of the buffer.
|
||||||
|
|
||||||
*encoding* is the name of the encoding used to decode or encode the file.
|
*encoding* is the name of the encoding used to decode or encode the file.
|
||||||
This should only be used in text mode. The default encoding is platform
|
This should only be used in text mode. The default encoding is platform
|
||||||
|
|
|
@ -104,6 +104,14 @@ The mathematical and bitwise operations are the most numerous:
|
||||||
Return ``a // b``.
|
Return ``a // b``.
|
||||||
|
|
||||||
|
|
||||||
|
.. function:: index(a)
|
||||||
|
__index__(a)
|
||||||
|
|
||||||
|
Return *a* converted to an integer. Equivalent to ``a.__index__()``.
|
||||||
|
|
||||||
|
.. versionadded:: 2.5
|
||||||
|
|
||||||
|
|
||||||
.. function:: inv(obj)
|
.. function:: inv(obj)
|
||||||
invert(obj)
|
invert(obj)
|
||||||
__inv__(obj)
|
__inv__(obj)
|
||||||
|
@ -133,7 +141,7 @@ The mathematical and bitwise operations are the most numerous:
|
||||||
.. function:: neg(obj)
|
.. function:: neg(obj)
|
||||||
__neg__(obj)
|
__neg__(obj)
|
||||||
|
|
||||||
Return *obj* negated.
|
Return *obj* negated (``-obj``).
|
||||||
|
|
||||||
|
|
||||||
.. function:: or_(a, b)
|
.. function:: or_(a, b)
|
||||||
|
@ -145,7 +153,7 @@ The mathematical and bitwise operations are the most numerous:
|
||||||
.. function:: pos(obj)
|
.. function:: pos(obj)
|
||||||
__pos__(obj)
|
__pos__(obj)
|
||||||
|
|
||||||
Return *obj* positive.
|
Return *obj* positive (``+obj``).
|
||||||
|
|
||||||
|
|
||||||
.. function:: pow(a, b)
|
.. function:: pow(a, b)
|
||||||
|
@ -179,13 +187,7 @@ The mathematical and bitwise operations are the most numerous:
|
||||||
Return the bitwise exclusive or of *a* and *b*.
|
Return the bitwise exclusive or of *a* and *b*.
|
||||||
|
|
||||||
|
|
||||||
.. function:: index(a)
|
Operations which work with sequences (some of them with mappings too) include:
|
||||||
__index__(a)
|
|
||||||
|
|
||||||
Return *a* converted to an integer. Equivalent to ``a.__index__()``.
|
|
||||||
|
|
||||||
|
|
||||||
Operations which work with sequences include:
|
|
||||||
|
|
||||||
.. function:: concat(a, b)
|
.. function:: concat(a, b)
|
||||||
__concat__(a, b)
|
__concat__(a, b)
|
||||||
|
@ -394,67 +396,77 @@ Mapping Operators to Functions
|
||||||
This table shows how abstract operations correspond to operator symbols in the
|
This table shows how abstract operations correspond to operator symbols in the
|
||||||
Python syntax and the functions in the :mod:`operator` module.
|
Python syntax and the functions in the :mod:`operator` module.
|
||||||
|
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Operation | Syntax | Function |
|
| Operation | Syntax | Function |
|
||||||
+=======================+=========================+=================================+
|
+=======================+=========================+=======================================+
|
||||||
| Addition | ``a + b`` | ``add(a, b)`` |
|
| Addition | ``a + b`` | ``add(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Concatenation | ``seq1 + seq2`` | ``concat(seq1, seq2)`` |
|
| Concatenation | ``seq1 + seq2`` | ``concat(seq1, seq2)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Containment Test | ``obj in seq`` | ``contains(seq, obj)`` |
|
| Containment Test | ``obj in seq`` | ``contains(seq, obj)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Division | ``a / b`` | ``truediv(a, b)`` |
|
| Division | ``a / b`` | ``div(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Division | ``a // b`` | ``floordiv(a, b)`` |
|
| Division | ``a // b`` | ``floordiv(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Bitwise And | ``a & b`` | ``and_(a, b)`` |
|
| Bitwise And | ``a & b`` | ``and_(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Bitwise Exclusive Or | ``a ^ b`` | ``xor(a, b)`` |
|
| Bitwise Exclusive Or | ``a ^ b`` | ``xor(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Bitwise Inversion | ``~ a`` | ``invert(a)`` |
|
| Bitwise Inversion | ``~ a`` | ``invert(a)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Bitwise Or | ``a | b`` | ``or_(a, b)`` |
|
| Bitwise Or | ``a | b`` | ``or_(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Exponentiation | ``a ** b`` | ``pow(a, b)`` |
|
| Exponentiation | ``a ** b`` | ``pow(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Identity | ``a is b`` | ``is_(a, b)`` |
|
| Identity | ``a is b`` | ``is_(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Identity | ``a is not b`` | ``is_not(a, b)`` |
|
| Identity | ``a is not b`` | ``is_not(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Indexed Assignment | ``obj[k] = v`` | ``setitem(obj, k, v)`` |
|
| Indexed Assignment | ``obj[k] = v`` | ``setitem(obj, k, v)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Indexed Deletion | ``del obj[k]`` | ``delitem(obj, k)`` |
|
| Indexed Deletion | ``del obj[k]`` | ``delitem(obj, k)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Indexing | ``obj[k]`` | ``getitem(obj, k)`` |
|
| Indexing | ``obj[k]`` | ``getitem(obj, k)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Left Shift | ``a << b`` | ``lshift(a, b)`` |
|
| Left Shift | ``a << b`` | ``lshift(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Modulo | ``a % b`` | ``mod(a, b)`` |
|
| Modulo | ``a % b`` | ``mod(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Multiplication | ``a * b`` | ``mul(a, b)`` |
|
| Multiplication | ``a * b`` | ``mul(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Negation (Arithmetic) | ``- a`` | ``neg(a)`` |
|
| Negation (Arithmetic) | ``- a`` | ``neg(a)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Negation (Logical) | ``not a`` | ``not_(a)`` |
|
| Negation (Logical) | ``not a`` | ``not_(a)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
|
| Positive | ``+ a`` | ``pos(a)`` |
|
||||||
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Right Shift | ``a >> b`` | ``rshift(a, b)`` |
|
| Right Shift | ``a >> b`` | ``rshift(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
|
| Sequence Repetition | ``seq * i`` | ``repeat(seq, i)`` |
|
||||||
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
|
| Slice Assignment | ``seq[i:j] = values`` | ``setitem(seq, slice(i, j), values)`` |
|
||||||
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
|
| Slice Deletion | ``del seq[i:j]`` | ``delitem(seq, slice(i, j))`` |
|
||||||
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
|
| Slicing | ``seq[i:j]`` | ``getitem(seq, slice(i, j))`` |
|
||||||
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| String Formatting | ``s % obj`` | ``mod(s, obj)`` |
|
| String Formatting | ``s % obj`` | ``mod(s, obj)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Subtraction | ``a - b`` | ``sub(a, b)`` |
|
| Subtraction | ``a - b`` | ``sub(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Truth Test | ``obj`` | ``truth(obj)`` |
|
| Truth Test | ``obj`` | ``truth(obj)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Ordering | ``a < b`` | ``lt(a, b)`` |
|
| Ordering | ``a < b`` | ``lt(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Ordering | ``a <= b`` | ``le(a, b)`` |
|
| Ordering | ``a <= b`` | ``le(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Equality | ``a == b`` | ``eq(a, b)`` |
|
| Equality | ``a == b`` | ``eq(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Difference | ``a != b`` | ``ne(a, b)`` |
|
| Difference | ``a != b`` | ``ne(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Ordering | ``a >= b`` | ``ge(a, b)`` |
|
| Ordering | ``a >= b`` | ``ge(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
| Ordering | ``a > b`` | ``gt(a, b)`` |
|
| Ordering | ``a > b`` | ``gt(a, b)`` |
|
||||||
+-----------------------+-------------------------+---------------------------------+
|
+-----------------------+-------------------------+---------------------------------------+
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ insert ::
|
||||||
import pdb; pdb.set_trace()
|
import pdb; pdb.set_trace()
|
||||||
|
|
||||||
at the location you want to break into the debugger. You can then step through
|
at the location you want to break into the debugger. You can then step through
|
||||||
the code following this statement, and continue running without debugger using
|
the code following this statement, and continue running without the debugger using
|
||||||
the ``c`` command.
|
the ``c`` command.
|
||||||
|
|
||||||
The typical usage to inspect a crashed program is::
|
The typical usage to inspect a crashed program is::
|
||||||
|
|
|
@ -6,6 +6,8 @@ The Python Profilers
|
||||||
|
|
||||||
.. sectionauthor:: James Roskind
|
.. sectionauthor:: James Roskind
|
||||||
|
|
||||||
|
.. module:: profile
|
||||||
|
:synopsis: Python source profiler.
|
||||||
|
|
||||||
.. index:: single: InfoSeek Corporation
|
.. index:: single: InfoSeek Corporation
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
========================================
|
========================================
|
||||||
|
|
||||||
.. module:: pty
|
.. module:: pty
|
||||||
:platform: IRIX, Linux
|
:platform: Linux
|
||||||
:synopsis: Pseudo-Terminal Handling for SGI and Linux.
|
:synopsis: Pseudo-Terminal Handling for Linux.
|
||||||
.. moduleauthor:: Steen Lumholt
|
.. moduleauthor:: Steen Lumholt
|
||||||
.. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
|
.. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ concept: starting another process and being able to write to and read from its
|
||||||
controlling terminal programmatically.
|
controlling terminal programmatically.
|
||||||
|
|
||||||
Because pseudo-terminal handling is highly platform dependent, there is code to
|
Because pseudo-terminal handling is highly platform dependent, there is code to
|
||||||
do it only for SGI and Linux. (The Linux code is supposed to work on other
|
do it only for Linux. (The Linux code is supposed to work on other platforms,
|
||||||
platforms, but hasn't been tested yet.)
|
but hasn't been tested yet.)
|
||||||
|
|
||||||
The :mod:`pty` module defines the following functions:
|
The :mod:`pty` module defines the following functions:
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ The :mod:`pty` module defines the following functions:
|
||||||
.. function:: openpty()
|
.. function:: openpty()
|
||||||
|
|
||||||
Open a new pseudo-terminal pair, using :func:`os.openpty` if possible, or
|
Open a new pseudo-terminal pair, using :func:`os.openpty` if possible, or
|
||||||
emulation code for SGI and generic Unix systems. Return a pair of file
|
emulation code for generic Unix systems. Return a pair of file descriptors
|
||||||
descriptors ``(master, slave)``, for the master and the slave end, respectively.
|
``(master, slave)``, for the master and the slave end, respectively.
|
||||||
|
|
||||||
|
|
||||||
.. function:: spawn(argv[, master_read[, stdin_read]])
|
.. function:: spawn(argv[, master_read[, stdin_read]])
|
||||||
|
|
|
@ -365,7 +365,7 @@ object, see :ref:`tarinfo-objects` for details.
|
||||||
value. Depending on this value the respective file is either excluded
|
value. Depending on this value the respective file is either excluded
|
||||||
(:const:`True`) or added (:const:`False`). If *filter* is specified it must
|
(:const:`True`) or added (:const:`False`). If *filter* is specified it must
|
||||||
be a function that takes a :class:`TarInfo` object argument and returns the
|
be a function that takes a :class:`TarInfo` object argument and returns the
|
||||||
changed TarInfo object. If it instead returns :const:`None` the TarInfo
|
changed :class:`TarInfo` object. If it instead returns :const:`None` the :class:`TarInfo`
|
||||||
object will be excluded from the archive. See :ref:`tar-examples` for an
|
object will be excluded from the archive. See :ref:`tar-examples` for an
|
||||||
example.
|
example.
|
||||||
|
|
||||||
|
|
|
@ -2023,7 +2023,7 @@ The public classes of the module :mod:`turtle`
|
||||||
Subclass of TurtleScreen, with :ref:`four methods added <screenspecific>`.
|
Subclass of TurtleScreen, with :ref:`four methods added <screenspecific>`.
|
||||||
|
|
||||||
|
|
||||||
.. class:: ScrolledCavas(master)
|
.. class:: ScrolledCanvas(master)
|
||||||
|
|
||||||
:param master: some Tkinter widget to contain the ScrolledCanvas, i.e.
|
:param master: some Tkinter widget to contain the ScrolledCanvas, i.e.
|
||||||
a Tkinter-canvas with scrollbars added
|
a Tkinter-canvas with scrollbars added
|
||||||
|
|
|
@ -72,10 +72,9 @@ support weak references but can add support through subclassing::
|
||||||
|
|
||||||
obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable
|
obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable
|
||||||
|
|
||||||
.. impl-detail::
|
Other built-in types such as :class:`tuple` and :class:`long` do not support
|
||||||
|
weak references even when subclassed (This is an implementation detail and may
|
||||||
Other built-in types such as :class:`tuple` and :class:`long` do not support
|
be different across various Python implementations.).
|
||||||
weak references even when subclassed.
|
|
||||||
|
|
||||||
Extension types can easily be made to support weak references; see
|
Extension types can easily be made to support weak references; see
|
||||||
:ref:`weakref-support`.
|
:ref:`weakref-support`.
|
||||||
|
|
|
@ -197,6 +197,13 @@ ZipFile Objects
|
||||||
be a subset of the list returned by :meth:`namelist`. *pwd* is the password
|
be a subset of the list returned by :meth:`namelist`. *pwd* is the password
|
||||||
used for encrypted files.
|
used for encrypted files.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
Never extract archives from untrusted sources without prior inspection.
|
||||||
|
It is possible that files are created outside of *path*, e.g. members
|
||||||
|
that have absolute filenames starting with ``"/"`` or filenames with two
|
||||||
|
dots ``".."``.
|
||||||
|
|
||||||
|
|
||||||
.. method:: ZipFile.printdir()
|
.. method:: ZipFile.printdir()
|
||||||
|
|
||||||
|
|
|
@ -2416,9 +2416,13 @@ changes, or look through the Subversion logs for all the details.
|
||||||
environments. TIPC addresses are 4- or 5-tuples.
|
environments. TIPC addresses are 4- or 5-tuples.
|
||||||
(Contributed by Alberto Bertogli; :issue:`1646`.)
|
(Contributed by Alberto Bertogli; :issue:`1646`.)
|
||||||
|
|
||||||
A new function, :func:`create_connection`, takes an address
|
A new function, :func:`create_connection`, takes an address and
|
||||||
and connects to it using an optional timeout value, returning
|
connects to it using an optional timeout value, returning the
|
||||||
the connected socket object.
|
connected socket object. This function also looks up the address's
|
||||||
|
type and connects to it using IPv4 or IPv6 as appropriate. Changing
|
||||||
|
your code to use :func:`create_connection` instead of
|
||||||
|
``socket(socket.AF_INET, ...)`` may be all that's required to make
|
||||||
|
your code work with IPv6.
|
||||||
|
|
||||||
* The base classes in the :mod:`SocketServer` module now support
|
* The base classes in the :mod:`SocketServer` module now support
|
||||||
calling a :meth:`handle_timeout` method after a span of inactivity
|
calling a :meth:`handle_timeout` method after a span of inactivity
|
||||||
|
|
|
@ -92,7 +92,7 @@ class check(Command):
|
||||||
missing.append(attr)
|
missing.append(attr)
|
||||||
|
|
||||||
if missing:
|
if missing:
|
||||||
self.warn("missing required meta-data: %s" % ' ,'.join(missing))
|
self.warn("missing required meta-data: %s" % ', '.join(missing))
|
||||||
if metadata.author:
|
if metadata.author:
|
||||||
if not metadata.author_email:
|
if not metadata.author_email:
|
||||||
self.warn("missing meta-data: if 'author' supplied, " +
|
self.warn("missing meta-data: if 'author' supplied, " +
|
||||||
|
|
|
@ -238,7 +238,7 @@ def isroutine(object):
|
||||||
|
|
||||||
def isabstract(object):
|
def isabstract(object):
|
||||||
"""Return true if the object is an abstract base class (ABC)."""
|
"""Return true if the object is an abstract base class (ABC)."""
|
||||||
return isinstance(object, type) and object.__flags__ & TPFLAGS_IS_ABSTRACT
|
return bool(isinstance(object, type) and object.__flags__ & TPFLAGS_IS_ABSTRACT)
|
||||||
|
|
||||||
def getmembers(object, predicate=None):
|
def getmembers(object, predicate=None):
|
||||||
"""Return all members of an object as (name, value) pairs sorted by name.
|
"""Return all members of an object as (name, value) pairs sorted by name.
|
||||||
|
|
|
@ -193,6 +193,14 @@ if sys.platform == 'darwin':
|
||||||
newsoft = min(hard, max(soft, 1024*2048))
|
newsoft = min(hard, max(soft, 1024*2048))
|
||||||
resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
|
resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
|
||||||
|
|
||||||
|
# Test result constants.
|
||||||
|
PASSED = 1
|
||||||
|
FAILED = 0
|
||||||
|
ENV_CHANGED = -1
|
||||||
|
SKIPPED = -2
|
||||||
|
RESOURCE_DENIED = -3
|
||||||
|
INTERRUPTED = -4
|
||||||
|
|
||||||
from test import support
|
from test import support
|
||||||
|
|
||||||
RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network',
|
RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network',
|
||||||
|
@ -352,7 +360,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
try:
|
try:
|
||||||
result = runtest(*args, **kwargs)
|
result = runtest(*args, **kwargs)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
result = -4, e.__class__.__name__
|
result = INTERRUPTED, e.__class__.__name__
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
print() # Force a newline (just in case)
|
print() # Force a newline (just in case)
|
||||||
print(json.dumps(result))
|
print(json.dumps(result))
|
||||||
|
@ -443,19 +451,18 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
def accumulate_result(test, result):
|
def accumulate_result(test, result):
|
||||||
ok, test_time = result
|
ok, test_time = result
|
||||||
test_times.append((test_time, test))
|
test_times.append((test_time, test))
|
||||||
if ok > 0:
|
if ok == PASSED:
|
||||||
good.append(test)
|
good.append(test)
|
||||||
return 'good'
|
elif ok == FAILED:
|
||||||
elif -2 < ok <= 0:
|
bad.append(test)
|
||||||
|
elif ok == ENV_CHANGED:
|
||||||
bad.append(test)
|
bad.append(test)
|
||||||
if ok == -1:
|
|
||||||
environment_changed.append(test)
|
environment_changed.append(test)
|
||||||
return 'bad'
|
elif ok == SKIPPED:
|
||||||
else:
|
skipped.append(test)
|
||||||
|
elif ok == RESOURCE_DENIED:
|
||||||
skipped.append(test)
|
skipped.append(test)
|
||||||
if ok == -3:
|
|
||||||
resource_denieds.append(test)
|
resource_denieds.append(test)
|
||||||
return 'skipped'
|
|
||||||
|
|
||||||
if use_mp:
|
if use_mp:
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
@ -511,7 +518,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
print(stdout)
|
print(stdout)
|
||||||
if stderr:
|
if stderr:
|
||||||
print(stderr, file=sys.stderr)
|
print(stderr, file=sys.stderr)
|
||||||
if result[0] == -4:
|
if result[0] == INTERRUPTED:
|
||||||
assert result[1] == 'KeyboardInterrupt'
|
assert result[1] == 'KeyboardInterrupt'
|
||||||
pending.clear()
|
pending.clear()
|
||||||
raise KeyboardInterrupt # What else?
|
raise KeyboardInterrupt # What else?
|
||||||
|
@ -532,8 +539,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
|
||||||
try:
|
try:
|
||||||
result = runtest(test, verbose, quiet,
|
result = runtest(test, verbose, quiet,
|
||||||
testdir, huntrleaks, debug)
|
testdir, huntrleaks, debug)
|
||||||
which = accumulate_result(test, result)
|
accumulate_result(test, result)
|
||||||
if verbose3 and which == 'bad':
|
if verbose3 and result[0] == FAILED:
|
||||||
print("Re-running test {} in verbose mode".format(test))
|
print("Re-running test {} in verbose mode".format(test))
|
||||||
runtest(test, True, quiet, testdir, huntrleaks, debug)
|
runtest(test, True, quiet, testdir, huntrleaks, debug)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -679,15 +686,14 @@ def runtest(test, verbose, quiet,
|
||||||
testdir -- test directory
|
testdir -- test directory
|
||||||
huntrleaks -- run multiple times to test for leaks; requires a debug
|
huntrleaks -- run multiple times to test for leaks; requires a debug
|
||||||
build; a triple corresponding to -R's three arguments
|
build; a triple corresponding to -R's three arguments
|
||||||
debug -- if true, print tracebacks for failed tests regardless of
|
|
||||||
verbose setting
|
Returns one of the test result constants:
|
||||||
Return:
|
INTERRUPTED KeyboardInterrupt when run under -j
|
||||||
-4 KeyboardInterrupt when run under -j
|
RESOURCE_DENIED test skipped because resource denied
|
||||||
-3 test skipped because resource denied
|
SKIPPED test skipped for some other reason
|
||||||
-2 test skipped for some other reason
|
ENV_CHANGED test failed because it changed the execution environment
|
||||||
-1 test failed because it changed the execution environment
|
FAILED test failed
|
||||||
0 test failed
|
PASSED test passed
|
||||||
1 test passed
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
support.verbose = verbose # Tell tests to be moderately quiet
|
support.verbose = verbose # Tell tests to be moderately quiet
|
||||||
|
@ -843,18 +849,18 @@ def runtest_inner(test, verbose, quiet,
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(test, "skipped --", msg)
|
print(test, "skipped --", msg)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
return -3, test_time
|
return RESOURCE_DENIED, test_time
|
||||||
except unittest.SkipTest as msg:
|
except unittest.SkipTest as msg:
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print(test, "skipped --", msg)
|
print(test, "skipped --", msg)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
return -2, test_time
|
return SKIPPED, test_time
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except support.TestFailed as msg:
|
except support.TestFailed as msg:
|
||||||
print("test", test, "failed --", msg)
|
print("test", test, "failed --", msg)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
return 0, test_time
|
return FAILED, test_time
|
||||||
except:
|
except:
|
||||||
type, value = sys.exc_info()[:2]
|
type, value = sys.exc_info()[:2]
|
||||||
print("test", test, "crashed --", str(type) + ":", value)
|
print("test", test, "crashed --", str(type) + ":", value)
|
||||||
|
@ -862,13 +868,13 @@ def runtest_inner(test, verbose, quiet,
|
||||||
if verbose or debug:
|
if verbose or debug:
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
return 0, test_time
|
return FAILED, test_time
|
||||||
else:
|
else:
|
||||||
if refleak:
|
if refleak:
|
||||||
return 0, test_time
|
return FAILED, test_time
|
||||||
if environment.changed:
|
if environment.changed:
|
||||||
return -1, test_time
|
return ENV_CHANGED, test_time
|
||||||
return 1, test_time
|
return PASSED, test_time
|
||||||
|
|
||||||
def cleanup_test_droppings(testname, verbose):
|
def cleanup_test_droppings(testname, verbose):
|
||||||
import shutil
|
import shutil
|
||||||
|
|
|
@ -154,6 +154,14 @@ class AST_Tests(unittest.TestCase):
|
||||||
im = ast.parse("from . import y").body[0]
|
im = ast.parse("from . import y").body[0]
|
||||||
self.assertIsNone(im.module)
|
self.assertIsNone(im.module)
|
||||||
|
|
||||||
|
def test_base_classes(self):
|
||||||
|
self.assertTrue(issubclass(ast.For, ast.stmt))
|
||||||
|
self.assertTrue(issubclass(ast.Name, ast.expr))
|
||||||
|
self.assertTrue(issubclass(ast.stmt, ast.AST))
|
||||||
|
self.assertTrue(issubclass(ast.expr, ast.AST))
|
||||||
|
self.assertTrue(issubclass(ast.comprehension, ast.AST))
|
||||||
|
self.assertTrue(issubclass(ast.Gt, ast.AST))
|
||||||
|
|
||||||
def test_nodeclasses(self):
|
def test_nodeclasses(self):
|
||||||
x = ast.BinOp(1, 2, 3, lineno=0)
|
x = ast.BinOp(1, 2, 3, lineno=0)
|
||||||
self.assertEquals(x.left, 1)
|
self.assertEquals(x.left, 1)
|
||||||
|
|
|
@ -120,6 +120,28 @@ class TestPredicates(IsTestBase):
|
||||||
self.assertTrue('a' in members)
|
self.assertTrue('a' in members)
|
||||||
self.assertTrue('b' not in members)
|
self.assertTrue('b' not in members)
|
||||||
|
|
||||||
|
def test_isabstract(self):
|
||||||
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
|
class AbstractClassExample(metaclass=ABCMeta):
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def foo(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class ClassExample(AbstractClassExample):
|
||||||
|
def foo(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
a = ClassExample()
|
||||||
|
|
||||||
|
# Test general behaviour.
|
||||||
|
self.assertTrue(inspect.isabstract(AbstractClassExample))
|
||||||
|
self.assertFalse(inspect.isabstract(ClassExample))
|
||||||
|
self.assertFalse(inspect.isabstract(a))
|
||||||
|
self.assertFalse(inspect.isabstract(int))
|
||||||
|
self.assertFalse(inspect.isabstract(5))
|
||||||
|
|
||||||
|
|
||||||
class TestInterpreterStack(IsTestBase):
|
class TestInterpreterStack(IsTestBase):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
|
@ -55,6 +55,14 @@ class ModuleTests(unittest.TestCase):
|
||||||
{"__name__": "foo", "__doc__": "foodoc", "bar": 42})
|
{"__name__": "foo", "__doc__": "foodoc", "bar": 42})
|
||||||
self.assertTrue(foo.__dict__ is d)
|
self.assertTrue(foo.__dict__ is d)
|
||||||
|
|
||||||
|
def test_dont_clear_dict(self):
|
||||||
|
# See issue 7140.
|
||||||
|
def f():
|
||||||
|
foo = ModuleType("foo")
|
||||||
|
foo.bar = 4
|
||||||
|
return foo
|
||||||
|
self.assertEqual(f().__dict__["bar"], 4)
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
run_unittest(ModuleTests)
|
run_unittest(ModuleTests)
|
||||||
|
|
||||||
|
|
|
@ -493,9 +493,9 @@ class CacheTests(unittest.TestCase):
|
||||||
_strptime._strptime_time("10", "%d")
|
_strptime._strptime_time("10", "%d")
|
||||||
_strptime._strptime_time("2005", "%Y")
|
_strptime._strptime_time("2005", "%Y")
|
||||||
_strptime._TimeRE_cache.locale_time.lang = "Ni"
|
_strptime._TimeRE_cache.locale_time.lang = "Ni"
|
||||||
original_time_re = id(_strptime._TimeRE_cache)
|
original_time_re = _strptime._TimeRE_cache
|
||||||
_strptime._strptime_time("10", "%d")
|
_strptime._strptime_time("10", "%d")
|
||||||
self.assertNotEqual(original_time_re, id(_strptime._TimeRE_cache))
|
self.assertIsNot(original_time_re, _strptime._TimeRE_cache)
|
||||||
self.assertEqual(len(_strptime._regex_cache), 1)
|
self.assertEqual(len(_strptime._regex_cache), 1)
|
||||||
|
|
||||||
def test_regex_cleanup(self):
|
def test_regex_cleanup(self):
|
||||||
|
@ -514,11 +514,10 @@ class CacheTests(unittest.TestCase):
|
||||||
def test_new_localetime(self):
|
def test_new_localetime(self):
|
||||||
# A new LocaleTime instance should be created when a new TimeRE object
|
# A new LocaleTime instance should be created when a new TimeRE object
|
||||||
# is created.
|
# is created.
|
||||||
locale_time_id = id(_strptime._TimeRE_cache.locale_time)
|
locale_time_id = _strptime._TimeRE_cache.locale_time
|
||||||
_strptime._TimeRE_cache.locale_time.lang = "Ni"
|
_strptime._TimeRE_cache.locale_time.lang = "Ni"
|
||||||
_strptime._strptime_time("10", "%d")
|
_strptime._strptime_time("10", "%d")
|
||||||
self.assertNotEqual(locale_time_id,
|
self.assertIsNot(locale_time_id, _strptime._TimeRE_cache.locale_time)
|
||||||
id(_strptime._TimeRE_cache.locale_time))
|
|
||||||
|
|
||||||
def test_TimeRE_recreation(self):
|
def test_TimeRE_recreation(self):
|
||||||
# The TimeRE instance should be recreated upon changing the locale.
|
# The TimeRE instance should be recreated upon changing the locale.
|
||||||
|
@ -530,15 +529,15 @@ class CacheTests(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
_strptime._strptime_time('10', '%d')
|
_strptime._strptime_time('10', '%d')
|
||||||
# Get id of current cache object.
|
# Get id of current cache object.
|
||||||
first_time_re_id = id(_strptime._TimeRE_cache)
|
first_time_re = _strptime._TimeRE_cache
|
||||||
try:
|
try:
|
||||||
# Change the locale and force a recreation of the cache.
|
# Change the locale and force a recreation of the cache.
|
||||||
locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8'))
|
locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8'))
|
||||||
_strptime._strptime_time('10', '%d')
|
_strptime._strptime_time('10', '%d')
|
||||||
# Get the new cache object's id.
|
# Get the new cache object's id.
|
||||||
second_time_re_id = id(_strptime._TimeRE_cache)
|
second_time_re = _strptime._TimeRE_cache
|
||||||
# They should not be equal.
|
# They should not be equal.
|
||||||
self.assertNotEqual(first_time_re_id, second_time_re_id)
|
self.assertIsNot(first_time_re, second_time_re)
|
||||||
# Possible test locale is not supported while initial locale is.
|
# Possible test locale is not supported while initial locale is.
|
||||||
# If this is the case just suppress the exception and fall-through
|
# If this is the case just suppress the exception and fall-through
|
||||||
# to the reseting to the original locale.
|
# to the reseting to the original locale.
|
||||||
|
|
|
@ -185,11 +185,13 @@ class ThreadTests(BaseTestCase):
|
||||||
except AsyncExc:
|
except AsyncExc:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
# This code is unreachable but it reflects the intent. If we wanted
|
||||||
|
# to be smarter the above loop wouldn't be infinite.
|
||||||
self.fail("AsyncExc not raised")
|
self.fail("AsyncExc not raised")
|
||||||
try:
|
try:
|
||||||
self.assertEqual(result, 1) # one thread state modified
|
self.assertEqual(result, 1) # one thread state modified
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
# The exception was raised to quickly for us to get the result.
|
# The exception was raised too quickly for us to get the result.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# `worker_started` is set by the thread when it's inside a try/except
|
# `worker_started` is set by the thread when it's inside a try/except
|
||||||
|
|
|
@ -531,6 +531,24 @@ pass the '-ucompiler' option to process the full directory.
|
||||||
... break
|
... break
|
||||||
... else: True
|
... else: True
|
||||||
True
|
True
|
||||||
|
|
||||||
|
Evil tabs
|
||||||
|
>>> dump_tokens("def f():\\n\\tif x\\n \\tpass")
|
||||||
|
ENCODING 'utf-8' (0, 0) (0, 0)
|
||||||
|
NAME 'def' (1, 0) (1, 3)
|
||||||
|
NAME 'f' (1, 4) (1, 5)
|
||||||
|
OP '(' (1, 5) (1, 6)
|
||||||
|
OP ')' (1, 6) (1, 7)
|
||||||
|
OP ':' (1, 7) (1, 8)
|
||||||
|
NEWLINE '\\n' (1, 8) (1, 9)
|
||||||
|
INDENT '\\t' (2, 0) (2, 1)
|
||||||
|
NAME 'if' (2, 1) (2, 3)
|
||||||
|
NAME 'x' (2, 4) (2, 5)
|
||||||
|
NEWLINE '\\n' (2, 5) (2, 6)
|
||||||
|
INDENT ' \\t' (3, 0) (3, 9)
|
||||||
|
NAME 'pass' (3, 9) (3, 13)
|
||||||
|
DEDENT '' (4, 0) (4, 0)
|
||||||
|
DEDENT '' (4, 0) (4, 0)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from test import support
|
from test import support
|
||||||
|
|
|
@ -23,15 +23,15 @@ __author__ = 'Ka-Ping Yee <ping@lfw.org>'
|
||||||
__credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
|
__credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
|
||||||
'Skip Montanaro, Raymond Hettinger, Trent Nelson, '
|
'Skip Montanaro, Raymond Hettinger, Trent Nelson, '
|
||||||
'Michael Foord')
|
'Michael Foord')
|
||||||
|
|
||||||
import re, string, sys
|
import re, string, sys
|
||||||
from token import *
|
from token import *
|
||||||
from codecs import lookup, BOM_UTF8
|
from codecs import lookup, BOM_UTF8
|
||||||
cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
|
cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
|
||||||
|
|
||||||
import token
|
import token
|
||||||
__all__ = [x for x in dir(token) if x[0] != '_'] + ["COMMENT", "tokenize",
|
__all__ = [x for x in dir(token) if not x.startswith("_")]
|
||||||
"detect_encoding", "NL", "untokenize", "ENCODING", "TokenInfo"]
|
__all__.extend(["COMMENT", "tokenize", "detect_encoding", "NL", "untokenize",
|
||||||
|
"ENCODING", "TokenInfo"])
|
||||||
del token
|
del token
|
||||||
|
|
||||||
COMMENT = N_TOKENS
|
COMMENT = N_TOKENS
|
||||||
|
@ -407,7 +407,7 @@ def _tokenize(readline, encoding):
|
||||||
|
|
||||||
if encoding is not None:
|
if encoding is not None:
|
||||||
line = line.decode(encoding)
|
line = line.decode(encoding)
|
||||||
lnum = lnum + 1
|
lnum += 1
|
||||||
pos, max = 0, len(line)
|
pos, max = 0, len(line)
|
||||||
|
|
||||||
if contstr: # continued string
|
if contstr: # continued string
|
||||||
|
@ -435,12 +435,17 @@ def _tokenize(readline, encoding):
|
||||||
if not line: break
|
if not line: break
|
||||||
column = 0
|
column = 0
|
||||||
while pos < max: # measure leading whitespace
|
while pos < max: # measure leading whitespace
|
||||||
if line[pos] == ' ': column = column + 1
|
if line[pos] == ' ':
|
||||||
elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize
|
column += 1
|
||||||
elif line[pos] == '\f': column = 0
|
elif line[pos] == '\t':
|
||||||
else: break
|
column = (column//tabsize + 1)*tabsize
|
||||||
pos = pos + 1
|
elif line[pos] == '\f':
|
||||||
if pos == max: break
|
column = 0
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
pos += 1
|
||||||
|
if pos == max:
|
||||||
|
break
|
||||||
|
|
||||||
if line[pos] in '#\r\n': # skip comments or blank lines
|
if line[pos] in '#\r\n': # skip comments or blank lines
|
||||||
if line[pos] == '#':
|
if line[pos] == '#':
|
||||||
|
@ -516,13 +521,15 @@ def _tokenize(readline, encoding):
|
||||||
elif initial == '\\': # continued stmt
|
elif initial == '\\': # continued stmt
|
||||||
continued = 1
|
continued = 1
|
||||||
else:
|
else:
|
||||||
if initial in '([{': parenlev = parenlev + 1
|
if initial in '([{':
|
||||||
elif initial in ')]}': parenlev = parenlev - 1
|
parenlev += 1
|
||||||
|
elif initial in ')]}':
|
||||||
|
parenlev -= 1
|
||||||
yield TokenInfo(OP, token, spos, epos, line)
|
yield TokenInfo(OP, token, spos, epos, line)
|
||||||
else:
|
else:
|
||||||
yield TokenInfo(ERRORTOKEN, line[pos],
|
yield TokenInfo(ERRORTOKEN, line[pos],
|
||||||
(lnum, pos), (lnum, pos+1), line)
|
(lnum, pos), (lnum, pos+1), line)
|
||||||
pos = pos + 1
|
pos += 1
|
||||||
|
|
||||||
for indent in indents[1:]: # pop remaining indent levels
|
for indent in indents[1:]: # pop remaining indent levels
|
||||||
yield TokenInfo(DEDENT, '', (lnum, 0), (lnum, 0), '')
|
yield TokenInfo(DEDENT, '', (lnum, 0), (lnum, 0), '')
|
||||||
|
|
|
@ -19,12 +19,6 @@ etree -- The ElementTree XML library. This is a subset of the full
|
||||||
|
|
||||||
__all__ = ["dom", "parsers", "sax", "etree"]
|
__all__ = ["dom", "parsers", "sax", "etree"]
|
||||||
|
|
||||||
# When being checked-out without options, this has the form
|
|
||||||
# "<dollar>Revision: x.y </dollar>"
|
|
||||||
# When exported using -kv, it is "x.y".
|
|
||||||
__version__ = "$Revision$".split()[-2:][0]
|
|
||||||
|
|
||||||
|
|
||||||
_MINIMUM_XMLPLUS_VERSION = (0, 8, 4)
|
_MINIMUM_XMLPLUS_VERSION = (0, 8, 4)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,7 @@ target platform. Forget about the posix module for now -- simply take
|
||||||
it out of the config.c file.
|
it out of the config.c file.
|
||||||
|
|
||||||
Bang on it until you get a >>> prompt. (You may have to disable the
|
Bang on it until you get a >>> prompt. (You may have to disable the
|
||||||
importing of "site.py" and "exceptions.py" by passing -X and -S
|
importing of "site.py" by passing the -S options.)
|
||||||
options.
|
|
||||||
|
|
||||||
Then bang on it until it executes very simple Python statements.
|
Then bang on it until it executes very simple Python statements.
|
||||||
|
|
||||||
|
|
|
@ -597,9 +597,6 @@ stringio_init(stringio *self, PyObject *args, PyObject *kwds)
|
||||||
Py_CLEAR(self->writenl);
|
Py_CLEAR(self->writenl);
|
||||||
Py_CLEAR(self->decoder);
|
Py_CLEAR(self->decoder);
|
||||||
|
|
||||||
assert((newline != NULL && newline_obj != Py_None) ||
|
|
||||||
(newline == NULL && newline_obj == Py_None));
|
|
||||||
|
|
||||||
assert((newline != NULL && newline_obj != Py_None) ||
|
assert((newline != NULL && newline_obj != Py_None) ||
|
||||||
(newline == NULL && newline_obj == Py_None));
|
(newline == NULL && newline_obj == Py_None));
|
||||||
|
|
||||||
|
|
|
@ -661,7 +661,7 @@ PyDoc_STRVAR(math_ceil_doc,
|
||||||
"This is the smallest integral value >= x.");
|
"This is the smallest integral value >= x.");
|
||||||
|
|
||||||
FUNC2(copysign, copysign,
|
FUNC2(copysign, copysign,
|
||||||
"copysign(x,y)\n\nReturn x with the sign of y.")
|
"copysign(x, y)\n\nReturn x with the sign of y.")
|
||||||
FUNC1(cos, cos, 0,
|
FUNC1(cos, cos, 0,
|
||||||
"cos(x)\n\nReturn the cosine of x (measured in radians).")
|
"cos(x)\n\nReturn the cosine of x (measured in radians).")
|
||||||
FUNC1(cosh, cosh, 1,
|
FUNC1(cosh, cosh, 1,
|
||||||
|
@ -695,8 +695,8 @@ PyDoc_STRVAR(math_floor_doc,
|
||||||
FUNC1A(gamma, m_tgamma,
|
FUNC1A(gamma, m_tgamma,
|
||||||
"gamma(x)\n\nGamma function at x.")
|
"gamma(x)\n\nGamma function at x.")
|
||||||
FUNC1(log1p, log1p, 1,
|
FUNC1(log1p, log1p, 1,
|
||||||
"log1p(x)\n\nReturn the natural logarithm of 1+x (base e).\n\
|
"log1p(x)\n\nReturn the natural logarithm of 1+x (base e).\n"
|
||||||
The result is computed in a way which is accurate for x near zero.")
|
"The result is computed in a way which is accurate for x near zero.")
|
||||||
FUNC1(sin, sin, 0,
|
FUNC1(sin, sin, 0,
|
||||||
"sin(x)\n\nReturn the sine of x (measured in radians).")
|
"sin(x)\n\nReturn the sine of x (measured in radians).")
|
||||||
FUNC1(sinh, sinh, 1,
|
FUNC1(sinh, sinh, 1,
|
||||||
|
@ -925,7 +925,7 @@ _fsum_error:
|
||||||
#undef NUM_PARTIALS
|
#undef NUM_PARTIALS
|
||||||
|
|
||||||
PyDoc_STRVAR(math_fsum_doc,
|
PyDoc_STRVAR(math_fsum_doc,
|
||||||
"sum(iterable)\n\n\
|
"fsum(iterable)\n\n\
|
||||||
Return an accurate floating point sum of values in the iterable.\n\
|
Return an accurate floating point sum of values in the iterable.\n\
|
||||||
Assumes IEEE-754 floating point arithmetic.");
|
Assumes IEEE-754 floating point arithmetic.");
|
||||||
|
|
||||||
|
@ -1101,7 +1101,8 @@ math_ldexp(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(math_ldexp_doc,
|
PyDoc_STRVAR(math_ldexp_doc,
|
||||||
"ldexp(x, i) -> x * (2**i)");
|
"ldexp(x, i)\n\n\
|
||||||
|
Return x * (2**i).");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
math_modf(PyObject *self, PyObject *arg)
|
math_modf(PyObject *self, PyObject *arg)
|
||||||
|
@ -1192,7 +1193,8 @@ math_log(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(math_log_doc,
|
PyDoc_STRVAR(math_log_doc,
|
||||||
"log(x[, base]) -> the logarithm of x to the given base.\n\
|
"log(x[, base])\n\n\
|
||||||
|
Return the logarithm of x to the given base.\n\
|
||||||
If the base not specified, returns the natural logarithm (base e) of x.");
|
If the base not specified, returns the natural logarithm (base e) of x.");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1202,7 +1204,7 @@ math_log10(PyObject *self, PyObject *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(math_log10_doc,
|
PyDoc_STRVAR(math_log10_doc,
|
||||||
"log10(x) -> the base 10 logarithm of x.");
|
"log10(x)\n\nReturn the base 10 logarithm of x.");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
math_fmod(PyObject *self, PyObject *args)
|
math_fmod(PyObject *self, PyObject *args)
|
||||||
|
@ -1235,7 +1237,7 @@ math_fmod(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(math_fmod_doc,
|
PyDoc_STRVAR(math_fmod_doc,
|
||||||
"fmod(x,y)\n\nReturn fmod(x, y), according to platform C."
|
"fmod(x, y)\n\nReturn fmod(x, y), according to platform C."
|
||||||
" x % y may differ.");
|
" x % y may differ.");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1277,7 +1279,7 @@ math_hypot(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(math_hypot_doc,
|
PyDoc_STRVAR(math_hypot_doc,
|
||||||
"hypot(x,y)\n\nReturn the Euclidean distance, sqrt(x*x + y*y).");
|
"hypot(x, y)\n\nReturn the Euclidean distance, sqrt(x*x + y*y).");
|
||||||
|
|
||||||
/* pow can't use math_2, but needs its own wrapper: the problem is
|
/* pow can't use math_2, but needs its own wrapper: the problem is
|
||||||
that an infinite result can arise either as a result of overflow
|
that an infinite result can arise either as a result of overflow
|
||||||
|
@ -1364,7 +1366,7 @@ math_pow(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(math_pow_doc,
|
PyDoc_STRVAR(math_pow_doc,
|
||||||
"pow(x,y)\n\nReturn x**y (x to the power of y).");
|
"pow(x, y)\n\nReturn x**y (x to the power of y).");
|
||||||
|
|
||||||
static const double degToRad = Py_MATH_PI / 180.0;
|
static const double degToRad = Py_MATH_PI / 180.0;
|
||||||
static const double radToDeg = 180.0 / Py_MATH_PI;
|
static const double radToDeg = 180.0 / Py_MATH_PI;
|
||||||
|
@ -1379,7 +1381,8 @@ math_degrees(PyObject *self, PyObject *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(math_degrees_doc,
|
PyDoc_STRVAR(math_degrees_doc,
|
||||||
"degrees(x) -> converts angle x from radians to degrees");
|
"degrees(x)\n\n\
|
||||||
|
Convert angle x from radians to degrees.");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
math_radians(PyObject *self, PyObject *arg)
|
math_radians(PyObject *self, PyObject *arg)
|
||||||
|
@ -1391,7 +1394,8 @@ math_radians(PyObject *self, PyObject *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(math_radians_doc,
|
PyDoc_STRVAR(math_radians_doc,
|
||||||
"radians(x) -> converts angle x from degrees to radians");
|
"radians(x)\n\n\
|
||||||
|
Convert angle x from degrees to radians.");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
math_isnan(PyObject *self, PyObject *arg)
|
math_isnan(PyObject *self, PyObject *arg)
|
||||||
|
@ -1403,8 +1407,8 @@ math_isnan(PyObject *self, PyObject *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(math_isnan_doc,
|
PyDoc_STRVAR(math_isnan_doc,
|
||||||
"isnan(x) -> bool\n\
|
"isnan(x) -> bool\n\n\
|
||||||
Checks if float x is not a number (NaN)");
|
Check if float x is not a number (NaN).");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
math_isinf(PyObject *self, PyObject *arg)
|
math_isinf(PyObject *self, PyObject *arg)
|
||||||
|
@ -1416,8 +1420,8 @@ math_isinf(PyObject *self, PyObject *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(math_isinf_doc,
|
PyDoc_STRVAR(math_isinf_doc,
|
||||||
"isinf(x) -> bool\n\
|
"isinf(x) -> bool\n\n\
|
||||||
Checks if float x is infinite (positive or negative)");
|
Check if float x is infinite (positive or negative).");
|
||||||
|
|
||||||
static PyMethodDef math_methods[] = {
|
static PyMethodDef math_methods[] = {
|
||||||
{"acos", math_acos, METH_O, math_acos_doc},
|
{"acos", math_acos, METH_O, math_acos_doc},
|
||||||
|
|
|
@ -7,7 +7,7 @@ PyDoc_STRVAR(operator_doc,
|
||||||
This module exports a set of functions implemented in C corresponding\n\
|
This module exports a set of functions implemented in C corresponding\n\
|
||||||
to the intrinsic operators of Python. For example, operator.add(x, y)\n\
|
to the intrinsic operators of Python. For example, operator.add(x, y)\n\
|
||||||
is equivalent to the expression x+y. The function names are those\n\
|
is equivalent to the expression x+y. The function names are those\n\
|
||||||
used for special class methods; variants without leading and trailing\n\
|
used for special methods; variants without leading and trailing\n\
|
||||||
'__' are also provided for convenience.");
|
'__' are also provided for convenience.");
|
||||||
|
|
||||||
#define spam1(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a1) { \
|
#define spam1(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a1) { \
|
||||||
|
@ -197,21 +197,21 @@ spam2o(not_,__not__, "not_(a) -- Same as not a.")
|
||||||
spam2(and_,__and__, "and_(a, b) -- Same as a & b.")
|
spam2(and_,__and__, "and_(a, b) -- Same as a & b.")
|
||||||
spam2(xor,__xor__, "xor(a, b) -- Same as a ^ b.")
|
spam2(xor,__xor__, "xor(a, b) -- Same as a ^ b.")
|
||||||
spam2(or_,__or__, "or_(a, b) -- Same as a | b.")
|
spam2(or_,__or__, "or_(a, b) -- Same as a | b.")
|
||||||
spam2(iadd,__iadd__, "iadd(a, b) -- Same as a += b.")
|
spam2(iadd,__iadd__, "a = iadd(a, b) -- Same as a += b.")
|
||||||
spam2(isub,__isub__, "isub(a, b) -- Same as a -= b.")
|
spam2(isub,__isub__, "a = isub(a, b) -- Same as a -= b.")
|
||||||
spam2(imul,__imul__, "imul(a, b) -- Same as a *= b.")
|
spam2(imul,__imul__, "a = imul(a, b) -- Same as a *= b.")
|
||||||
spam2(ifloordiv,__ifloordiv__, "ifloordiv(a, b) -- Same as a //= b.")
|
spam2(ifloordiv,__ifloordiv__, "a = ifloordiv(a, b) -- Same as a //= b.")
|
||||||
spam2(itruediv,__itruediv__, "itruediv(a, b) -- Same as a /= b.")
|
spam2(itruediv,__itruediv__, "a = itruediv(a, b) -- Same as a /= b")
|
||||||
spam2(imod,__imod__, "imod(a, b) -- Same as a %= b.")
|
spam2(imod,__imod__, "a = imod(a, b) -- Same as a %= b.")
|
||||||
spam2(ilshift,__ilshift__, "ilshift(a, b) -- Same as a <<= b.")
|
spam2(ilshift,__ilshift__, "a = ilshift(a, b) -- Same as a <<= b.")
|
||||||
spam2(irshift,__irshift__, "irshift(a, b) -- Same as a >>= b.")
|
spam2(irshift,__irshift__, "a = irshift(a, b) -- Same as a >>= b.")
|
||||||
spam2(iand,__iand__, "iand(a, b) -- Same as a &= b.")
|
spam2(iand,__iand__, "a = iand(a, b) -- Same as a &= b.")
|
||||||
spam2(ixor,__ixor__, "ixor(a, b) -- Same as a ^= b.")
|
spam2(ixor,__ixor__, "a = ixor(a, b) -- Same as a ^= b.")
|
||||||
spam2(ior,__ior__, "ior(a, b) -- Same as a |= b.")
|
spam2(ior,__ior__, "a = ior(a, b) -- Same as a |= b.")
|
||||||
spam2(concat,__concat__,
|
spam2(concat,__concat__,
|
||||||
"concat(a, b) -- Same as a + b, for a and b sequences.")
|
"concat(a, b) -- Same as a + b, for a and b sequences.")
|
||||||
spam2(iconcat,__iconcat__,
|
spam2(iconcat,__iconcat__,
|
||||||
"iconcat(a, b) -- Same as a += b, for a and b sequences.")
|
"a = iconcat(a, b) -- Same as a += b, for a and b sequences.")
|
||||||
spam2(getitem,__getitem__,
|
spam2(getitem,__getitem__,
|
||||||
"getitem(a, b) -- Same as a[b].")
|
"getitem(a, b) -- Same as a[b].")
|
||||||
spam2(setitem,__setitem__,
|
spam2(setitem,__setitem__,
|
||||||
|
@ -219,7 +219,7 @@ spam2(setitem,__setitem__,
|
||||||
spam2(delitem,__delitem__,
|
spam2(delitem,__delitem__,
|
||||||
"delitem(a, b) -- Same as del a[b].")
|
"delitem(a, b) -- Same as del a[b].")
|
||||||
spam2(pow,__pow__, "pow(a, b) -- Same as a ** b.")
|
spam2(pow,__pow__, "pow(a, b) -- Same as a ** b.")
|
||||||
spam2(ipow,__ipow__, "ipow(a, b) -- Same as a **= b.")
|
spam2(ipow,__ipow__, "a = ipow(a, b) -- Same as a **= b.")
|
||||||
spam2(lt,__lt__, "lt(a, b) -- Same as a<b.")
|
spam2(lt,__lt__, "lt(a, b) -- Same as a<b.")
|
||||||
spam2(le,__le__, "le(a, b) -- Same as a<=b.")
|
spam2(le,__le__, "le(a, b) -- Same as a<=b.")
|
||||||
spam2(eq,__eq__, "eq(a, b) -- Same as a==b.")
|
spam2(eq,__eq__, "eq(a, b) -- Same as a==b.")
|
||||||
|
|
|
@ -1293,26 +1293,29 @@ property_init(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
/* if no docstring given and the getter has one, use that one */
|
/* if no docstring given and the getter has one, use that one */
|
||||||
if ((doc == NULL || doc == Py_None) && get != NULL) {
|
if ((doc == NULL || doc == Py_None) && get != NULL) {
|
||||||
PyObject *get_doc = PyObject_GetAttrString(get, "__doc__");
|
PyObject *get_doc = PyObject_GetAttrString(get, "__doc__");
|
||||||
if (get_doc != NULL) {
|
if (get_doc) {
|
||||||
/* get_doc already INCREF'd by GetAttr */
|
if (Py_TYPE(self) == &PyProperty_Type) {
|
||||||
if (Py_TYPE(self)==&PyProperty_Type) {
|
|
||||||
Py_XDECREF(prop->prop_doc);
|
Py_XDECREF(prop->prop_doc);
|
||||||
prop->prop_doc = get_doc;
|
prop->prop_doc = get_doc;
|
||||||
} else {
|
}
|
||||||
/* Put __doc__ in dict of the subclass instance instead,
|
else {
|
||||||
otherwise it gets shadowed by class's __doc__. */
|
/* If this is a property subclass, put __doc__
|
||||||
if (PyObject_SetAttrString(self, "__doc__", get_doc) != 0)
|
in dict of the subclass instance instead,
|
||||||
{
|
otherwise it gets shadowed by __doc__ in the
|
||||||
/* DECREF for props handled by _dealloc */
|
class's dict. */
|
||||||
|
int err = PyObject_SetAttrString(self, "__doc__", get_doc);
|
||||||
Py_DECREF(get_doc);
|
Py_DECREF(get_doc);
|
||||||
|
if (err < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Py_DECREF(get_doc);
|
|
||||||
}
|
|
||||||
prop->getter_doc = 1;
|
prop->getter_doc = 1;
|
||||||
} else {
|
}
|
||||||
|
else if (PyErr_ExceptionMatches(PyExc_Exception)) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -183,9 +183,12 @@ PyList_GetItem(PyObject *op, Py_ssize_t i)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (i < 0 || i >= Py_SIZE(op)) {
|
if (i < 0 || i >= Py_SIZE(op)) {
|
||||||
if (indexerr == NULL)
|
if (indexerr == NULL) {
|
||||||
indexerr = PyUnicode_FromString(
|
indexerr = PyUnicode_FromString(
|
||||||
"list index out of range");
|
"list index out of range");
|
||||||
|
if (indexerr == NULL)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
PyErr_SetObject(PyExc_IndexError, indexerr);
|
PyErr_SetObject(PyExc_IndexError, indexerr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -406,9 +409,12 @@ static PyObject *
|
||||||
list_item(PyListObject *a, Py_ssize_t i)
|
list_item(PyListObject *a, Py_ssize_t i)
|
||||||
{
|
{
|
||||||
if (i < 0 || i >= Py_SIZE(a)) {
|
if (i < 0 || i >= Py_SIZE(a)) {
|
||||||
if (indexerr == NULL)
|
if (indexerr == NULL) {
|
||||||
indexerr = PyUnicode_FromString(
|
indexerr = PyUnicode_FromString(
|
||||||
"list index out of range");
|
"list index out of range");
|
||||||
|
if (indexerr == NULL)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
PyErr_SetObject(PyExc_IndexError, indexerr);
|
PyErr_SetObject(PyExc_IndexError, indexerr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,6 +312,9 @@ module_dealloc(PyModuleObject *m)
|
||||||
if (m->md_def && m->md_def->m_free)
|
if (m->md_def && m->md_def->m_free)
|
||||||
m->md_def->m_free(m);
|
m->md_def->m_free(m);
|
||||||
if (m->md_dict != NULL) {
|
if (m->md_dict != NULL) {
|
||||||
|
/* If we are the only ones holding a reference, we can clear
|
||||||
|
the dictionary. */
|
||||||
|
if (Py_REFCNT(m->md_dict) == 1)
|
||||||
_PyModule_Clear((PyObject *)m);
|
_PyModule_Clear((PyObject *)m);
|
||||||
Py_DECREF(m->md_dict);
|
Py_DECREF(m->md_dict);
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,20 +197,26 @@ get_normal_name(char *s) /* for utf-8 and latin-1 */
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 12; i++) {
|
for (i = 0; i < 12; i++) {
|
||||||
int c = s[i];
|
int c = s[i];
|
||||||
if (c == '\0') break;
|
if (c == '\0')
|
||||||
else if (c == '_') buf[i] = '-';
|
break;
|
||||||
else buf[i] = tolower(c);
|
else if (c == '_')
|
||||||
|
buf[i] = '-';
|
||||||
|
else
|
||||||
|
buf[i] = tolower(c);
|
||||||
}
|
}
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
if (strcmp(buf, "utf-8") == 0 ||
|
if (strcmp(buf, "utf-8") == 0 ||
|
||||||
strncmp(buf, "utf-8-", 6) == 0) return "utf-8";
|
strncmp(buf, "utf-8-", 6) == 0)
|
||||||
|
return "utf-8";
|
||||||
else if (strcmp(buf, "latin-1") == 0 ||
|
else if (strcmp(buf, "latin-1") == 0 ||
|
||||||
strcmp(buf, "iso-8859-1") == 0 ||
|
strcmp(buf, "iso-8859-1") == 0 ||
|
||||||
strcmp(buf, "iso-latin-1") == 0 ||
|
strcmp(buf, "iso-latin-1") == 0 ||
|
||||||
strncmp(buf, "latin-1-", 8) == 0 ||
|
strncmp(buf, "latin-1-", 8) == 0 ||
|
||||||
strncmp(buf, "iso-8859-1-", 11) == 0 ||
|
strncmp(buf, "iso-8859-1-", 11) == 0 ||
|
||||||
strncmp(buf, "iso-latin-1-", 12) == 0) return "iso-8859-1";
|
strncmp(buf, "iso-latin-1-", 12) == 0)
|
||||||
else return s;
|
return "iso-8859-1";
|
||||||
|
else
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the coding spec in S, or NULL if none is found. */
|
/* Return the coding spec in S, or NULL if none is found. */
|
||||||
|
@ -336,12 +342,18 @@ check_bom(int get_char(struct tok_state *),
|
||||||
/* Disable support for UTF-16 BOMs until a decision
|
/* Disable support for UTF-16 BOMs until a decision
|
||||||
is made whether this needs to be supported. */
|
is made whether this needs to be supported. */
|
||||||
} else if (ch == 0xFE) {
|
} else if (ch == 0xFE) {
|
||||||
ch = get_char(tok); if (ch != 0xFF) goto NON_BOM;
|
ch = get_char(tok);
|
||||||
if (!set_readline(tok, "utf-16-be")) return 0;
|
if (ch != 0xFF)
|
||||||
|
goto NON_BOM;
|
||||||
|
if (!set_readline(tok, "utf-16-be"))
|
||||||
|
return 0;
|
||||||
tok->decoding_state = STATE_NORMAL;
|
tok->decoding_state = STATE_NORMAL;
|
||||||
} else if (ch == 0xFF) {
|
} else if (ch == 0xFF) {
|
||||||
ch = get_char(tok); if (ch != 0xFE) goto NON_BOM;
|
ch = get_char(tok);
|
||||||
if (!set_readline(tok, "utf-16-le")) return 0;
|
if (ch != 0xFE)
|
||||||
|
goto NON_BOM;
|
||||||
|
if (!set_readline(tok, "utf-16-le"))
|
||||||
|
return 0;
|
||||||
tok->decoding_state = STATE_NORMAL;
|
tok->decoding_state = STATE_NORMAL;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
@ -1036,7 +1048,7 @@ tok_backup(register struct tok_state *tok, register int c)
|
||||||
{
|
{
|
||||||
if (c != EOF) {
|
if (c != EOF) {
|
||||||
if (--tok->cur < tok->buf)
|
if (--tok->cur < tok->buf)
|
||||||
Py_FatalError("tok_backup: begin of buffer");
|
Py_FatalError("tok_backup: beginning of buffer");
|
||||||
if (*tok->cur != c)
|
if (*tok->cur != c)
|
||||||
*tok->cur = c;
|
*tok->cur = c;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue