Python-checkins
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
November 2010
- 16 participants
- 934 discussions
Author: georg.brandl
Date: Fri Nov 26 09:49:15 2010
New Revision: 86783
Log:
Merged revisions 85572-85573,85606,85609-85622,85624,85626-85627,85629,85631,85633,85635-85636,85638-85639,85641-85642 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r85572 | georg.brandl | 2010-10-16 20:51:05 +0200 (Sa, 16 Okt 2010) | 1 line
#10122: typo fix.
........
r85573 | georg.brandl | 2010-10-16 20:53:08 +0200 (Sa, 16 Okt 2010) | 1 line
#10124: typo fix.
........
r85606 | georg.brandl | 2010-10-17 08:32:59 +0200 (So, 17 Okt 2010) | 1 line
#10058: tweak wording about exception returns.
........
r85609 | georg.brandl | 2010-10-17 11:19:03 +0200 (So, 17 Okt 2010) | 1 line
#8556: use less confusing mapping key in example.
........
r85610 | georg.brandl | 2010-10-17 11:23:05 +0200 (So, 17 Okt 2010) | 1 line
#8686: remove potentially confusing wording that does not add any value.
........
r85611 | georg.brandl | 2010-10-17 11:33:24 +0200 (So, 17 Okt 2010) | 1 line
#8811: small fixes to sqlite3 docs.
........
r85612 | georg.brandl | 2010-10-17 11:37:54 +0200 (So, 17 Okt 2010) | 1 line
#8855: add shelve security warning.
........
r85613 | georg.brandl | 2010-10-17 11:43:35 +0200 (So, 17 Okt 2010) | 1 line
Fix hmac docs: it takes and returns bytes, except for hexdigest().
........
r85614 | georg.brandl | 2010-10-17 11:46:11 +0200 (So, 17 Okt 2010) | 1 line
#8968: add actual name of token constants.
........
r85615 | georg.brandl | 2010-10-17 12:05:13 +0200 (So, 17 Okt 2010) | 1 line
#459007: merge info from PC/getpathp.c and using/windows.rst to document the forming of sys.path under Windows.
........
r85616 | georg.brandl | 2010-10-17 12:07:29 +0200 (So, 17 Okt 2010) | 1 line
Fix copy-paste error in example.
........
r85617 | georg.brandl | 2010-10-17 12:09:06 +0200 (So, 17 Okt 2010) | 1 line
#5212: md5 weaknesses do not affect hmac, so remove the note about that.
........
r85618 | georg.brandl | 2010-10-17 12:14:38 +0200 (So, 17 Okt 2010) | 1 line
#9086: correct wrong terminology about linking with pythonXY.dll.
........
r85619 | georg.brandl | 2010-10-17 12:15:50 +0200 (So, 17 Okt 2010) | 1 line
Make file names consistent.
........
r85620 | georg.brandl | 2010-10-17 12:22:28 +0200 (So, 17 Okt 2010) | 1 line
Remove second parser module example; it referred to non-readily-available example files, and this kind of discovery is much better done with the AST nowadays anyway.
........
r85621 | georg.brandl | 2010-10-17 12:24:54 +0200 (So, 17 Okt 2010) | 1 line
#9105: move pickle warning to a bit more prominent location.
........
r85622 | georg.brandl | 2010-10-17 12:28:04 +0200 (So, 17 Okt 2010) | 1 line
#9112: document error() and exit() methods of ArgumentParser.
........
r85624 | georg.brandl | 2010-10-17 12:34:28 +0200 (So, 17 Okt 2010) | 1 line
Some markup and style fixes in argparse docs.
........
r85626 | georg.brandl | 2010-10-17 12:38:20 +0200 (So, 17 Okt 2010) | 1 line
#9117: fix syntax for class definition.
........
r85627 | georg.brandl | 2010-10-17 12:44:11 +0200 (So, 17 Okt 2010) | 1 line
#9138: reword introduction to classes in Python.
........
r85629 | georg.brandl | 2010-10-17 12:51:45 +0200 (So, 17 Okt 2010) | 1 line
#5962: clarify sys.exit() vs. threads.
........
r85631 | georg.brandl | 2010-10-17 12:53:54 +0200 (So, 17 Okt 2010) | 1 line
Fix capitalization.
........
r85633 | georg.brandl | 2010-10-17 12:59:41 +0200 (So, 17 Okt 2010) | 1 line
#9204: remove mentions of removed types in the types module.
........
r85635 | georg.brandl | 2010-10-17 13:03:22 +0200 (So, 17 Okt 2010) | 1 line
#5121: fix claims about default values leading to segfaults.
........
r85636 | georg.brandl | 2010-10-17 13:06:14 +0200 (So, 17 Okt 2010) | 1 line
#9237: document sys.call_tracing().
........
r85638 | georg.brandl | 2010-10-17 13:13:37 +0200 (So, 17 Okt 2010) | 1 line
Port changes to pickle docs apparently lost in py3k.
........
r85639 | georg.brandl | 2010-10-17 13:23:56 +0200 (So, 17 Okt 2010) | 1 line
Make twisted example a bit more logical.
........
r85641 | georg.brandl | 2010-10-17 13:29:07 +0200 (So, 17 Okt 2010) | 1 line
Fix documentation of dis.opmap direction.
........
r85642 | georg.brandl | 2010-10-17 13:36:28 +0200 (So, 17 Okt 2010) | 1 line
#9730: fix example.
........
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Doc/c-api/bytearray.rst
python/branches/release31-maint/Doc/c-api/bytes.rst
python/branches/release31-maint/Doc/c-api/complex.rst
python/branches/release31-maint/Doc/c-api/dict.rst
python/branches/release31-maint/Doc/c-api/float.rst
python/branches/release31-maint/Doc/c-api/intro.rst
python/branches/release31-maint/Doc/c-api/list.rst
python/branches/release31-maint/Doc/c-api/long.rst
python/branches/release31-maint/Doc/c-api/slice.rst
python/branches/release31-maint/Doc/c-api/tuple.rst
python/branches/release31-maint/Doc/c-api/type.rst
python/branches/release31-maint/Doc/c-api/unicode.rst
python/branches/release31-maint/Doc/c-api/veryhigh.rst
python/branches/release31-maint/Doc/faq/windows.rst
python/branches/release31-maint/Doc/howto/cporting.rst
python/branches/release31-maint/Doc/library/audioop.rst
python/branches/release31-maint/Doc/library/base64.rst
python/branches/release31-maint/Doc/library/difflib.rst
python/branches/release31-maint/Doc/library/dis.rst
python/branches/release31-maint/Doc/library/functions.rst
python/branches/release31-maint/Doc/library/hmac.rst
python/branches/release31-maint/Doc/library/os.rst
python/branches/release31-maint/Doc/library/parser.rst
python/branches/release31-maint/Doc/library/pickle.rst
python/branches/release31-maint/Doc/library/shelve.rst
python/branches/release31-maint/Doc/library/sqlite3.rst
python/branches/release31-maint/Doc/library/stdtypes.rst
python/branches/release31-maint/Doc/library/sys.rst
python/branches/release31-maint/Doc/library/token.rst
python/branches/release31-maint/Doc/reference/compound_stmts.rst
python/branches/release31-maint/Doc/tutorial/classes.rst
python/branches/release31-maint/Doc/using/windows.rst
Modified: python/branches/release31-maint/Doc/c-api/bytearray.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/bytearray.rst (original)
+++ python/branches/release31-maint/Doc/c-api/bytearray.rst Fri Nov 26 09:49:15 2010
@@ -16,7 +16,8 @@
.. cvar:: PyTypeObject PyByteArray_Type
This instance of :ctype:`PyTypeObject` represents the Python bytearray type;
- it is the same object as ``bytearray`` in the Python layer.
+ it is the same object as :class:`bytearray` in the Python layer.
+
Type check macros
^^^^^^^^^^^^^^^^^
Modified: python/branches/release31-maint/Doc/c-api/bytes.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/bytes.rst (original)
+++ python/branches/release31-maint/Doc/c-api/bytes.rst Fri Nov 26 09:49:15 2010
@@ -18,10 +18,8 @@
.. cvar:: PyTypeObject PyBytes_Type
- .. index:: single: BytesType (in module types)
-
This instance of :ctype:`PyTypeObject` represents the Python bytes type; it
- is the same object as ``bytes`` in the Python layer. .
+ is the same object as :class:`bytes` in the Python layer.
.. cfunction:: int PyBytes_Check(PyObject *o)
Modified: python/branches/release31-maint/Doc/c-api/complex.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/complex.rst (original)
+++ python/branches/release31-maint/Doc/c-api/complex.rst Fri Nov 26 09:49:15 2010
@@ -82,7 +82,7 @@
.. cvar:: PyTypeObject PyComplex_Type
This instance of :ctype:`PyTypeObject` represents the Python complex number
- type. It is the same object as ``complex`` and ``types.ComplexType``.
+ type. It is the same object as :class:`complex` in the Python layer.
.. cfunction:: int PyComplex_Check(PyObject *p)
Modified: python/branches/release31-maint/Doc/c-api/dict.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/dict.rst (original)
+++ python/branches/release31-maint/Doc/c-api/dict.rst Fri Nov 26 09:49:15 2010
@@ -15,13 +15,8 @@
.. cvar:: PyTypeObject PyDict_Type
- .. index::
- single: DictType (in module types)
- single: DictionaryType (in module types)
-
This instance of :ctype:`PyTypeObject` represents the Python dictionary
- type. This is exposed to Python programs as ``dict`` and
- ``types.DictType``.
+ type. This is the same object as :class:`dict` in the Python layer.
.. cfunction:: int PyDict_Check(PyObject *p)
Modified: python/branches/release31-maint/Doc/c-api/float.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/float.rst (original)
+++ python/branches/release31-maint/Doc/c-api/float.rst Fri Nov 26 09:49:15 2010
@@ -15,10 +15,8 @@
.. cvar:: PyTypeObject PyFloat_Type
- .. index:: single: FloatType (in modules types)
-
This instance of :ctype:`PyTypeObject` represents the Python floating point
- type. This is the same object as ``float`` and ``types.FloatType``.
+ type. This is the same object as :class:`float` in the Python layer.
.. cfunction:: int PyFloat_Check(PyObject *p)
Modified: python/branches/release31-maint/Doc/c-api/intro.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/intro.rst (original)
+++ python/branches/release31-maint/Doc/c-api/intro.rst Fri Nov 26 09:49:15 2010
@@ -361,15 +361,16 @@
.. index:: single: PyErr_Occurred()
-For C programmers, however, error checking always has to be explicit. All
-functions in the Python/C API can raise exceptions, unless an explicit claim is
-made otherwise in a function's documentation. In general, when a function
-encounters an error, it sets an exception, discards any object references that
-it owns, and returns an error indicator --- usually *NULL* or ``-1``. A few
-functions return a Boolean true/false result, with false indicating an error.
-Very few functions return no explicit error indicator or have an ambiguous
-return value, and require explicit testing for errors with
-:cfunc:`PyErr_Occurred`.
+For C programmers, however, error checking always has to be explicit. All
+functions in the Python/C API can raise exceptions, unless an explicit claim is
+made otherwise in a function's documentation. In general, when a function
+encounters an error, it sets an exception, discards any object references that
+it owns, and returns an error indicator. If not documented otherwise, this
+indicator is either *NULL* or ``-1``, depending on the function's return type.
+A few functions return a Boolean true/false result, with false indicating an
+error. Very few functions return no explicit error indicator or have an
+ambiguous return value, and require explicit testing for errors with
+:cfunc:`PyErr_Occurred`. These exceptions are always explicitly documented.
.. index::
single: PyErr_SetString()
Modified: python/branches/release31-maint/Doc/c-api/list.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/list.rst (original)
+++ python/branches/release31-maint/Doc/c-api/list.rst Fri Nov 26 09:49:15 2010
@@ -15,8 +15,8 @@
.. cvar:: PyTypeObject PyList_Type
- This instance of :ctype:`PyTypeObject` represents the Python list type. This
- is the same object as ``list`` in the Python layer.
+ This instance of :ctype:`PyTypeObject` represents the Python list type.
+ This is the same object as :class:`list` in the Python layer.
.. cfunction:: int PyList_Check(PyObject *p)
Modified: python/branches/release31-maint/Doc/c-api/long.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/long.rst (original)
+++ python/branches/release31-maint/Doc/c-api/long.rst Fri Nov 26 09:49:15 2010
@@ -18,7 +18,7 @@
.. cvar:: PyTypeObject PyLong_Type
This instance of :ctype:`PyTypeObject` represents the Python integer type.
- This is the same object as ``int``.
+ This is the same object as :class:`int` in the Python layer.
.. cfunction:: int PyLong_Check(PyObject *p)
Modified: python/branches/release31-maint/Doc/c-api/slice.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/slice.rst (original)
+++ python/branches/release31-maint/Doc/c-api/slice.rst Fri Nov 26 09:49:15 2010
@@ -8,10 +8,8 @@
.. cvar:: PyTypeObject PySlice_Type
- .. index:: single: SliceType (in module types)
-
- The type object for slice objects. This is the same as ``slice`` and
- ``types.SliceType``.
+ The type object for slice objects. This is the same as :class:`slice` in the
+ Python layer.
.. cfunction:: int PySlice_Check(PyObject *ob)
Modified: python/branches/release31-maint/Doc/c-api/tuple.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/tuple.rst (original)
+++ python/branches/release31-maint/Doc/c-api/tuple.rst Fri Nov 26 09:49:15 2010
@@ -15,10 +15,8 @@
.. cvar:: PyTypeObject PyTuple_Type
- .. index:: single: TupleType (in module types)
-
- This instance of :ctype:`PyTypeObject` represents the Python tuple type; it is
- the same object as ``tuple`` and ``types.TupleType`` in the Python layer..
+ This instance of :ctype:`PyTypeObject` represents the Python tuple type; it
+ is the same object as :class:`tuple` in the Python layer.
.. cfunction:: int PyTuple_Check(PyObject *p)
Modified: python/branches/release31-maint/Doc/c-api/type.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/type.rst (original)
+++ python/branches/release31-maint/Doc/c-api/type.rst Fri Nov 26 09:49:15 2010
@@ -15,10 +15,8 @@
.. cvar:: PyObject* PyType_Type
- .. index:: single: TypeType (in module types)
-
- This is the type object for type objects; it is the same object as ``type`` and
- ``types.TypeType`` in the Python layer.
+ This is the type object for type objects; it is the same object as
+ :class:`type` in the Python layer.
.. cfunction:: int PyType_Check(PyObject *o)
Modified: python/branches/release31-maint/Doc/c-api/unicode.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/unicode.rst (original)
+++ python/branches/release31-maint/Doc/c-api/unicode.rst Fri Nov 26 09:49:15 2010
@@ -204,7 +204,7 @@
.. cfunction:: PyObject* PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size)
- Create a Unicode Object from the Py_UNICODE buffer *u* of the given size. *u*
+ Create a Unicode object from the Py_UNICODE buffer *u* of the given size. *u*
may be *NULL* which causes the contents to be undefined. It is the user's
responsibility to fill in the needed data. The buffer is copied into the new
object. If the buffer is not *NULL*, the return value might be a shared object.
@@ -214,7 +214,7 @@
.. cfunction:: PyObject* PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size)
- Create a Unicode Object from the char buffer *u*. The bytes will be interpreted
+ Create a Unicode object from the char buffer *u*. The bytes will be interpreted
as being UTF-8 encoded. *u* may also be *NULL* which
causes the contents to be undefined. It is the user's responsibility to fill in
the needed data. The buffer is copied into the new object. If the buffer is not
Modified: python/branches/release31-maint/Doc/c-api/veryhigh.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/veryhigh.rst (original)
+++ python/branches/release31-maint/Doc/c-api/veryhigh.rst Fri Nov 26 09:49:15 2010
@@ -123,13 +123,13 @@
.. cfunction:: int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
- Read and execute a single statement from a file associated with an interactive
- device according to the *flags* argument. If *filename* is *NULL*, ``"???"`` is
- used instead. The user will be prompted using ``sys.ps1`` and ``sys.ps2``.
- Returns ``0`` when the input was executed successfully, ``-1`` if there was an
- exception, or an error code from the :file:`errcode.h` include file distributed
- as part of Python if there was a parse error. (Note that :file:`errcode.h` is
- not included by :file:`Python.h`, so must be included specifically if needed.)
+ Read and execute a single statement from a file associated with an
+ interactive device according to the *flags* argument. The user will be
+ prompted using ``sys.ps1`` and ``sys.ps2``. Returns ``0`` when the input was
+ executed successfully, ``-1`` if there was an exception, or an error code
+ from the :file:`errcode.h` include file distributed as part of Python if
+ there was a parse error. (Note that :file:`errcode.h` is not included by
+ :file:`Python.h`, so must be included specifically if needed.)
.. cfunction:: int PyRun_InteractiveLoop(FILE *fp, const char *filename)
@@ -138,11 +138,11 @@
leaving *flags* set to *NULL*.
-.. cfunction:: int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
+.. cfunction:: int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
Read and execute statements from a file associated with an interactive device
- until EOF is reached. If *filename* is *NULL*, ``"???"`` is used instead. The
- user will be prompted using ``sys.ps1`` and ``sys.ps2``. Returns ``0`` at EOF.
+ until EOF is reached. The user will be prompted using ``sys.ps1`` and
+ ``sys.ps2``. Returns ``0`` at EOF.
.. cfunction:: struct _node* PyParser_SimpleParseString(const char *str, int start)
Modified: python/branches/release31-maint/Doc/faq/windows.rst
==============================================================================
--- python/branches/release31-maint/Doc/faq/windows.rst (original)
+++ python/branches/release31-maint/Doc/faq/windows.rst Fri Nov 26 09:49:15 2010
@@ -290,20 +290,18 @@
1. Do _not_ build Python into your .exe file directly. On Windows, Python must
be a DLL to handle importing modules that are themselves DLL's. (This is the
- first key undocumented fact.) Instead, link to :file:`python{NN}.dll`; it is
- typically installed in ``C:\Windows\System``. NN is the Python version, a
+ first key undocumented fact.) Instead, link to :file:`python{NN}.dll`; it is
+ typically installed in ``C:\Windows\System``. *NN* is the Python version, a
number such as "23" for Python 2.3.
- You can link to Python statically or dynamically. Linking statically means
- linking against :file:`python{NN}.lib`, while dynamically linking means
- linking against :file:`python{NN}.dll`. The drawback to dynamic linking is
- that your app won't run if :file:`python{NN}.dll` does not exist on your
- system. (General note: :file:`python{NN}.lib` is the so-called "import lib"
- corresponding to :file:`python.dll`. It merely defines symbols for the
- linker.)
+ You can link to Python in two different ways. Load-time linking means
+ linking against :file:`python{NN}.lib`, while run-time linking means linking
+ against :file:`python{NN}.dll`. (General note: :file:`python{NN}.lib` is the
+ so-called "import lib" corresponding to :file:`python{NN}.dll`. It merely
+ defines symbols for the linker.)
- Linking dynamically greatly simplifies link options; everything happens at
- run time. Your code must load :file:`python{NN}.dll` using the Windows
+ Run-time linking greatly simplifies link options; everything happens at run
+ time. Your code must load :file:`python{NN}.dll` using the Windows
``LoadLibraryEx()`` routine. The code must also use access routines and data
in :file:`python{NN}.dll` (that is, Python's C API's) using pointers obtained
by the Windows ``GetProcAddress()`` routine. Macros can make using these
@@ -312,6 +310,8 @@
Borland note: convert :file:`python{NN}.lib` to OMF format using Coff2Omf.exe
first.
+ .. XXX what about static linking?
+
2. If you use SWIG, it is easy to create a Python "extension module" that will
make the app's data and methods available to Python. SWIG will handle just
about all the grungy details for you. The result is C code that you link
Modified: python/branches/release31-maint/Doc/howto/cporting.rst
==============================================================================
--- python/branches/release31-maint/Doc/howto/cporting.rst (original)
+++ python/branches/release31-maint/Doc/howto/cporting.rst Fri Nov 26 09:49:15 2010
@@ -50,9 +50,9 @@
compatibility with 3.0, :ctype:`PyUnicode` should be used for textual data and
:ctype:`PyBytes` for binary data. It's also important to remember that
:ctype:`PyBytes` and :ctype:`PyUnicode` in 3.0 are not interchangeable like
-:ctype:`PyString` and :ctype:`PyString` are in 2.x. The following example shows
-best practices with regards to :ctype:`PyUnicode`, :ctype:`PyString`, and
-:ctype:`PyBytes`. ::
+:ctype:`PyString` and :ctype:`PyUnicode` are in 2.x. The following example
+shows best practices with regards to :ctype:`PyUnicode`, :ctype:`PyString`,
+and :ctype:`PyBytes`. ::
#include "stdlib.h"
#include "Python.h"
Modified: python/branches/release31-maint/Doc/library/audioop.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/audioop.rst (original)
+++ python/branches/release31-maint/Doc/library/audioop.rst Fri Nov 26 09:49:15 2010
@@ -230,8 +230,8 @@
def mul_stereo(sample, width, lfactor, rfactor):
lsample = audioop.tomono(sample, width, 1, 0)
rsample = audioop.tomono(sample, width, 0, 1)
- lsample = audioop.mul(sample, width, lfactor)
- rsample = audioop.mul(sample, width, rfactor)
+ lsample = audioop.mul(lsample, width, lfactor)
+ rsample = audioop.mul(rsample, width, rfactor)
lsample = audioop.tostereo(lsample, width, 1, 0)
rsample = audioop.tostereo(rsample, width, 0, 1)
return audioop.add(lsample, rsample, width)
Modified: python/branches/release31-maint/Doc/library/base64.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/base64.rst (original)
+++ python/branches/release31-maint/Doc/library/base64.rst Fri Nov 26 09:49:15 2010
@@ -157,12 +157,12 @@
An example usage of the module:
>>> import base64
- >>> encoded = base64.b64encode('data to be encoded')
+ >>> encoded = base64.b64encode(b'data to be encoded')
>>> encoded
b'ZGF0YSB0byBiZSBlbmNvZGVk'
>>> data = base64.b64decode(encoded)
>>> data
- 'data to be encoded'
+ b'data to be encoded'
.. seealso::
Modified: python/branches/release31-maint/Doc/library/difflib.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/difflib.rst (original)
+++ python/branches/release31-maint/Doc/library/difflib.rst Fri Nov 26 09:49:15 2010
@@ -500,16 +500,11 @@
Return an upper bound on :meth:`ratio` relatively quickly.
- This isn't defined beyond that it is an upper bound on :meth:`ratio`, and
- is faster to compute.
-
.. method:: real_quick_ratio()
Return an upper bound on :meth:`ratio` very quickly.
- This isn't defined beyond that it is an upper bound on :meth:`ratio`, and
- is faster to compute than either :meth:`ratio` or :meth:`quick_ratio`.
The three methods that return the ratio of matching to total characters can give
different results due to differing levels of approximation, although
Modified: python/branches/release31-maint/Doc/library/dis.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/dis.rst (original)
+++ python/branches/release31-maint/Doc/library/dis.rst Fri Nov 26 09:49:15 2010
@@ -93,7 +93,7 @@
.. data:: opmap
- Dictionary mapping bytecodes to operation names.
+ Dictionary mapping operation names to bytecodes.
.. data:: cmp_op
Modified: python/branches/release31-maint/Doc/library/functions.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/functions.rst (original)
+++ python/branches/release31-maint/Doc/library/functions.rst Fri Nov 26 09:49:15 2010
@@ -466,7 +466,7 @@
.. function:: getattr(object, name[, default])
- Return the value of the named attributed of *object*. *name* must be a string.
+ Return the value of the named attribute of *object*. *name* must be a string.
If the string is the name of one of the object's attributes, the result is the
value of that attribute. For example, ``getattr(x, 'foobar')`` is equivalent to
``x.foobar``. If the named attribute does not exist, *default* is returned if
Modified: python/branches/release31-maint/Doc/library/hmac.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/hmac.rst (original)
+++ python/branches/release31-maint/Doc/library/hmac.rst Fri Nov 26 09:49:15 2010
@@ -2,7 +2,8 @@
========================================================
.. module:: hmac
- :synopsis: Keyed-Hashing for Message Authentication (HMAC) implementation for Python.
+ :synopsis: Keyed-Hashing for Message Authentication (HMAC) implementation
+ for Python.
.. moduleauthor:: Gerhard HƤring <ghaering(a)users.sourceforge.net>
.. sectionauthor:: Gerhard HƤring <ghaering(a)users.sourceforge.net>
@@ -12,37 +13,34 @@
.. function:: new(key, msg=None, digestmod=None)
- Return a new hmac object. If *msg* is present, the method call ``update(msg)``
- is made. *digestmod* is the digest constructor or module for the HMAC object to
- use. It defaults to the :func:`hashlib.md5` constructor.
+ Return a new hmac object. *key* is a bytes object giving the secret key. If
+ *msg* is present, the method call ``update(msg)`` is made. *digestmod* is
+ the digest constructor or module for the HMAC object to use. It defaults to
+ the :func:`hashlib.md5` constructor.
- .. note::
-
- The md5 hash has known weaknesses but remains the default for backwards
- compatibility. Choose a better one for your application.
An HMAC object has the following methods:
-
.. method:: hmac.update(msg)
- Update the hmac object with the string *msg*. Repeated calls are equivalent to
- a single call with the concatenation of all the arguments: ``m.update(a);
- m.update(b)`` is equivalent to ``m.update(a + b)``.
+ Update the hmac object with the bytes object *msg*. Repeated calls are
+ equivalent to a single call with the concatenation of all the arguments:
+ ``m.update(a); m.update(b)`` is equivalent to ``m.update(a + b)``.
.. method:: hmac.digest()
- Return the digest of the strings passed to the :meth:`update` method so far.
- This string will be the same length as the *digest_size* of the digest given to
- the constructor. It may contain non-ASCII characters, including NUL bytes.
+ Return the digest of the bytes passed to the :meth:`update` method so far.
+ This bytes object will be the same length as the *digest_size* of the digest
+ given to the constructor. It may contain non-ASCII bytes, including NUL
+ bytes.
.. method:: hmac.hexdigest()
- Like :meth:`digest` except the digest is returned as a string twice the length
- containing only hexadecimal digits. This may be used to exchange the value
- safely in email or other non-binary environments.
+ Like :meth:`digest` except the digest is returned as a string twice the
+ length containing only hexadecimal digits. This may be used to exchange the
+ value safely in email or other non-binary environments.
.. method:: hmac.copy()
@@ -55,4 +53,3 @@
Module :mod:`hashlib`
The Python module providing secure hash functions.
-
Modified: python/branches/release31-maint/Doc/library/os.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/os.rst (original)
+++ python/branches/release31-maint/Doc/library/os.rst Fri Nov 26 09:49:15 2010
@@ -1421,15 +1421,15 @@
.. function:: _exit(n)
- Exit to the system with status *n*, without calling cleanup handlers, flushing
+ Exit the process with status *n*, without calling cleanup handlers, flushing
stdio buffers, etc.
Availability: Unix, Windows.
.. note::
- The standard way to exit is ``sys.exit(n)``. :func:`_exit` should normally only
- be used in the child process after a :func:`fork`.
+ The standard way to exit is ``sys.exit(n)``. :func:`_exit` should
+ normally only be used in the child process after a :func:`fork`.
The following exit codes are defined and can be used with :func:`_exit`,
although they are not required. These are typically used for system programs
Modified: python/branches/release31-maint/Doc/library/parser.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/parser.rst (original)
+++ python/branches/release31-maint/Doc/library/parser.rst Fri Nov 26 09:49:15 2010
@@ -318,22 +318,8 @@
Same as ``st2tuple(st, line_info)``.
-.. _st-examples:
-
-Examples
---------
-
-.. index:: builtin: compile
-
-The parser modules allows operations to be performed on the parse tree of Python
-source code before the :term:`bytecode` is generated, and provides for inspection of the
-parse tree for information gathering purposes. Two examples are presented. The
-simple example demonstrates emulation of the :func:`compile` built-in function
-and the complex example shows the use of a parse tree for information discovery.
-
-
-Emulation of :func:`compile`
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Example: Emulation of :func:`compile`
+-------------------------------------
While many useful operations may take place between parsing and bytecode
generation, the simplest operation is to do nothing. For this purpose, using
@@ -367,320 +353,3 @@
def load_expression(source_string):
st = parser.expr(source_string)
return st, st.compile()
-
-
-Information Discovery
-^^^^^^^^^^^^^^^^^^^^^
-
-.. index::
- single: string; documentation
- single: docstrings
-
-Some applications benefit from direct access to the parse tree. The remainder
-of this section demonstrates how the parse tree provides access to module
-documentation defined in docstrings without requiring that the code being
-examined be loaded into a running interpreter via :keyword:`import`. This can
-be very useful for performing analyses of untrusted code.
-
-Generally, the example will demonstrate how the parse tree may be traversed to
-distill interesting information. Two functions and a set of classes are
-developed which provide programmatic access to high level function and class
-definitions provided by a module. The classes extract information from the
-parse tree and provide access to the information at a useful semantic level, one
-function provides a simple low-level pattern matching capability, and the other
-function defines a high-level interface to the classes by handling file
-operations on behalf of the caller. All source files mentioned here which are
-not part of the Python installation are located in the :file:`Demo/parser/`
-directory of the distribution.
-
-The dynamic nature of Python allows the programmer a great deal of flexibility,
-but most modules need only a limited measure of this when defining classes,
-functions, and methods. In this example, the only definitions that will be
-considered are those which are defined in the top level of their context, e.g.,
-a function defined by a :keyword:`def` statement at column zero of a module, but
-not a function defined within a branch of an :keyword:`if` ... :keyword:`else`
-construct, though there are some good reasons for doing so in some situations.
-Nesting of definitions will be handled by the code developed in the example.
-
-To construct the upper-level extraction methods, we need to know what the parse
-tree structure looks like and how much of it we actually need to be concerned
-about. Python uses a moderately deep parse tree so there are a large number of
-intermediate nodes. It is important to read and understand the formal grammar
-used by Python. This is specified in the file :file:`Grammar/Grammar` in the
-distribution. Consider the simplest case of interest when searching for
-docstrings: a module consisting of a docstring and nothing else. (See file
-:file:`docstring.py`.) ::
-
- """Some documentation.
- """
-
-Using the interpreter to take a look at the parse tree, we find a bewildering
-mass of numbers and parentheses, with the documentation buried deep in nested
-tuples. ::
-
- >>> import parser
- >>> import pprint
- >>> st = parser.suite(open('docstring.py').read())
- >>> tup = st.totuple()
- >>> pprint.pprint(tup)
- (257,
- (264,
- (265,
- (266,
- (267,
- (307,
- (287,
- (288,
- (289,
- (290,
- (292,
- (293,
- (294,
- (295,
- (296,
- (297,
- (298,
- (299,
- (300, (3, '"""Some documentation.\n"""'))))))))))))))))),
- (4, ''))),
- (4, ''),
- (0, ''))
-
-The numbers at the first element of each node in the tree are the node types;
-they map directly to terminal and non-terminal symbols in the grammar.
-Unfortunately, they are represented as integers in the internal representation,
-and the Python structures generated do not change that. However, the
-:mod:`symbol` and :mod:`token` modules provide symbolic names for the node types
-and dictionaries which map from the integers to the symbolic names for the node
-types.
-
-In the output presented above, the outermost tuple contains four elements: the
-integer ``257`` and three additional tuples. Node type ``257`` has the symbolic
-name :const:`file_input`. Each of these inner tuples contains an integer as the
-first element; these integers, ``264``, ``4``, and ``0``, represent the node
-types :const:`stmt`, :const:`NEWLINE`, and :const:`ENDMARKER`, respectively.
-Note that these values may change depending on the version of Python you are
-using; consult :file:`symbol.py` and :file:`token.py` for details of the
-mapping. It should be fairly clear that the outermost node is related primarily
-to the input source rather than the contents of the file, and may be disregarded
-for the moment. The :const:`stmt` node is much more interesting. In
-particular, all docstrings are found in subtrees which are formed exactly as
-this node is formed, with the only difference being the string itself. The
-association between the docstring in a similar tree and the defined entity
-(class, function, or module) which it describes is given by the position of the
-docstring subtree within the tree defining the described structure.
-
-By replacing the actual docstring with something to signify a variable component
-of the tree, we allow a simple pattern matching approach to check any given
-subtree for equivalence to the general pattern for docstrings. Since the
-example demonstrates information extraction, we can safely require that the tree
-be in tuple form rather than list form, allowing a simple variable
-representation to be ``['variable_name']``. A simple recursive function can
-implement the pattern matching, returning a Boolean and a dictionary of variable
-name to value mappings. (See file :file:`example.py`.) ::
-
- def match(pattern, data, vars=None):
- if vars is None:
- vars = {}
- if isinstance(pattern, list):
- vars[pattern[0]] = data
- return True, vars
- if not instance(pattern, tuple):
- return (pattern == data), vars
- if len(data) != len(pattern):
- return False, vars
- for pattern, data in zip(pattern, data):
- same, vars = match(pattern, data, vars)
- if not same:
- break
- return same, vars
-
-Using this simple representation for syntactic variables and the symbolic node
-types, the pattern for the candidate docstring subtrees becomes fairly readable.
-(See file :file:`example.py`.) ::
-
- import symbol
- import token
-
- DOCSTRING_STMT_PATTERN = (
- symbol.stmt,
- (symbol.simple_stmt,
- (symbol.small_stmt,
- (symbol.expr_stmt,
- (symbol.testlist,
- (symbol.test,
- (symbol.and_test,
- (symbol.not_test,
- (symbol.comparison,
- (symbol.expr,
- (symbol.xor_expr,
- (symbol.and_expr,
- (symbol.shift_expr,
- (symbol.arith_expr,
- (symbol.term,
- (symbol.factor,
- (symbol.power,
- (symbol.atom,
- (token.STRING, ['docstring'])
- )))))))))))))))),
- (token.NEWLINE, '')
- ))
-
-Using the :func:`match` function with this pattern, extracting the module
-docstring from the parse tree created previously is easy::
-
- >>> found, vars = match(DOCSTRING_STMT_PATTERN, tup[1])
- >>> found
- True
- >>> vars
- {'docstring': '"""Some documentation.\n"""'}
-
-Once specific data can be extracted from a location where it is expected, the
-question of where information can be expected needs to be answered. When
-dealing with docstrings, the answer is fairly simple: the docstring is the first
-:const:`stmt` node in a code block (:const:`file_input` or :const:`suite` node
-types). A module consists of a single :const:`file_input` node, and class and
-function definitions each contain exactly one :const:`suite` node. Classes and
-functions are readily identified as subtrees of code block nodes which start
-with ``(stmt, (compound_stmt, (classdef, ...`` or ``(stmt, (compound_stmt,
-(funcdef, ...``. Note that these subtrees cannot be matched by :func:`match`
-since it does not support multiple sibling nodes to match without regard to
-number. A more elaborate matching function could be used to overcome this
-limitation, but this is sufficient for the example.
-
-Given the ability to determine whether a statement might be a docstring and
-extract the actual string from the statement, some work needs to be performed to
-walk the parse tree for an entire module and extract information about the names
-defined in each context of the module and associate any docstrings with the
-names. The code to perform this work is not complicated, but bears some
-explanation.
-
-The public interface to the classes is straightforward and should probably be
-somewhat more flexible. Each "major" block of the module is described by an
-object providing several methods for inquiry and a constructor which accepts at
-least the subtree of the complete parse tree which it represents. The
-:class:`ModuleInfo` constructor accepts an optional *name* parameter since it
-cannot otherwise determine the name of the module.
-
-The public classes include :class:`ClassInfo`, :class:`FunctionInfo`, and
-:class:`ModuleInfo`. All objects provide the methods :meth:`get_name`,
-:meth:`get_docstring`, :meth:`get_class_names`, and :meth:`get_class_info`. The
-:class:`ClassInfo` objects support :meth:`get_method_names` and
-:meth:`get_method_info` while the other classes provide
-:meth:`get_function_names` and :meth:`get_function_info`.
-
-Within each of the forms of code block that the public classes represent, most
-of the required information is in the same form and is accessed in the same way,
-with classes having the distinction that functions defined at the top level are
-referred to as "methods." Since the difference in nomenclature reflects a real
-semantic distinction from functions defined outside of a class, the
-implementation needs to maintain the distinction. Hence, most of the
-functionality of the public classes can be implemented in a common base class,
-:class:`SuiteInfoBase`, with the accessors for function and method information
-provided elsewhere. Note that there is only one class which represents function
-and method information; this parallels the use of the :keyword:`def` statement
-to define both types of elements.
-
-Most of the accessor functions are declared in :class:`SuiteInfoBase` and do not
-need to be overridden by subclasses. More importantly, the extraction of most
-information from a parse tree is handled through a method called by the
-:class:`SuiteInfoBase` constructor. The example code for most of the classes is
-clear when read alongside the formal grammar, but the method which recursively
-creates new information objects requires further examination. Here is the
-relevant part of the :class:`SuiteInfoBase` definition from :file:`example.py`::
-
- class SuiteInfoBase:
- _docstring = ''
- _name = ''
-
- def __init__(self, tree = None):
- self._class_info = {}
- self._function_info = {}
- if tree:
- self._extract_info(tree)
-
- def _extract_info(self, tree):
- # extract docstring
- if len(tree) == 2:
- found, vars = match(DOCSTRING_STMT_PATTERN[1], tree[1])
- else:
- found, vars = match(DOCSTRING_STMT_PATTERN, tree[3])
- if found:
- self._docstring = eval(vars['docstring'])
- # discover inner definitions
- for node in tree[1:]:
- found, vars = match(COMPOUND_STMT_PATTERN, node)
- if found:
- cstmt = vars['compound']
- if cstmt[0] == symbol.funcdef:
- name = cstmt[2][1]
- self._function_info[name] = FunctionInfo(cstmt)
- elif cstmt[0] == symbol.classdef:
- name = cstmt[2][1]
- self._class_info[name] = ClassInfo(cstmt)
-
-After initializing some internal state, the constructor calls the
-:meth:`_extract_info` method. This method performs the bulk of the information
-extraction which takes place in the entire example. The extraction has two
-distinct phases: the location of the docstring for the parse tree passed in, and
-the discovery of additional definitions within the code block represented by the
-parse tree.
-
-The initial :keyword:`if` test determines whether the nested suite is of the
-"short form" or the "long form." The short form is used when the code block is
-on the same line as the definition of the code block, as in ::
-
- def square(x): "Square an argument."; return x ** 2
-
-while the long form uses an indented block and allows nested definitions::
-
- def make_power(exp):
- "Make a function that raises an argument to the exponent `exp`."
- def raiser(x, y=exp):
- return x ** y
- return raiser
-
-When the short form is used, the code block may contain a docstring as the
-first, and possibly only, :const:`small_stmt` element. The extraction of such a
-docstring is slightly different and requires only a portion of the complete
-pattern used in the more common case. As implemented, the docstring will only
-be found if there is only one :const:`small_stmt` node in the
-:const:`simple_stmt` node. Since most functions and methods which use the short
-form do not provide a docstring, this may be considered sufficient. The
-extraction of the docstring proceeds using the :func:`match` function as
-described above, and the value of the docstring is stored as an attribute of the
-:class:`SuiteInfoBase` object.
-
-After docstring extraction, a simple definition discovery algorithm operates on
-the :const:`stmt` nodes of the :const:`suite` node. The special case of the
-short form is not tested; since there are no :const:`stmt` nodes in the short
-form, the algorithm will silently skip the single :const:`simple_stmt` node and
-correctly not discover any nested definitions.
-
-Each statement in the code block is categorized as a class definition, function
-or method definition, or something else. For the definition statements, the
-name of the element defined is extracted and a representation object appropriate
-to the definition is created with the defining subtree passed as an argument to
-the constructor. The representation objects are stored in instance variables
-and may be retrieved by name using the appropriate accessor methods.
-
-The public classes provide any accessors required which are more specific than
-those provided by the :class:`SuiteInfoBase` class, but the real extraction
-algorithm remains common to all forms of code blocks. A high-level function can
-be used to extract the complete set of information from a source file. (See
-file :file:`example.py`.) ::
-
- def get_docs(fileName):
- import os
- import parser
-
- source = open(fileName).read()
- basename = os.path.basename(os.path.splitext(fileName)[0])
- st = parser.suite(source)
- return ModuleInfo(st.totuple(), basename)
-
-This provides an easy-to-use interface to the documentation of a module. If
-information is required which is not extracted by the code of this example, the
-code may be extended at clearly defined points to provide additional
-capabilities.
-
Modified: python/branches/release31-maint/Doc/library/pickle.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/pickle.rst (original)
+++ python/branches/release31-maint/Doc/library/pickle.rst Fri Nov 26 09:49:15 2010
@@ -23,6 +23,12 @@
"serialization", "marshalling," [#]_ or "flattening", however, to avoid
confusion, the terms used here are "pickling" and "unpickling"..
+.. warning::
+
+ The :mod:`pickle` module is not intended to be secure against erroneous or
+ maliciously constructed data. Never unpickle data received from an untrusted
+ or unauthenticated source.
+
Relationship to other Python modules
------------------------------------
@@ -63,12 +69,6 @@
The :mod:`pickle` serialization format is guaranteed to be backwards compatible
across Python releases.
-.. warning::
-
- The :mod:`pickle` module is not intended to be secure against erroneous or
- maliciously constructed data. Never unpickle data received from an untrusted
- or unauthenticated source.
-
Note that serialization is a more primitive notion than persistence; although
:mod:`pickle` reads and writes file objects, it does not handle the issue of
naming persistent objects, nor the (even more complicated) issue of concurrent
@@ -427,33 +427,38 @@
obj.__dict__.update(attributes)
return obj
-.. index:: single: __getnewargs__() (copy protocol)
-
Classes can alter the default behaviour by providing one or several special
-methods. In protocol 2 and newer, classes that implements the
-:meth:`__getnewargs__` method can dictate the values passed to the
-:meth:`__new__` method upon unpickling. This is often needed for classes
-whose :meth:`__new__` method requires arguments.
-
-.. index:: single: __getstate__() (copy protocol)
-
-Classes can further influence how their instances are pickled; if the class
-defines the method :meth:`__getstate__`, it is called and the returned object is
-pickled as the contents for the instance, instead of the contents of the
-instance's dictionary. If the :meth:`__getstate__` method is absent, the
-instance's :attr:`__dict__` is pickled as usual.
-
-.. index:: single: __setstate__() (copy protocol)
-
-Upon unpickling, if the class defines :meth:`__setstate__`, it is called with
-the unpickled state. In that case, there is no requirement for the state object
-to be a dictionary. Otherwise, the pickled state must be a dictionary and its
-items are assigned to the new instance's dictionary.
+methods:
-.. note::
+.. method:: object.__getnewargs__()
+
+ In protocol 2 and newer, classes that implements the :meth:`__getnewargs__`
+ method can dictate the values passed to the :meth:`__new__` method upon
+ unpickling. This is often needed for classes whose :meth:`__new__` method
+ requires arguments.
+
+
+.. method:: object.__getstate__()
+
+ Classes can further influence how their instances are pickled; if the class
+ defines the method :meth:`__getstate__`, it is called and the returned object
+ is pickled as the contents for the instance, instead of the contents of the
+ instance's dictionary. If the :meth:`__getstate__` method is absent, the
+ instance's :attr:`__dict__` is pickled as usual.
+
+
+.. method:: object.__setstate__(state)
+
+ Upon unpickling, if the class defines :meth:`__setstate__`, it is called with
+ the unpickled state. In that case, there is no requirement for the state
+ object to be a dictionary. Otherwise, the pickled state must be a dictionary
+ and its items are assigned to the new instance's dictionary.
+
+ .. note::
+
+ If :meth:`__getstate__` returns a false value, the :meth:`__setstate__`
+ method will not be called upon unpickling.
- If :meth:`__getstate__` returns a false value, the :meth:`__setstate__`
- method will not be called.
Refer to the section :ref:`pickle-state` for more information about how to use
the methods :meth:`__getstate__` and :meth:`__setstate__`.
@@ -462,14 +467,12 @@
At unpickling time, some methods like :meth:`__getattr__`,
:meth:`__getattribute__`, or :meth:`__setattr__` may be called upon the
- instance. In case those methods rely on some internal invariant being
- true, the type should implement either :meth:`__getinitargs__` or
- :meth:`__getnewargs__` to establish such an invariant; otherwise, neither
- :meth:`__new__` nor :meth:`__init__` will be called.
+ instance. In case those methods rely on some internal invariant being true,
+ the type should implement :meth:`__getnewargs__` to establish such an
+ invariant; otherwise, neither :meth:`__new__` nor :meth:`__init__` will be
+ called.
-.. index::
- pair: copy; protocol
- single: __reduce__() (copy protocol)
+.. index:: pair: copy; protocol
As we shall see, pickle does not use directly the methods described above. In
fact, these methods are part of the copy protocol which implements the
@@ -480,58 +483,61 @@
Although powerful, implementing :meth:`__reduce__` directly in your classes is
error prone. For this reason, class designers should use the high-level
interface (i.e., :meth:`__getnewargs__`, :meth:`__getstate__` and
-:meth:`__setstate__`) whenever possible. We will show, however, cases where using
-:meth:`__reduce__` is the only option or leads to more efficient pickling or
-both.
-
-The interface is currently defined as follows. The :meth:`__reduce__` method
-takes no argument and shall return either a string or preferably a tuple (the
-returned object is often referred to as the "reduce value").
-
-If a string is returned, the string should be interpreted as the name of a
-global variable. It should be the object's local name relative to its module;
-the pickle module searches the module namespace to determine the object's
-module. This behaviour is typically useful for singletons.
-
-When a tuple is returned, it must be between two and five items long. Optional
-items can either be omitted, or ``None`` can be provided as their value. The
-semantics of each item are in order:
-
-.. XXX Mention __newobj__ special-case?
-
-* A callable object that will be called to create the initial version of the
- object.
-
-* A tuple of arguments for the callable object. An empty tuple must be given if
- the callable does not accept any argument.
-
-* Optionally, the object's state, which will be passed to the object's
- :meth:`__setstate__` method as previously described. If the object has no
- such method then, the value must be a dictionary and it will be added to the
- object's :attr:`__dict__` attribute.
-
-* Optionally, an iterator (and not a sequence) yielding successive items. These
- items will be appended to the object either using ``obj.append(item)`` or, in
- batch, using ``obj.extend(list_of_items)``. This is primarily used for list
- subclasses, but may be used by other classes as long as they have
- :meth:`append` and :meth:`extend` methods with the appropriate signature.
- (Whether :meth:`append` or :meth:`extend` is used depends on which pickle
- protocol version is used as well as the number of items to append, so both
- must be supported.)
-
-* Optionally, an iterator (not a sequence) yielding successive key-value pairs.
- These items will be stored to the object using ``obj[key] = value``. This is
- primarily used for dictionary subclasses, but may be used by other classes as
- long as they implement :meth:`__setitem__`.
-
-.. index:: single: __reduce_ex__() (copy protocol)
-
-Alternatively, a :meth:`__reduce_ex__` method may be defined. The only
-difference is this method should take a single integer argument, the protocol
-version. When defined, pickle will prefer it over the :meth:`__reduce__`
-method. In addition, :meth:`__reduce__` automatically becomes a synonym for the
-extended version. The main use for this method is to provide
-backwards-compatible reduce values for older Python releases.
+:meth:`__setstate__`) whenever possible. We will show, however, cases where
+using :meth:`__reduce__` is the only option or leads to more efficient pickling
+or both.
+
+.. method:: object.__reduce__()
+
+ The interface is currently defined as follows. The :meth:`__reduce__` method
+ takes no argument and shall return either a string or preferably a tuple (the
+ returned object is often referred to as the "reduce value").
+
+ If a string is returned, the string should be interpreted as the name of a
+ global variable. It should be the object's local name relative to its
+ module; the pickle module searches the module namespace to determine the
+ object's module. This behaviour is typically useful for singletons.
+
+ When a tuple is returned, it must be between two and five items long.
+ Optional items can either be omitted, or ``None`` can be provided as their
+ value. The semantics of each item are in order:
+
+ .. XXX Mention __newobj__ special-case?
+
+ * A callable object that will be called to create the initial version of the
+ object.
+
+ * A tuple of arguments for the callable object. An empty tuple must be given
+ if the callable does not accept any argument.
+
+ * Optionally, the object's state, which will be passed to the object's
+ :meth:`__setstate__` method as previously described. If the object has no
+ such method then, the value must be a dictionary and it will be added to
+ the object's :attr:`__dict__` attribute.
+
+ * Optionally, an iterator (and not a sequence) yielding successive items.
+ These items will be appended to the object either using
+ ``obj.append(item)`` or, in batch, using ``obj.extend(list_of_items)``.
+ This is primarily used for list subclasses, but may be used by other
+ classes as long as they have :meth:`append` and :meth:`extend` methods with
+ the appropriate signature. (Whether :meth:`append` or :meth:`extend` is
+ used depends on which pickle protocol version is used as well as the number
+ of items to append, so both must be supported.)
+
+ * Optionally, an iterator (not a sequence) yielding successive key-value
+ pairs. These items will be stored to the object using ``obj[key] =
+ value``. This is primarily used for dictionary subclasses, but may be used
+ by other classes as long as they implement :meth:`__setitem__`.
+
+
+.. method:: object.__reduce_ex__(protocol)
+
+ Alternatively, a :meth:`__reduce_ex__` method may be defined. The only
+ difference is this method should take a single integer argument, the protocol
+ version. When defined, pickle will prefer it over the :meth:`__reduce__`
+ method. In addition, :meth:`__reduce__` automatically becomes a synonym for
+ the extended version. The main use for this method is to provide
+ backwards-compatible reduce values for older Python releases.
.. _pickle-persistent:
Modified: python/branches/release31-maint/Doc/library/shelve.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/shelve.rst (original)
+++ python/branches/release31-maint/Doc/library/shelve.rst Fri Nov 26 09:49:15 2010
@@ -43,6 +43,11 @@
:meth:`close` explicitly when you don't need it any more, or use a
:keyword:`with` statement with :func:`contextlib.closing`.
+.. warning::
+
+ Because the :mod:`shelve` module is backed by :mod:`pickle`, it is insecure
+ to load a shelf from an untrusted source. Like with pickle, loading a shelf
+ can execute arbitrary code.
Shelf objects support all methods supported by dictionaries. This eases the
transition from dictionary based scripts to those requiring persistent storage.
Modified: python/branches/release31-maint/Doc/library/sqlite3.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/sqlite3.rst (original)
+++ python/branches/release31-maint/Doc/library/sqlite3.rst Fri Nov 26 09:49:15 2010
@@ -255,23 +255,22 @@
.. method:: Connection.execute(sql, [parameters])
This is a nonstandard shortcut that creates an intermediate cursor object by
- calling the cursor method, then calls the cursor's
- :meth:`execute<Cursor.execute>` method with the parameters given.
+ calling the cursor method, then calls the cursor's :meth:`execute
+ <Cursor.execute>` method with the parameters given.
.. method:: Connection.executemany(sql, [parameters])
This is a nonstandard shortcut that creates an intermediate cursor object by
- calling the cursor method, then calls the cursor's
- :meth:`executemany<Cursor.executemany>` method with the parameters given.
+ calling the cursor method, then calls the cursor's :meth:`executemany
+ <Cursor.executemany>` method with the parameters given.
.. method:: Connection.executescript(sql_script)
This is a nonstandard shortcut that creates an intermediate cursor object by
- calling the cursor method, then calls the cursor's
- :meth:`executescript<Cursor.executescript>` method with the parameters
- given.
+ calling the cursor method, then calls the cursor's :meth:`executescript
+ <Cursor.executescript>` method with the parameters given.
.. method:: Connection.create_function(name, num_params, func)
@@ -435,7 +434,7 @@
.. class:: Cursor
- A SQLite database cursor has the following attributes and methods:
+ A :class:`Cursor` instance has the following attributes and methods.
.. method:: Cursor.execute(sql, [parameters])
@@ -853,4 +852,3 @@
The only exception is calling the :meth:`~Connection.interrupt` method, which
only makes sense to call from a different thread.
-
Modified: python/branches/release31-maint/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/stdtypes.rst (original)
+++ python/branches/release31-maint/Doc/library/stdtypes.rst Fri Nov 26 09:49:15 2010
@@ -1264,9 +1264,8 @@
dictionary inserted immediately after the ``'%'`` character. The mapping key
selects the value to be formatted from the mapping. For example:
-
- >>> print('%(language)s has %(#)03d quote types.' % \
- ... {'language': "Python", "#": 2})
+ >>> print('%(language)s has %(number)03d quote types.' %
+ ... {'language': "Python", "number": 2})
Python has 002 quote types.
In this case no ``*`` specifiers may occur in a format (since they require a
@@ -1877,12 +1876,12 @@
values are added as items to the dictionary. If a key is specified both in
the positional argument and as a keyword argument, the value associated with
the keyword is retained in the dictionary. For example, these all return a
- dictionary equal to ``{"one": 2, "two": 3}``:
+ dictionary equal to ``{"one": 1, "two": 2}``:
- * ``dict(one=2, two=3)``
- * ``dict({'one': 2, 'two': 3})``
- * ``dict(zip(('one', 'two'), (2, 3)))``
- * ``dict([['two', 3], ['one', 2]])``
+ * ``dict(one=1, two=2)``
+ * ``dict({'one': 1, 'two': 2})``
+ * ``dict(zip(('one', 'two'), (1, 2)))``
+ * ``dict([['two', 2], ['one', 1]])``
The first example only works for keys that are valid Python identifiers; the
others work with any valid keys.
Modified: python/branches/release31-maint/Doc/library/sys.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/sys.rst (original)
+++ python/branches/release31-maint/Doc/library/sys.rst Fri Nov 26 09:49:15 2010
@@ -48,6 +48,13 @@
``modules.keys()`` only lists the imported modules.)
+.. function:: call_tracing(func, args)
+
+ Call ``func(*args)``, while tracing is enabled. The tracing state is saved,
+ and restored afterwards. This is intended to be called from a debugger from
+ a checkpoint, to recursively debug some other code.
+
+
.. data:: copyright
A string containing the copyright pertaining to the Python interpreter.
@@ -173,19 +180,25 @@
Exit from Python. This is implemented by raising the :exc:`SystemExit`
exception, so cleanup actions specified by finally clauses of :keyword:`try`
- statements are honored, and it is possible to intercept the exit attempt at an
- outer level. The optional argument *arg* can be an integer giving the exit
- status (defaulting to zero), or another type of object. If it is an integer,
- zero is considered "successful termination" and any nonzero value is considered
- "abnormal termination" by shells and the like. Most systems require it to be in
- the range 0-127, and produce undefined results otherwise. Some systems have a
- convention for assigning specific meanings to specific exit codes, but these are
- generally underdeveloped; Unix programs generally use 2 for command line syntax
- errors and 1 for all other kind of errors. If another type of object is passed,
- ``None`` is equivalent to passing zero, and any other object is printed to
- ``sys.stderr`` and results in an exit code of 1. In particular,
- ``sys.exit("some error message")`` is a quick way to exit a program when an
- error occurs.
+ statements are honored, and it is possible to intercept the exit attempt at
+ an outer level.
+
+ The optional argument *arg* can be an integer giving the exit status
+ (defaulting to zero), or another type of object. If it is an integer, zero
+ is considered "successful termination" and any nonzero value is considered
+ "abnormal termination" by shells and the like. Most systems require it to be
+ in the range 0-127, and produce undefined results otherwise. Some systems
+ have a convention for assigning specific meanings to specific exit codes, but
+ these are generally underdeveloped; Unix programs generally use 2 for command
+ line syntax errors and 1 for all other kind of errors. If another type of
+ object is passed, ``None`` is equivalent to passing zero, and any other
+ object is printed to :data:`stderr` and results in an exit code of 1. In
+ particular, ``sys.exit("some error message")`` is a quick way to exit a
+ program when an error occurs.
+
+ Since :func:`exit` ultimately "only" raises an exception, it will only exit
+ the process when called from the main thread, and the exception is not
+ intercepted.
.. data:: flags
Modified: python/branches/release31-maint/Doc/library/token.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/token.rst (original)
+++ python/branches/release31-maint/Doc/library/token.rst Fri Nov 26 09:49:15 2010
@@ -12,8 +12,8 @@
the language grammar. The specific numeric values which the names map to may
change between Python versions.
-This module also provides one data object and some functions. The functions
-mirror definitions in the Python C header files.
+The module also provides a mapping from numeric codes to names and some
+functions. The functions mirror definitions in the Python C header files.
.. data:: tok_name
@@ -38,6 +38,65 @@
Return true if *x* is the marker indicating the end of input.
+The token constants are:
+
+.. data:: ENDMARKER
+ NAME
+ NUMBER
+ STRING
+ NEWLINE
+ INDENT
+ DEDENT
+ LPAR
+ RPAR
+ LSQB
+ RSQB
+ COLON
+ COMMA
+ SEMI
+ PLUS
+ MINUS
+ STAR
+ SLASH
+ VBAR
+ AMPER
+ LESS
+ GREATER
+ EQUAL
+ DOT
+ PERCENT
+ BACKQUOTE
+ LBRACE
+ RBRACE
+ EQEQUAL
+ NOTEQUAL
+ LESSEQUAL
+ GREATEREQUAL
+ TILDE
+ CIRCUMFLEX
+ LEFTSHIFT
+ RIGHTSHIFT
+ DOUBLESTAR
+ PLUSEQUAL
+ MINEQUAL
+ STAREQUAL
+ SLASHEQUAL
+ PERCENTEQUAL
+ AMPEREQUAL
+ VBAREQUAL
+ CIRCUMFLEXEQUAL
+ LEFTSHIFTEQUAL
+ RIGHTSHIFTEQUAL
+ DOUBLESTAREQUAL
+ DOUBLESLASH
+ DOUBLESLASHEQUAL
+ AT
+ OP
+ ERRORTOKEN
+ N_TOKENS
+ NT_OFFSET
+
+
.. seealso::
Module :mod:`parser`
Modified: python/branches/release31-maint/Doc/reference/compound_stmts.rst
==============================================================================
--- python/branches/release31-maint/Doc/reference/compound_stmts.rst (original)
+++ python/branches/release31-maint/Doc/reference/compound_stmts.rst Fri Nov 26 09:49:15 2010
@@ -553,10 +553,9 @@
.. productionlist::
classdef: [`decorators`] "class" `classname` [`inheritance`] ":" `suite`
- inheritance: "(" [`argument_list` [","] ] ")"
+ inheritance: "(" [`argument_list` [","] | `comprehension`] ")"
classname: `identifier`
-
A class definition is an executable statement. The inheritance list usually
gives a list of base classes (see :ref:`metaclasses` for more advanced uses), so
each item in the list should evaluate to a class object which allows
@@ -582,7 +581,7 @@
Class creation can be customized heavily using :ref:`metaclasses <metaclasses>`.
-Classes can also be decorated; as with functions, ::
+Classes can also be decorated: just like when decorating functions, ::
@f1(arg)
@f2
@@ -593,6 +592,10 @@
class Foo: pass
Foo = f1(arg)(f2(Foo))
+The evaluation rules for the decorator expressions are the same as for function
+decorators. The result must be a class object, which is then bound to the class
+name.
+
**Programmer's note:** Variables defined in the class definition are class
attributes; they are shared by instances. Instance attributes can be set in a
method with ``self.name = value``. Both class and instance attributes are
Modified: python/branches/release31-maint/Doc/tutorial/classes.rst
==============================================================================
--- python/branches/release31-maint/Doc/tutorial/classes.rst (original)
+++ python/branches/release31-maint/Doc/tutorial/classes.rst Fri Nov 26 09:49:15 2010
@@ -4,26 +4,26 @@
Classes
*******
-Python's class mechanism adds classes to the language with a minimum of new
-syntax and semantics. It is a mixture of the class mechanisms found in C++ and
-Modula-3. As is true for modules, classes in Python do not put an absolute
-barrier between definition and user, but rather rely on the politeness of the
-user not to "break into the definition." The most important features of classes
-are retained with full power, however: the class inheritance mechanism allows
+Compared with other programming languages, Python's class mechanism adds classes
+with a minimum of new syntax and semantics. It is a mixture of the class
+mechanisms found in C++ and Modula-3. Python classes provide all the standard
+features of Object Oriented Programming: the class inheritance mechanism allows
multiple base classes, a derived class can override any methods of its base
class or classes, and a method can call the method of a base class with the same
-name. Objects can contain an arbitrary amount of data.
+name. Objects can contain arbitrary amounts and kinds of data. As is true for
+modules, classes partake of the dynamic nature of Python: they are created at
+runtime, and can be modified further after creation.
In C++ terminology, normally class members (including the data members) are
-*public* (except see below :ref:`tut-private`),
-and all member functions are *virtual*. As in Modula-3, there are no shorthands
-for referencing the object's members from its methods: the method function is
-declared with an explicit first argument representing the object, which is
-provided implicitly by the call. As in Smalltalk, classes themselves are
-objects. This provides semantics for importing and renaming. Unlike C++ and
-Modula-3, built-in types can be used as base classes for extension by the user.
-Also, like in C++, most built-in operators with special syntax (arithmetic
-operators, subscripting etc.) can be redefined for class instances.
+*public* (except see below :ref:`tut-private`), and all member functions are
+*virtual*. As in Modula-3, there are no shorthands for referencing the object's
+members from its methods: the method function is declared with an explicit first
+argument representing the object, which is provided implicitly by the call. As
+in Smalltalk, classes themselves are objects. This provides semantics for
+importing and renaming. Unlike C++ and Modula-3, built-in types can be used as
+base classes for extension by the user. Also, like in C++, most built-in
+operators with special syntax (arithmetic operators, subscripting etc.) can be
+redefined for class instances.
(Lacking universally accepted terminology to talk about classes, I will make
occasional use of Smalltalk and C++ terms. I would use Modula-3 terms, since
Modified: python/branches/release31-maint/Doc/using/windows.rst
==============================================================================
--- python/branches/release31-maint/Doc/using/windows.rst (original)
+++ python/branches/release31-maint/Doc/using/windows.rst Fri Nov 26 09:49:15 2010
@@ -156,23 +156,48 @@
:file:`C:\\Python\\Lib\\` and third-party modules should be stored in
:file:`C:\\Python\\Lib\\site-packages\\`.
-.. `` this fixes syntax highlighting errors in some editors due to the \\ hackery
+This is how :data:`sys.path` is populated on Windows:
-You can add folders to your search path to make Python's import mechanism search
-in these directories as well. Use :envvar:`PYTHONPATH`, as described in
-:ref:`using-on-envvars`, to modify :data:`sys.path`. On Windows, paths are
-separated by semicolons, though, to distinguish them from drive identifiers
-(:file:`C:\\` etc.).
-
-.. ``
-
-Modifying the module search path can also be done through the Windows registry
-under the key :file:`HKLM\\SOFTWARE\\Python\\PythonCore\\{version}\\PythonPath`.
-Subkeys which have semicolon-delimited path strings as their default value will
-cause each path to be searched. Multiple subkeys can be created and are
-appended to the path in alphabetical order. A convenient registry editor is
-:program:`regedit` (start it by typing "regedit" into :menuselection:`Start -->
-Run`).
+* An empty entry is added at the start, which corresponds to the current
+ directory.
+
+* If the environment variable :envvar:`PYTHONPATH` exists, as described in
+ :ref:`using-on-envvars`, its entries are added next. Note that on Windows,
+ paths in this variable must be separated by semicolons, to distinguish them
+ from the colon used in drive identifiers (``C:\`` etc.).
+
+* Additional "application paths" can be added in the registry as subkeys of
+ :samp:`\\SOFTWARE\\Python\\PythonCore\\{version}\\PythonPath` under both the
+ ``HKEY_CURRENT_USER`` and ``HKEY_LOCAL_MACHINE`` hives. Subkeys which have
+ semicolon-delimited path strings as their default value will cause each path
+ to be added to :data:`sys.path`. (Note that all known installers only use
+ HKLM, so HKCU is typically empty.)
+
+* If the environment variable :envvar:`PYTHONHOME` is set, it is assumed as
+ "Python Home". Otherwise, the path of the main Python executable is used to
+ locate a "landmark file" (``Lib\os.py``) to deduce the "Python Home". If a
+ Python home is found, the relevant sub-directories added to :data:`sys.path`
+ (``Lib``, ``plat-win``, etc) are based on that folder. Otherwise, the core
+ Python path is constructed from the PythonPath stored in the registry.
+
+* If the Python Home cannot be located, no :envvar:`PYTHONPATH` is specified in
+ the environment, and no registry entries can be found, a default path with
+ relative entries is used (e.g. ``.\Lib;.\plat-win``, etc).
+
+The end result of all this is:
+
+* When running :file:`python.exe`, or any other .exe in the main Python
+ directory (either an installed version, or directly from the PCbuild
+ directory), the core path is deduced, and the core paths in the registry are
+ ignored. Other "application paths" in the registry are always read.
+
+* When Python is hosted in another .exe (different directory, embedded via COM,
+ etc), the "Python Home" will not be deduced, so the core path from the
+ registry is used. Other "application paths" in the registry are always read.
+
+* If Python can't find its home and there is no registry (eg, frozen .exe, some
+ very strange installation setup) you get a path with some default, but
+ relative, paths.
Executing scripts
1
0
Author: georg.brandl
Date: Fri Nov 26 09:44:18 2010
New Revision: 86782
Log:
Blocked revisions 85287,85354-85355,85357,85375,85456-85458,85526,85528,85531,85535,85577,85604 via svnmerge
........
r85287 | georg.brandl | 2010-10-06 14:29:49 +0200 (Mi, 06 Okt 2010) | 1 line
Update to Sphin 1.0.4.
........
r85354 | georg.brandl | 2010-10-10 11:37:51 +0200 (So, 10 Okt 2010) | 1 line
Update pydoc topics.
........
r85355 | georg.brandl | 2010-10-10 11:40:34 +0200 (So, 10 Okt 2010) | 1 line
Bump to 3.2a3.
........
r85357 | georg.brandl | 2010-10-10 11:49:21 +0200 (So, 10 Okt 2010) | 1 line
Rewrap.
........
r85375 | georg.brandl | 2010-10-12 14:38:48 +0200 (Di, 12 Okt 2010) | 1 line
Post-release bumps.
........
r85456 | georg.brandl | 2010-10-14 09:04:07 +0200 (Do, 14 Okt 2010) | 1 line
#9418: first step of moving private string methods to _string module.
........
r85457 | georg.brandl | 2010-10-14 09:14:31 +0200 (Do, 14 Okt 2010) | 1 line
#9964: fix pdb failure to import under -OO. Warn the user that help is simply not available in this case.
........
r85458 | georg.brandl | 2010-10-14 09:17:44 +0200 (Do, 14 Okt 2010) | 1 line
Remove unused imports.
........
r85526 | georg.brandl | 2010-10-15 16:46:48 +0200 (Fr, 15 Okt 2010) | 1 line
#5355: Provide mappings from Expat error numbers to string descriptions and backwards, in order to actually make it possible to analyze error codes provided by ExpatError.
........
r85528 | georg.brandl | 2010-10-15 17:25:23 +0200 (Fr, 15 Okt 2010) | 1 line
#5355 followup: add unit test for new dictionaries, and provide submodules from xml.parsers.expat as advertised.
........
r85531 | georg.brandl | 2010-10-15 17:57:45 +0200 (Fr, 15 Okt 2010) | 1 line
#2830: add html.escape() helper and move cgi.escape() uses in the standard library to it. It defaults to quote=True and also escapes single quotes, which makes casual use safer. The cgi.escape() interface is not touched, but emits a (silent) PendingDeprecationWarning.
........
r85535 | georg.brandl | 2010-10-15 18:23:54 +0200 (Fr, 15 Okt 2010) | 1 line
Remove unused label.
........
r85577 | georg.brandl | 2010-10-16 22:33:11 +0200 (Sa, 16 Okt 2010) | 1 line
Get rid of a "unused static function" warning.
........
r85604 | georg.brandl | 2010-10-17 08:21:59 +0200 (So, 17 Okt 2010) | 1 line
Note that maxtasksperchild is new in 3.2.
........
Modified:
python/branches/release31-maint/ (props changed)
1
0
Nov. 26, 2010
Author: georg.brandl
Date: Fri Nov 26 09:42:45 2010
New Revision: 86781
Log:
Merged revisions 85530,85532-85534,85538-85543,85546-85548 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r85530 | georg.brandl | 2010-10-15 17:32:05 +0200 (Fr, 15 Okt 2010) | 1 line
Refrain from using inline suites.
........
r85532 | georg.brandl | 2010-10-15 18:03:02 +0200 (Fr, 15 Okt 2010) | 1 line
#7771: reference to documentation of dictview methods and operations.
........
r85533 | georg.brandl | 2010-10-15 18:07:41 +0200 (Fr, 15 Okt 2010) | 1 line
#9683: remove broken dead code dealing with nested arguments removed from Py3k, and update the docs and docstrings accordingly.
........
r85534 | georg.brandl | 2010-10-15 18:19:43 +0200 (Fr, 15 Okt 2010) | 1 line
#9801: document how list and dict proxies created by Managers behave w.r.t. mutable items.
........
r85538 | georg.brandl | 2010-10-15 18:35:46 +0200 (Fr, 15 Okt 2010) | 1 line
#7303: add documentation for useful pkgutil functions and classes.
........
r85539 | georg.brandl | 2010-10-15 18:42:14 +0200 (Fr, 15 Okt 2010) | 1 line
Fix issue references.
........
r85540 | georg.brandl | 2010-10-15 18:42:37 +0200 (Fr, 15 Okt 2010) | 1 line
#6798: fix wrong docs for the arguments to several trace events.
........
r85541 | georg.brandl | 2010-10-15 18:53:24 +0200 (Fr, 15 Okt 2010) | 1 line
#4968: updates to inspect.is* function docs.
........
r85542 | georg.brandl | 2010-10-15 19:01:15 +0200 (Fr, 15 Okt 2010) | 1 line
#7790: move table of struct_time members to the actual description of struct_time.
........
r85543 | georg.brandl | 2010-10-15 19:03:02 +0200 (Fr, 15 Okt 2010) | 1 line
#4785: document strict argument of JSONDecoder, plus add object_pairs_hook in the docstrings.
........
r85546 | georg.brandl | 2010-10-15 19:58:45 +0200 (Fr, 15 Okt 2010) | 1 line
#5762: fix handling of empty namespace in minidom, which would result in AttributeError on toxml().
........
r85547 | georg.brandl | 2010-10-15 20:00:35 +0200 (Fr, 15 Okt 2010) | 1 line
#6098: Refrain from claiming DOM level 3 conformance in minidom.
........
r85548 | georg.brandl | 2010-10-15 21:46:19 +0200 (Fr, 15 Okt 2010) | 1 line
#10072: assume a bit less knowledge of the FTP protocol in the ftplib docs.
........
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Doc/c-api/init.rst
python/branches/release31-maint/Doc/library/ftplib.rst
python/branches/release31-maint/Doc/library/inspect.rst
python/branches/release31-maint/Doc/library/json.rst
python/branches/release31-maint/Doc/library/multiprocessing.rst
python/branches/release31-maint/Doc/library/pkgutil.rst
python/branches/release31-maint/Doc/library/stdtypes.rst
python/branches/release31-maint/Doc/library/sys.rst
python/branches/release31-maint/Doc/library/time.rst
python/branches/release31-maint/Doc/tutorial/controlflow.rst
python/branches/release31-maint/Lib/inspect.py
python/branches/release31-maint/Lib/json/__init__.py
python/branches/release31-maint/Lib/json/decoder.py
python/branches/release31-maint/Lib/test/test_minidom.py
python/branches/release31-maint/Lib/xml/dom/minidom.py
python/branches/release31-maint/Misc/NEWS
Modified: python/branches/release31-maint/Doc/c-api/init.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/init.rst (original)
+++ python/branches/release31-maint/Doc/c-api/init.rst Fri Nov 26 09:42:45 2010
@@ -908,13 +908,14 @@
+------------------------------+--------------------------------------+
| :const:`PyTrace_LINE` | Always *NULL*. |
+------------------------------+--------------------------------------+
- | :const:`PyTrace_RETURN` | Value being returned to the caller. |
+ | :const:`PyTrace_RETURN` | Value being returned to the caller, |
+ | | or *NULL* if caused by an exception. |
+------------------------------+--------------------------------------+
- | :const:`PyTrace_C_CALL` | Name of function being called. |
+ | :const:`PyTrace_C_CALL` | Function object being called. |
+------------------------------+--------------------------------------+
- | :const:`PyTrace_C_EXCEPTION` | Always *NULL*. |
+ | :const:`PyTrace_C_EXCEPTION` | Function object being called. |
+------------------------------+--------------------------------------+
- | :const:`PyTrace_C_RETURN` | Always *NULL*. |
+ | :const:`PyTrace_C_RETURN` | Function object being called. |
+------------------------------+--------------------------------------+
Modified: python/branches/release31-maint/Doc/library/ftplib.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/ftplib.rst (original)
+++ python/branches/release31-maint/Doc/library/ftplib.rst Fri Nov 26 09:42:45 2010
@@ -54,18 +54,21 @@
.. exception:: error_temp
- Exception raised when an error code in the range 400--499 is received.
+ Exception raised when an error code signifying a temporary error (response
+ codes in the range 400--499) is received.
.. exception:: error_perm
- Exception raised when an error code in the range 500--599 is received.
+ Exception raised when an error code signifying a permanent error (response
+ codes in the range 500--599) is received.
.. exception:: error_proto
- Exception raised when a reply is received from the server that does not begin
- with a digit in the range 1--5.
+ Exception raised when a reply is received from the server that does not fit
+ the response specifications of the File Transfer Protocol, i.e. begin with a
+ digit in the range 1--5.
.. data:: all_errors
@@ -158,9 +161,9 @@
.. method:: FTP.voidcmd(cmd)
- Send a simple command string to the server and handle the response. Return
- nothing if a response code in the range 200--299 is received. Raise an exception
- otherwise.
+ Send a simple command string to the server and handle the response. Return
+ nothing if a response code corresponding to success (codes in the range
+ 200--299) is received. Raise :exc:`error_reply` otherwise.
.. method:: FTP.retrbinary(cmd, callback, blocksize=8192, rest=None)
@@ -177,12 +180,15 @@
.. method:: FTP.retrlines(cmd, callback=None)
- Retrieve a file or directory listing in ASCII transfer mode. *cmd*
- should be an appropriate ``RETR`` command (see :meth:`retrbinary`) or a
- command such as ``LIST``, ``NLST`` or ``MLSD`` (usually just the string
- ``'LIST'``). The *callback* function is called for each line with a
- string argument containing the line with the trailing CRLF stripped.
- The default *callback* prints the line to ``sys.stdout``.
+ Retrieve a file or directory listing in ASCII transfer mode. *cmd* should be
+ an appropriate ``RETR`` command (see :meth:`retrbinary`) or a command such as
+ ``LIST``, ``NLST`` or ``MLSD`` (usually just the string ``'LIST'``).
+ ``LIST`` retrieves a list of files and information about those files.
+ ``NLST`` retrieves a list of file names. On some servers, ``MLSD`` retrieves
+ a machine readable list of files and information about those files. The
+ *callback* function is called for each line with a string argument containing
+ the line with the trailing CRLF stripped. The default *callback* prints the
+ line to ``sys.stdout``.
.. method:: FTP.set_pasv(boolean)
@@ -240,10 +246,10 @@
.. method:: FTP.nlst(argument[, ...])
- Return a list of files as returned by the ``NLST`` command. The optional
- *argument* is a directory to list (default is the current server directory).
- Multiple arguments can be used to pass non-standard options to the ``NLST``
- command.
+ Return a list of file names as returned by the ``NLST`` command. The
+ optional *argument* is a directory to list (default is the current server
+ directory). Multiple arguments can be used to pass non-standard options to
+ the ``NLST`` command.
.. method:: FTP.dir(argument[, ...])
Modified: python/branches/release31-maint/Doc/library/inspect.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/inspect.rst (original)
+++ python/branches/release31-maint/Doc/library/inspect.rst Fri Nov 26 09:42:45 2010
@@ -204,18 +204,19 @@
.. function:: isclass(object)
- Return true if the object is a class.
+ Return true if the object is a class, whether built-in or created in Python
+ code.
.. function:: ismethod(object)
- Return true if the object is a method.
+ Return true if the object is a bound method written in Python.
.. function:: isfunction(object)
- Return true if the object is a Python function or unnamed (:term:`lambda`)
- function.
+ Return true if the object is a Python function, which includes functions
+ created by a :term:`lambda` expression.
.. function:: isgeneratorfunction(object)
@@ -245,13 +246,14 @@
.. function:: isbuiltin(object)
- Return true if the object is a built-in function.
+ Return true if the object is a built-in function or a bound built-in method.
.. function:: isroutine(object)
Return true if the object is a user-defined or built-in function or method.
+
.. function:: isabstract(object)
Return true if the object is an abstract base class.
@@ -259,8 +261,9 @@
.. function:: ismethoddescriptor(object)
- Return true if the object is a method descriptor, but not if :func:`ismethod`
- or :func:`isclass` or :func:`isfunction` are true.
+ Return true if the object is a method descriptor, but not if
+ :func:`ismethod`, :func:`isclass`, :func:`isfunction` or :func:`isbuiltin`
+ are true.
This, for example, is true of ``int.__add__``. An object passing this test
has a :attr:`__get__` attribute but not a :attr:`__set__` attribute, but
@@ -422,19 +425,19 @@
Get information about arguments passed into a particular frame. A
:term:`named tuple` ``ArgInfo(args, varargs, keywords, locals)`` is
- returned. *args* is a list of the argument names (it may contain nested
- lists). *varargs* and *varkw* are the names of the ``*`` and ``**`` arguments
- or ``None``. *locals* is the locals dictionary of the given frame.
+ returned. *args* is a list of the argument names. *varargs* and *varkw* are
+ the names of the ``*`` and ``**`` arguments or ``None``. *locals* is the
+ locals dictionary of the given frame.
-.. function:: formatargspec(args[, varargs, varkw, defaults, formatarg, formatvarargs, formatvarkw, formatvalue, join])
+.. function:: formatargspec(args[, varargs, varkw, defaults, formatarg, formatvarargs, formatvarkw, formatvalue])
Format a pretty argument spec from the four values returned by
:func:`getargspec`. The format\* arguments are the corresponding optional
formatting functions that are called to turn names and values into strings.
-.. function:: formatargvalues(args[, varargs, varkw, locals, formatarg, formatvarargs, formatvarkw, formatvalue, join])
+.. function:: formatargvalues(args[, varargs, varkw, locals, formatarg, formatvarargs, formatvarkw, formatvalue])
Format a pretty argument spec from the four values returned by
:func:`getargvalues`. The format\* arguments are the corresponding optional
Modified: python/branches/release31-maint/Doc/library/json.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/json.rst (original)
+++ python/branches/release31-maint/Doc/library/json.rst Fri Nov 26 09:42:45 2010
@@ -149,7 +149,7 @@
To use a custom :class:`JSONEncoder` subclass (e.g. one that overrides the
:meth:`default` method to serialize additional types), specify it with the
- *cls* kwarg.
+ *cls* kwarg; otherwise :class:`JSONEncoder` is used.
.. function:: dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, **kw)
@@ -195,8 +195,8 @@
are encountered.
To use a custom :class:`JSONDecoder` subclass, specify it with the ``cls``
- kwarg. Additional keyword arguments will be passed to the constructor of the
- class.
+ kwarg; otherwise :class:`JSONDecoder` is used. Additional keyword arguments
+ will be passed to the constructor of the class.
.. function:: loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
@@ -275,6 +275,11 @@
``'false'``. This can be used to raise an exception if invalid JSON numbers
are encountered.
+ If *strict* is ``False`` (``True`` is the default), then control characters
+ will be allowed inside strings. Control characters in this context are
+ those with character codes in the 0-31 range, including ``'\t'`` (tab),
+ ``'\n'``, ``'\r'`` and ``'\0'``.
+
.. method:: decode(s)
Modified: python/branches/release31-maint/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/multiprocessing.rst (original)
+++ python/branches/release31-maint/Doc/library/multiprocessing.rst Fri Nov 26 09:42:45 2010
@@ -1288,6 +1288,24 @@
Create a shared ``list`` object and return a proxy for it.
+ .. note::
+
+ Modifications to mutable values or items in dict and list proxies will not
+ be propagated through the manager, because the proxy has no way of knowing
+ when its values or items are modified. To modify such an item, you can
+ re-assign the modified object to the container proxy::
+
+ # create a list proxy and append a mutable object (a dictionary)
+ lproxy = manager.list()
+ lproxy.append({})
+ # now mutate the dictionary
+ d = lproxy[0]
+ d['a'] = 1
+ d['b'] = 2
+ # at this point, the changes to d are not yet synced, but by
+ # reassigning the dictionary, the proxy is notified of the change
+ lproxy[0] = d
+
Namespace objects
>>>>>>>>>>>>>>>>>
Modified: python/branches/release31-maint/Doc/library/pkgutil.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/pkgutil.rst (original)
+++ python/branches/release31-maint/Doc/library/pkgutil.rst Fri Nov 26 09:42:45 2010
@@ -3,40 +3,166 @@
============================================
.. module:: pkgutil
- :synopsis: Utilities to support extension of packages.
+ :synopsis: Utilities for the import system.
-
-This module provides functions to manipulate packages:
+This module provides utilities for the import system, in particular package
+support.
.. function:: extend_path(path, name)
- Extend the search path for the modules which comprise a package. Intended use is
- to place the following code in a package's :file:`__init__.py`::
+ Extend the search path for the modules which comprise a package. Intended
+ use is to place the following code in a package's :file:`__init__.py`::
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
- This will add to the package's ``__path__`` all subdirectories of directories on
- ``sys.path`` named after the package. This is useful if one wants to distribute
- different parts of a single logical package as multiple directories.
-
- It also looks for :file:`\*.pkg` files beginning where ``*`` matches the *name*
- argument. This feature is similar to :file:`\*.pth` files (see the :mod:`site`
- module for more information), except that it doesn't special-case lines starting
- with ``import``. A :file:`\*.pkg` file is trusted at face value: apart from
- checking for duplicates, all entries found in a :file:`\*.pkg` file are added to
- the path, regardless of whether they exist on the filesystem. (This is a
- feature.)
+ This will add to the package's ``__path__`` all subdirectories of directories
+ on ``sys.path`` named after the package. This is useful if one wants to
+ distribute different parts of a single logical package as multiple
+ directories.
+
+ It also looks for :file:`\*.pkg` files beginning where ``*`` matches the
+ *name* argument. This feature is similar to :file:`\*.pth` files (see the
+ :mod:`site` module for more information), except that it doesn't special-case
+ lines starting with ``import``. A :file:`\*.pkg` file is trusted at face
+ value: apart from checking for duplicates, all entries found in a
+ :file:`\*.pkg` file are added to the path, regardless of whether they exist
+ on the filesystem. (This is a feature.)
If the input path is not a list (as is the case for frozen packages) it is
returned unchanged. The input path is not modified; an extended copy is
returned. Items are only appended to the copy at the end.
- It is assumed that ``sys.path`` is a sequence. Items of ``sys.path`` that are
- not strings referring to existing directories are ignored. Unicode items on
- ``sys.path`` that cause errors when used as filenames may cause this function
- to raise an exception (in line with :func:`os.path.isdir` behavior).
+ It is assumed that :data:`sys.path` is a sequence. Items of :data:`sys.path`
+ that are not strings referring to existing directories are ignored. Unicode
+ items on :data:`sys.path` that cause errors when used as filenames may cause
+ this function to raise an exception (in line with :func:`os.path.isdir`
+ behavior).
+
+
+.. class:: ImpImporter(dirname=None)
+
+ :pep:`302` Importer that wraps Python's "classic" import algorithm.
+
+ If *dirname* is a string, a :pep:`302` importer is created that searches that
+ directory. If *dirname* is ``None``, a :pep:`302` importer is created that
+ searches the current :data:`sys.path`, plus any modules that are frozen or
+ built-in.
+
+ Note that :class:`ImpImporter` does not currently support being used by
+ placement on :data:`sys.meta_path`.
+
+
+.. class:: ImpLoader(fullname, file, filename, etc)
+
+ :pep:`302` Loader that wraps Python's "classic" import algorithm.
+
+
+.. function:: find_loader(fullname)
+
+ Find a :pep:`302` "loader" object for *fullname*.
+
+ If *fullname* contains dots, path must be the containing package's
+ ``__path__``. Returns ``None`` if the module cannot be found or imported.
+ This function uses :func:`iter_importers`, and is thus subject to the same
+ limitations regarding platform-specific special import locations such as the
+ Windows registry.
+
+
+.. function:: get_importer(path_item)
+
+ Retrieve a :pep:`302` importer for the given *path_item*.
+
+ The returned importer is cached in :data:`sys.path_importer_cache` if it was
+ newly created by a path hook.
+
+ If there is no importer, a wrapper around the basic import machinery is
+ returned. This wrapper is never inserted into the importer cache (None is
+ inserted instead).
+
+ The cache (or part of it) can be cleared manually if a rescan of
+ :data:`sys.path_hooks` is necessary.
+
+
+.. function:: get_loader(module_or_name)
+
+ Get a :pep:`302` "loader" object for *module_or_name*.
+
+ If the module or package is accessible via the normal import mechanism, a
+ wrapper around the relevant part of that machinery is returned. Returns
+ ``None`` if the module cannot be found or imported. If the named module is
+ not already imported, its containing package (if any) is imported, in order
+ to establish the package ``__path__``.
+
+ This function uses :func:`iter_importers`, and is thus subject to the same
+ limitations regarding platform-specific special import locations such as the
+ Windows registry.
+
+
+.. function:: iter_importers(fullname='')
+
+ Yield :pep:`302` importers for the given module name.
+
+ If fullname contains a '.', the importers will be for the package containing
+ fullname, otherwise they will be importers for :data:`sys.meta_path`,
+ :data:`sys.path`, and Python's "classic" import machinery, in that order. If
+ the named module is in a package, that package is imported as a side effect
+ of invoking this function.
+
+ Non-:pep:`302` mechanisms (e.g. the Windows registry) used by the standard
+ import machinery to find files in alternative locations are partially
+ supported, but are searched *after* :data:`sys.path`. Normally, these
+ locations are searched *before* :data:`sys.path`, preventing :data:`sys.path`
+ entries from shadowing them.
+
+ For this to cause a visible difference in behaviour, there must be a module
+ or package name that is accessible via both :data:`sys.path` and one of the
+ non-:pep:`302` file system mechanisms. In this case, the emulation will find
+ the former version, while the builtin import mechanism will find the latter.
+
+ Items of the following types can be affected by this discrepancy:
+ ``imp.C_EXTENSION``, ``imp.PY_SOURCE``, ``imp.PY_COMPILED``,
+ ``imp.PKG_DIRECTORY``.
+
+
+.. function:: iter_modules(path=None, prefix='')
+
+ Yields ``(module_loader, name, ispkg)`` for all submodules on *path*, or, if
+ path is ``None``, all top-level modules on ``sys.path``.
+
+ *path* should be either ``None`` or a list of paths to look for modules in.
+
+ *prefix* is a string to output on the front of every module name on output.
+
+
+.. function:: walk_packages(path=None, prefix='', onerror=None)
+
+ Yields ``(module_loader, name, ispkg)`` for all modules recursively on
+ *path*, or, if path is ``None``, all accessible modules.
+
+ *path* should be either ``None`` or a list of paths to look for modules in.
+
+ *prefix* is a string to output on the front of every module name on output.
+
+ Note that this function must import all *packages* (*not* all modules!) on
+ the given *path*, in order to access the ``__path__`` attribute to find
+ submodules.
+
+ *onerror* is a function which gets called with one argument (the name of the
+ package which was being imported) if any exception occurs while trying to
+ import a package. If no *onerror* function is supplied, :exc:`ImportError`\s
+ are caught and ignored, while all other exceptions are propagated,
+ terminating the search.
+
+ Examples::
+
+ # list all modules python can access
+ walk_packages()
+
+ # list all submodules of ctypes
+ walk_packages(ctypes.__path__, ctypes.__name__ + '.')
+
.. function:: get_data(package, resource)
@@ -48,14 +174,14 @@
filename, using ``/`` as the path separator. The parent directory name
``..`` is not allowed, and nor is a rooted name (starting with a ``/``).
- The function returns a binary string that is the contents of the
- specified resource.
+ The function returns a binary string that is the contents of the specified
+ resource.
For packages located in the filesystem, which have already been imported,
this is the rough equivalent of::
- d = os.path.dirname(sys.modules[package].__file__)
- data = open(os.path.join(d, resource), 'rb').read()
+ d = os.path.dirname(sys.modules[package].__file__)
+ data = open(os.path.join(d, resource), 'rb').read()
If the package cannot be located or loaded, or it uses a PEP 302 loader
- which does not support :func:`get_data`, then None is returned.
+ which does not support :func:`get_data`, then ``None`` is returned.
Modified: python/branches/release31-maint/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/stdtypes.rst (original)
+++ python/branches/release31-maint/Doc/library/stdtypes.rst Fri Nov 26 09:42:45 2010
@@ -2038,28 +2038,11 @@
Keys views are set-like since their entries are unique and hashable. If all
-values are hashable, so that (key, value) pairs are unique and hashable, then
-the items view is also set-like. (Values views are not treated as set-like
-since the entries are generally not unique.) Then these set operations are
-available ("other" refers either to another view or a set):
-
-.. describe:: dictview & other
-
- Return the intersection of the dictview and the other object as a new set.
-
-.. describe:: dictview | other
-
- Return the union of the dictview and the other object as a new set.
-
-.. describe:: dictview - other
-
- Return the difference between the dictview and the other object (all elements
- in *dictview* that aren't in *other*) as a new set.
-
-.. describe:: dictview ^ other
-
- Return the symmetric difference (all elements either in *dictview* or
- *other*, but not in both) of the dictview and the other object as a new set.
+values are hashable, so that ``(key, value)`` pairs are unique and hashable,
+then the items view is also set-like. (Values views are not treated as set-like
+since the entries are generally not unique.) For set-like views, all of the
+operations defined for the abstract base class :class:`collections.Set` are
+available (for example, ``==``, ``<``, or ``^``).
An example of dictionary view usage::
@@ -2090,6 +2073,8 @@
>>> # set operations
>>> keys & {'eggs', 'bacon', 'salad'}
{'bacon'}
+ >>> keys ^ {'sausage', 'juice'}
+ {'juice', 'eggs', 'bacon', 'spam'}
.. _typememoryview:
Modified: python/branches/release31-maint/Doc/library/sys.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/sys.rst (original)
+++ python/branches/release31-maint/Doc/library/sys.rst Fri Nov 26 09:42:45 2010
@@ -746,8 +746,9 @@
``'return'``
A function (or other code block) is about to return. The local trace
- function is called; *arg* is the value that will be returned. The trace
- function's return value is ignored.
+ function is called; *arg* is the value that will be returned, or ``None``
+ if the event is caused by an exception being raised. The trace function's
+ return value is ignored.
``'exception'``
An exception has occurred. The local trace function is called; *arg* is a
@@ -759,10 +760,10 @@
a built-in. *arg* is the C function object.
``'c_return'``
- A C function has returned. *arg* is ``None``.
+ A C function has returned. *arg* is the C function object.
``'c_exception'``
- A C function has raised an exception. *arg* is ``None``.
+ A C function has raised an exception. *arg* is the C function object.
Note that as an exception is propagated down the chain of callers, an
``'exception'`` event is generated at each level.
Modified: python/branches/release31-maint/Doc/library/time.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/time.rst (original)
+++ python/branches/release31-maint/Doc/library/time.rst Fri Nov 26 09:42:45 2010
@@ -16,21 +16,23 @@
An explanation of some terminology and conventions is in order.
- .. index:: single: epoch
+.. index:: single: epoch
* The :dfn:`epoch` is the point where the time starts. On January 1st of that
year, at 0 hours, the "time since the epoch" is zero. For Unix, the epoch is
1970. To find out what the epoch is, look at ``gmtime(0)``.
- .. index:: single: Year 2038
+.. index:: single: Year 2038
* The functions in this module do not handle dates and times before the epoch or
far in the future. The cut-off point in the future is determined by the C
library; for Unix, it is typically in 2038.
- .. index::
- single: Year 2000
- single: Y2K
+.. index::
+ single: Year 2000
+ single: Y2K
+
+.. _time-y2kissues:
* **Year 2000 (Y2K) issues**: Python depends on the platform's C library, which
generally doesn't have year 2000 issues, since all dates and times are
@@ -47,16 +49,16 @@
Note that this is new as of Python 1.5.2(a2); earlier versions, up to Python
1.5.1 and 1.5.2a1, would add 1900 to year values below 1900.
- .. index::
- single: UTC
- single: Coordinated Universal Time
- single: Greenwich Mean Time
+.. index::
+ single: UTC
+ single: Coordinated Universal Time
+ single: Greenwich Mean Time
* UTC is Coordinated Universal Time (formerly known as Greenwich Mean Time, or
GMT). The acronym UTC is not a mistake but a compromise between English and
French.
- .. index:: single: Daylight Saving Time
+.. index:: single: Daylight Saving Time
* DST is Daylight Saving Time, an adjustment of the timezone by (usually) one
hour during part of the year. DST rules are magic (determined by local law) and
@@ -81,37 +83,7 @@
:func:`gmtime`, :func:`localtime`, and :func:`strptime` also offer attribute
names for individual fields.
- +-------+------------------+------------------------------+
- | Index | Attribute | Values |
- +=======+==================+==============================+
- | 0 | :attr:`tm_year` | (for example, 1993) |
- +-------+------------------+------------------------------+
- | 1 | :attr:`tm_mon` | range [1,12] |
- +-------+------------------+------------------------------+
- | 2 | :attr:`tm_mday` | range [1,31] |
- +-------+------------------+------------------------------+
- | 3 | :attr:`tm_hour` | range [0,23] |
- +-------+------------------+------------------------------+
- | 4 | :attr:`tm_min` | range [0,59] |
- +-------+------------------+------------------------------+
- | 5 | :attr:`tm_sec` | range [0,61]; see **(1)** in |
- | | | :func:`strftime` description |
- +-------+------------------+------------------------------+
- | 6 | :attr:`tm_wday` | range [0,6], Monday is 0 |
- +-------+------------------+------------------------------+
- | 7 | :attr:`tm_yday` | range [1,366] |
- +-------+------------------+------------------------------+
- | 8 | :attr:`tm_isdst` | 0, 1 or -1; see below |
- +-------+------------------+------------------------------+
-
- Note that unlike the C structure, the month value is a range of 1-12, not 0-11.
- A year value will be handled as described under "Year 2000 (Y2K) issues" above.
- A ``-1`` argument as the daylight savings flag, passed to :func:`mktime` will
- usually result in the correct daylight savings state to be filled in.
-
- When a tuple with an incorrect length is passed to a function expecting a
- :class:`struct_time`, or having elements of the wrong type, a :exc:`TypeError`
- is raised.
+ See :class:`struct_time` for a description of these objects.
* Use the following functions to convert between time representations:
@@ -388,10 +360,45 @@
documented as supported.
-.. data:: struct_time
+.. class:: struct_time
The type of the time value sequence returned by :func:`gmtime`,
- :func:`localtime`, and :func:`strptime`.
+ :func:`localtime`, and :func:`strptime`. It is an object with a :term:`named
+ tuple` interface: values can be accessed by index and by attribute name. The
+ following values are present:
+
+ +-------+-------------------+---------------------------------+
+ | Index | Attribute | Values |
+ +=======+===================+=================================+
+ | 0 | :attr:`tm_year` | (for example, 1993) |
+ +-------+-------------------+---------------------------------+
+ | 1 | :attr:`tm_mon` | range [1, 12] |
+ +-------+-------------------+---------------------------------+
+ | 2 | :attr:`tm_mday` | range [1, 31] |
+ +-------+-------------------+---------------------------------+
+ | 3 | :attr:`tm_hour` | range [0, 23] |
+ +-------+-------------------+---------------------------------+
+ | 4 | :attr:`tm_min` | range [0, 59] |
+ +-------+-------------------+---------------------------------+
+ | 5 | :attr:`tm_sec` | range [0, 61]; see **(1)** in |
+ | | | :func:`strftime` description |
+ +-------+-------------------+---------------------------------+
+ | 6 | :attr:`tm_wday` | range [0, 6], Monday is 0 |
+ +-------+-------------------+---------------------------------+
+ | 7 | :attr:`tm_yday` | range [1, 366] |
+ +-------+-------------------+---------------------------------+
+ | 8 | :attr:`tm_isdst` | 0, 1 or -1; see below |
+ +-------+-------------------+---------------------------------+
+
+ Note that unlike the C structure, the month value is a range of [1, 12], not
+ [0, 11]. A year value will be handled as described under :ref:`Year 2000
+ (Y2K) issues <time-y2kissues>` above. A ``-1`` argument as the daylight
+ savings flag, passed to :func:`mktime` will usually result in the correct
+ daylight savings state to be filled in.
+
+ When a tuple with an incorrect length is passed to a function expecting a
+ :class:`struct_time`, or having elements of the wrong type, a
+ :exc:`TypeError` is raised.
.. function:: time()
Modified: python/branches/release31-maint/Doc/tutorial/controlflow.rst
==============================================================================
--- python/branches/release31-maint/Doc/tutorial/controlflow.rst (original)
+++ python/branches/release31-maint/Doc/tutorial/controlflow.rst Fri Nov 26 09:42:45 2010
@@ -458,10 +458,12 @@
def cheeseshop(kind, *arguments, **keywords):
print("-- Do you have any", kind, "?")
print("-- I'm sorry, we're all out of", kind)
- for arg in arguments: print(arg)
+ for arg in arguments:
+ print(arg)
print("-" * 40)
keys = sorted(keywords.keys())
- for kw in keys: print(kw, ":", keywords[kw])
+ for kw in keys:
+ print(kw, ":", keywords[kw])
It could be called like this::
Modified: python/branches/release31-maint/Lib/inspect.py
==============================================================================
--- python/branches/release31-maint/Lib/inspect.py (original)
+++ python/branches/release31-maint/Lib/inspect.py Fri Nov 26 09:42:45 2010
@@ -737,9 +737,9 @@
"""Get information about the arguments accepted by a code object.
Three things are returned: (args, varargs, varkw), where
- 'args' is the list of argument names, possibly containing nested
- lists. Keyword-only arguments are appended. 'varargs' and 'varkw'
- are the names of the * and ** arguments or None."""
+ 'args' is the list of argument names. Keyword-only arguments are
+ appended. 'varargs' and 'varkw' are the names of the * and **
+ arguments or None."""
args, varargs, kwonlyargs, varkw = _getfullargs(co)
return Arguments(args + kwonlyargs, varargs, varkw)
@@ -747,9 +747,8 @@
"""Get information about the arguments accepted by a code object.
Four things are returned: (args, varargs, kwonlyargs, varkw), where
- 'args' and 'kwonlyargs' are lists of argument names (with 'args'
- possibly containing nested lists), and 'varargs' and 'varkw' are the
- names of the * and ** arguments or None."""
+ 'args' and 'kwonlyargs' are lists of argument names, and 'varargs'
+ and 'varkw' are the names of the * and ** arguments or None."""
if not iscode(co):
raise TypeError('{!r} is not a code object'.format(co))
@@ -778,7 +777,7 @@
"""Get the names and default values of a function's arguments.
A tuple of four things is returned: (args, varargs, varkw, defaults).
- 'args' is a list of the argument names (it may contain nested lists).
+ 'args' is a list of the argument names.
'args' will include keyword-only argument names.
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'defaults' is an n-tuple of the default values of the last n arguments.
@@ -803,7 +802,7 @@
A tuple of seven things is returned:
(args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults annotations).
- 'args' is a list of the argument names (it may contain nested lists).
+ 'args' is a list of the argument names.
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'defaults' is an n-tuple of the default values of the last n arguments.
'kwonlyargs' is a list of keyword-only argument names.
@@ -827,25 +826,12 @@
"""Get information about arguments passed into a particular frame.
A tuple of four things is returned: (args, varargs, varkw, locals).
- 'args' is a list of the argument names (it may contain nested lists).
+ 'args' is a list of the argument names.
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'locals' is the locals dictionary of the given frame."""
args, varargs, varkw = getargs(frame.f_code)
return ArgInfo(args, varargs, varkw, frame.f_locals)
-def joinseq(seq):
- if len(seq) == 1:
- return '(' + seq[0] + ',)'
- else:
- return '(' + ', '.join(seq) + ')'
-
-def strseq(object, convert, join=joinseq):
- """Recursively walk a sequence, stringifying each element."""
- if type(object) in (list, tuple):
- return join(map(lambda o, c=convert, j=join: strseq(o, c, j), object))
- else:
- return convert(object)
-
def formatannotation(annotation, base_module=None):
if isinstance(annotation, type):
if annotation.__module__ in ('builtins', base_module):
@@ -866,8 +852,7 @@
formatvarkw=lambda name: '**' + name,
formatvalue=lambda value: '=' + repr(value),
formatreturns=lambda text: ' -> ' + text,
- formatannotation=formatannotation,
- join=joinseq):
+ formatannotation=formatannotation):
"""Format an argument spec from the values returned by getargspec
or getfullargspec.
@@ -885,7 +870,7 @@
if defaults:
firstdefault = len(args) - len(defaults)
for i, arg in enumerate(args):
- spec = strseq(arg, formatargandannotation, join)
+ spec = formatargandannotation(arg)
if defaults and i >= firstdefault:
spec = spec + formatvalue(defaults[i - firstdefault])
specs.append(spec)
@@ -911,8 +896,7 @@
formatarg=str,
formatvarargs=lambda name: '*' + name,
formatvarkw=lambda name: '**' + name,
- formatvalue=lambda value: '=' + repr(value),
- join=joinseq):
+ formatvalue=lambda value: '=' + repr(value)):
"""Format an argument spec from the 4 values returned by getargvalues.
The first four arguments are (args, varargs, varkw, locals). The
@@ -924,7 +908,7 @@
return formatarg(name) + formatvalue(locals[name])
specs = []
for i in range(len(args)):
- specs.append(strseq(args[i], convert, join))
+ specs.append(convert(args[i]))
if varargs:
specs.append(formatvarargs(varargs) + formatvalue(locals[varargs]))
if varkw:
Modified: python/branches/release31-maint/Lib/json/__init__.py
==============================================================================
--- python/branches/release31-maint/Lib/json/__init__.py (original)
+++ python/branches/release31-maint/Lib/json/__init__.py Fri Nov 26 09:42:45 2010
@@ -155,7 +155,7 @@
To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
``.default()`` method to serialize additional types), specify it with
- the ``cls`` kwarg.
+ the ``cls`` kwarg; otherwise ``JSONEncoder`` is used.
"""
# cached encoder
@@ -213,7 +213,7 @@
To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
``.default()`` method to serialize additional types), specify it with
- the ``cls`` kwarg.
+ the ``cls`` kwarg; otherwise ``JSONEncoder`` is used.
"""
# cached encoder
@@ -244,8 +244,16 @@
``object_hook`` will be used instead of the ``dict``. This feature
can be used to implement custom decoders (e.g. JSON-RPC class hinting).
+ ``object_pairs_hook`` is an optional function that will be called with the
+ result of any object literal decoded with an ordered list of pairs. The
+ return value of ``object_pairs_hook`` will be used instead of the ``dict``.
+ This feature can be used to implement custom decoders that rely on the
+ order that the key and value pairs are decoded (for example,
+ collections.OrderedDict will remember the order of insertion). If
+ ``object_hook`` is also defined, the ``object_pairs_hook`` takes priority.
+
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
- kwarg.
+ kwarg; otherwise ``JSONDecoder`` is used.
"""
return loads(fp.read(),
@@ -264,6 +272,14 @@
``object_hook`` will be used instead of the ``dict``. This feature
can be used to implement custom decoders (e.g. JSON-RPC class hinting).
+ ``object_pairs_hook`` is an optional function that will be called with the
+ result of any object literal decoded with an ordered list of pairs. The
+ return value of ``object_pairs_hook`` will be used instead of the ``dict``.
+ This feature can be used to implement custom decoders that rely on the
+ order that the key and value pairs are decoded (for example,
+ collections.OrderedDict will remember the order of insertion). If
+ ``object_hook`` is also defined, the ``object_pairs_hook`` takes priority.
+
``parse_float``, if specified, will be called with the string
of every JSON float to be decoded. By default this is equivalent to
float(num_str). This can be used to use another datatype or parser
@@ -280,7 +296,7 @@
are encountered.
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
- kwarg.
+ kwarg; otherwise ``JSONDecoder`` is used.
"""
if (cls is None and object_hook is None and
Modified: python/branches/release31-maint/Lib/json/decoder.py
==============================================================================
--- python/branches/release31-maint/Lib/json/decoder.py (original)
+++ python/branches/release31-maint/Lib/json/decoder.py Fri Nov 26 09:42:45 2010
@@ -289,6 +289,15 @@
place of the given ``dict``. This can be used to provide custom
deserializations (e.g. to support JSON-RPC class hinting).
+ ``object_pairs_hook``, if specified will be called with the result of
+ every JSON object decoded with an ordered list of pairs. The return
+ value of ``object_pairs_hook`` will be used instead of the ``dict``.
+ This feature can be used to implement custom decoders that rely on the
+ order that the key and value pairs are decoded (for example,
+ collections.OrderedDict will remember the order of insertion). If
+ ``object_hook`` is also defined, the ``object_pairs_hook`` takes
+ priority.
+
``parse_float``, if specified, will be called with the string
of every JSON float to be decoded. By default this is equivalent to
float(num_str). This can be used to use another datatype or parser
@@ -304,6 +313,11 @@
This can be used to raise an exception if invalid JSON numbers
are encountered.
+ If ``strict`` is false (true is the default), then control
+ characters will be allowed inside strings. Control characters in
+ this context are those with character codes in the 0-31 range,
+ including ``'\\t'`` (tab), ``'\\n'``, ``'\\r'`` and ``'\\0'``.
+
"""
self.object_hook = object_hook
self.parse_float = parse_float or float
Modified: python/branches/release31-maint/Lib/test/test_minidom.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_minidom.py (original)
+++ python/branches/release31-maint/Lib/test/test_minidom.py Fri Nov 26 09:42:45 2010
@@ -1479,6 +1479,13 @@
doc.appendChild(doc.createComment("foo--bar"))
self.assertRaises(ValueError, doc.toxml)
+ def testEmptyXMLNSValue(self):
+ doc = parseString("<element xmlns=''>\n"
+ "<foo/>\n</element>")
+ doc2 = parseString(doc.toxml())
+ self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)
+
+
def test_main():
run_unittest(MinidomTest)
Modified: python/branches/release31-maint/Lib/xml/dom/minidom.py
==============================================================================
--- python/branches/release31-maint/Lib/xml/dom/minidom.py (original)
+++ python/branches/release31-maint/Lib/xml/dom/minidom.py Fri Nov 26 09:42:45 2010
@@ -293,9 +293,10 @@
def _write_data(writer, data):
"Writes datachars to writer."
- data = data.replace("&", "&").replace("<", "<")
- data = data.replace("\"", """).replace(">", ">")
- writer.write(data)
+ if data:
+ data = data.replace("&", "&").replace("<", "<"). \
+ replace("\"", """).replace(">", ">")
+ writer.write(data)
def _get_elements_by_tagName_helper(parent, name, rc):
for node in parent.childNodes:
@@ -1358,11 +1359,9 @@
class DOMImplementation(DOMImplementationLS):
_features = [("core", "1.0"),
("core", "2.0"),
- ("core", "3.0"),
("core", None),
("xml", "1.0"),
("xml", "2.0"),
- ("xml", "3.0"),
("xml", None),
("ls-load", "3.0"),
("ls-load", None),
Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS (original)
+++ python/branches/release31-maint/Misc/NEWS Fri Nov 26 09:42:45 2010
@@ -18,6 +18,11 @@
- Issue #10459: Update CJK character names to Unicode 5.1.
+- Issue #6098: Don't claim DOM level 3 conformance in minidom.
+
+- Issue #5762: Fix AttributeError raised by ``xml.dom.minidom`` when an empty
+ XML namespace attribute is encountered.
+
- Issue #1710703: Write structures for an empty ZIP archive when a ZipFile is
created in modes 'a' or 'w' and then closed without adding any files. Raise
BadZipfile (rather than IOError) when opening small non-ZIP files.
1
0
r86780 - in python/branches/release31-maint: Doc/library/atexit.rst Doc/library/os.path.rst Doc/library/os.rst Doc/library/profile.rst Doc/library/zipfile.rst Lib/test/test_zipfile.py Lib/zipfile.py Misc/NEWS Tools/README
by georg.brandl Nov. 26, 2010
by georg.brandl Nov. 26, 2010
Nov. 26, 2010
Author: georg.brandl
Date: Fri Nov 26 09:37:46 2010
New Revision: 86780
Log:
Merged revisions 85450-85455,85460-85465 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r85450 | georg.brandl | 2010-10-14 08:35:53 +0200 (Do, 14 Okt 2010) | 1 line
#7642: update to os.system() docs.
........
r85451 | georg.brandl | 2010-10-14 08:41:42 +0200 (Do, 14 Okt 2010) | 1 line
#3865: add note about benchmarking with profilers, and move licensing stuff to bottom of document.
........
r85452 | georg.brandl | 2010-10-14 08:43:22 +0200 (Do, 14 Okt 2010) | 1 line
#10046: small correction to atexit docs.
........
r85453 | georg.brandl | 2010-10-14 08:46:08 +0200 (Do, 14 Okt 2010) | 1 line
#6825: small correction to split() docs.
........
r85454 | georg.brandl | 2010-10-14 08:48:47 +0200 (Do, 14 Okt 2010) | 1 line
Mention 2to3.
........
r85455 | georg.brandl | 2010-10-14 08:59:45 +0200 (Do, 14 Okt 2010) | 1 line
#1710703: write zipfile structures also in the case of closing a new, but empty, archive.
........
r85460 | georg.brandl | 2010-10-14 09:24:28 +0200 (Do, 14 Okt 2010) | 1 line
#9964: fix running test_import under -O or -OO.
........
r85461 | georg.brandl | 2010-10-14 09:29:08 +0200 (Do, 14 Okt 2010) | 1 line
#9964: fix lib2to3 fixer fix_operator when running under -OO.
........
r85462 | georg.brandl | 2010-10-14 09:32:52 +0200 (Do, 14 Okt 2010) | 1 line
#9964: fix running test_xml_etree under -OO.
........
r85463 | georg.brandl | 2010-10-14 09:34:56 +0200 (Do, 14 Okt 2010) | 1 line
Better check for "any optimize option given".
........
r85464 | georg.brandl | 2010-10-14 09:42:27 +0200 (Do, 14 Okt 2010) | 1 line
#9964: fix running test_compileall under -O and -OO.
........
r85465 | georg.brandl | 2010-10-14 10:08:56 +0200 (Do, 14 Okt 2010) | 1 line
#9964: fix running test_cmd_line_script under -O and -OO.
........
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Doc/library/atexit.rst
python/branches/release31-maint/Doc/library/os.path.rst
python/branches/release31-maint/Doc/library/os.rst
python/branches/release31-maint/Doc/library/profile.rst
python/branches/release31-maint/Doc/library/zipfile.rst
python/branches/release31-maint/Lib/test/test_zipfile.py
python/branches/release31-maint/Lib/zipfile.py
python/branches/release31-maint/Misc/NEWS
python/branches/release31-maint/Tools/README
Modified: python/branches/release31-maint/Doc/library/atexit.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/atexit.rst (original)
+++ python/branches/release31-maint/Doc/library/atexit.rst Fri Nov 26 09:37:46 2010
@@ -12,8 +12,8 @@
interpreter termination.
Note: the functions registered via this module are not called when the program
-is killed by a signal, when a Python fatal internal error is detected, or when
-:func:`os._exit` is called.
+is killed by a signal not handled by Python, when a Python fatal internal error
+is detected, or when :func:`os._exit` is called.
.. function:: register(func, *args, **kargs)
Modified: python/branches/release31-maint/Doc/library/os.path.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/os.path.rst (original)
+++ python/branches/release31-maint/Doc/library/os.path.rst Fri Nov 26 09:37:46 2010
@@ -258,14 +258,14 @@
.. function:: split(path)
- Split the pathname *path* into a pair, ``(head, tail)`` where *tail* is the last
- pathname component and *head* is everything leading up to that. The *tail* part
- will never contain a slash; if *path* ends in a slash, *tail* will be empty. If
- there is no slash in *path*, *head* will be empty. If *path* is empty, both
- *head* and *tail* are empty. Trailing slashes are stripped from *head* unless
- it is the root (one or more slashes only). In nearly all cases, ``join(head,
- tail)`` equals *path* (the only exception being when there were multiple slashes
- separating *head* from *tail*).
+ Split the pathname *path* into a pair, ``(head, tail)`` where *tail* is the
+ last pathname component and *head* is everything leading up to that. The
+ *tail* part will never contain a slash; if *path* ends in a slash, *tail*
+ will be empty. If there is no slash in *path*, *head* will be empty. If
+ *path* is empty, both *head* and *tail* are empty. Trailing slashes are
+ stripped from *head* unless it is the root (one or more slashes only). In
+ all cases, ``join(head, tail)`` returns a path to the same location as *path*
+ (but the strings may differ).
.. function:: splitdrive(path)
Modified: python/branches/release31-maint/Doc/library/os.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/os.rst (original)
+++ python/branches/release31-maint/Doc/library/os.rst Fri Nov 26 09:37:46 2010
@@ -1760,25 +1760,25 @@
Execute the command (a string) in a subshell. This is implemented by calling
the Standard C function :cfunc:`system`, and has the same limitations.
- Changes to :data:`sys.stdin`, etc. are not reflected in the environment of the
- executed command.
+ Changes to :data:`sys.stdin`, etc. are not reflected in the environment of
+ the executed command. If *command* generates any output, it will be sent to
+ the interpreter standard output stream.
On Unix, the return value is the exit status of the process encoded in the
- format specified for :func:`wait`. Note that POSIX does not specify the meaning
- of the return value of the C :cfunc:`system` function, so the return value of
- the Python function is system-dependent.
-
- On Windows, the return value is that returned by the system shell after running
- *command*, given by the Windows environment variable :envvar:`COMSPEC`: on
- :program:`command.com` systems (Windows 95, 98 and ME) this is always ``0``; on
- :program:`cmd.exe` systems (Windows NT, 2000 and XP) this is the exit status of
- the command run; on systems using a non-native shell, consult your shell
- documentation.
-
- The :mod:`subprocess` module provides more powerful facilities for spawning new
- processes and retrieving their results; using that module is preferable to using
- this function. Use the :mod:`subprocess` module. Check especially the
- :ref:`subprocess-replacements` section.
+ format specified for :func:`wait`. Note that POSIX does not specify the
+ meaning of the return value of the C :cfunc:`system` function, so the return
+ value of the Python function is system-dependent.
+
+ On Windows, the return value is that returned by the system shell after
+ running *command*. The shell is given by the Windows environment variable
+ :envvar:`COMSPEC`: it is usually :program:`cmd.exe`, which returns the exit
+ status of the command run; on systems using a non-native shell, consult your
+ shell documentation.
+
+ The :mod:`subprocess` module provides more powerful facilities for spawning
+ new processes and retrieving their results; using that module is preferable
+ to using this function. See the :ref:`subprocess-replacements` section in
+ the :mod:`subprocess` documentation for some helpful recipes.
Availability: Unix, Windows.
Modified: python/branches/release31-maint/Doc/library/profile.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/profile.rst (original)
+++ python/branches/release31-maint/Doc/library/profile.rst Fri Nov 26 09:37:46 2010
@@ -10,29 +10,6 @@
.. module:: profile
:synopsis: Python source profiler.
-.. index:: single: InfoSeek Corporation
-
-Copyright Ā© 1994, by InfoSeek Corporation, all rights reserved.
-
-Written by James Roskind. [#]_
-
-Permission to use, copy, modify, and distribute this Python software and its
-associated documentation for any purpose (subject to the restriction in the
-following sentence) without fee is hereby granted, provided that the above
-copyright notice appears in all copies, and that both that copyright notice and
-this permission notice appear in supporting documentation, and that the name of
-InfoSeek not be used in advertising or publicity pertaining to distribution of
-the software without specific, written prior permission. This permission is
-explicitly restricted to the copying and modification of the software to remain
-in Python, compiled Python, or other languages (such as C) wherein the modified
-or derived code is exclusively imported into a Python module.
-
-INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
-SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
-OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.. _profiler-introduction:
@@ -43,33 +20,38 @@
single: deterministic profiling
single: profiling, deterministic
-A :dfn:`profiler` is a program that describes the run time performance
-of a program, providing a variety of statistics. This documentation
-describes the profiler functionality provided in the modules
-:mod:`cProfile`, :mod:`profile` and :mod:`pstats`. This profiler
-provides :dfn:`deterministic profiling` of Python programs. It also
-provides a series of report generation tools to allow users to rapidly
-examine the results of a profile operation.
+A :dfn:`profiler` is a program that describes the run time performance of a
+program, providing a variety of statistics. This documentation describes the
+profiler functionality provided in the modules :mod:`cProfile`, :mod:`profile`
+and :mod:`pstats`. This profiler provides :dfn:`deterministic profiling` of
+Python programs. It also provides a series of report generation tools to allow
+users to rapidly examine the results of a profile operation.
The Python standard library provides two different profilers:
-#. :mod:`cProfile` is recommended for most users; it's a C extension
- with reasonable overhead
- that makes it suitable for profiling long-running programs.
- Based on :mod:`lsprof`,
- contributed by Brett Rosen and Ted Czotter.
-
-#. :mod:`profile`, a pure Python module whose interface is imitated by
- :mod:`cProfile`. Adds significant overhead to profiled programs.
- If you're trying to extend
- the profiler in some way, the task might be easier with this module.
- Copyright Ā© 1994, by InfoSeek Corporation.
+1. :mod:`cProfile` is recommended for most users; it's a C extension with
+ reasonable overhead that makes it suitable for profiling long-running
+ programs. Based on :mod:`lsprof`, contributed by Brett Rosen and Ted
+ Czotter.
+
+2. :mod:`profile`, a pure Python module whose interface is imitated by
+ :mod:`cProfile`. Adds significant overhead to profiled programs. If you're
+ trying to extend the profiler in some way, the task might be easier with this
+ module. Copyright Ā© 1994, by InfoSeek Corporation.
The :mod:`profile` and :mod:`cProfile` modules export the same interface, so
they are mostly interchangeable; :mod:`cProfile` has a much lower overhead but
-is newer and might not be available on all systems.
-:mod:`cProfile` is really a compatibility layer on top of the internal
-:mod:`_lsprof` module.
+is newer and might not be available on all systems. :mod:`cProfile` is really a
+compatibility layer on top of the internal :mod:`_lsprof` module.
+
+.. note::
+
+ The profiler modules are designed to provide an execution profile for a given
+ program, not for benchmarking purposes (for that, there is :mod:`timeit` for
+ resonably accurate results). This particularly applies to benchmarking
+ Python code against C code: the profilers introduce overhead for Python code,
+ but not for C-level functions, and so the C code would seem faster than any
+ Python one.
.. _profile-instant:
@@ -608,8 +590,26 @@
best results with a custom timer, it might be necessary to hard-code it in the C
source of the internal :mod:`_lsprof` module.
-.. rubric:: Footnotes
-.. [#] Updated and converted to LaTeX by Guido van Rossum. Further updated by Armin
- Rigo to integrate the documentation for the new :mod:`cProfile` module of Python
- 2.5.
+Copyright and License Notices
+=============================
+
+Copyright Ā© 1994, by InfoSeek Corporation, all rights reserved.
+
+Permission to use, copy, modify, and distribute this Python software and its
+associated documentation for any purpose (subject to the restriction in the
+following sentence) without fee is hereby granted, provided that the above
+copyright notice appears in all copies, and that both that copyright notice and
+this permission notice appear in supporting documentation, and that the name of
+InfoSeek not be used in advertising or publicity pertaining to distribution of
+the software without specific, written prior permission. This permission is
+explicitly restricted to the copying and modification of the software to remain
+in Python, compiled Python, or other languages (such as C) wherein the modified
+or derived code is exclusively imported into a Python module.
+
+INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT
+SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Modified: python/branches/release31-maint/Doc/library/zipfile.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/zipfile.rst (original)
+++ python/branches/release31-maint/Doc/library/zipfile.rst Fri Nov 26 09:37:46 2010
@@ -120,6 +120,10 @@
because the default :program:`zip` and :program:`unzip` commands on Unix (the
InfoZIP utilities) don't support these extensions.
+ If the file is created with mode ``'a'`` or ``'w'`` and then
+ :meth:`close`\ d without adding any files to the archive, the appropriate
+ ZIP structures for an empty archive will be written to the file.
+
.. method:: ZipFile.close()
Modified: python/branches/release31-maint/Lib/test/test_zipfile.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_zipfile.py (original)
+++ python/branches/release31-maint/Lib/test/test_zipfile.py Fri Nov 26 09:37:46 2010
@@ -902,6 +902,31 @@
def test_read_return_size_deflated(self):
self.check_read_return_size(zipfile.ZIP_DEFLATED)
+ def test_empty_zipfile(self):
+ # Check that creating a file in 'w' or 'a' mode and closing without
+ # adding any files to the archives creates a valid empty ZIP file
+ zipf = zipfile.ZipFile(TESTFN, mode="w")
+ zipf.close()
+ try:
+ zipf = zipfile.ZipFile(TESTFN, mode="r")
+ except zipfile.BadZipFile:
+ self.fail("Unable to create empty ZIP file in 'w' mode")
+
+ zipf = zipfile.ZipFile(TESTFN, mode="a")
+ zipf.close()
+ try:
+ zipf = zipfile.ZipFile(TESTFN, mode="r")
+ except:
+ self.fail("Unable to create empty ZIP file in 'a' mode")
+
+ def test_open_empty_file(self):
+ # Issue 1710703: Check that opening a file with less than 22 bytes
+ # raises a BadZipfile exception (rather than the previously unhelpful
+ # IOError)
+ f = open(TESTFN, 'w')
+ f.close()
+ self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN, 'r')
+
def tearDown(self):
support.unlink(TESTFN)
support.unlink(TESTFN2)
Modified: python/branches/release31-maint/Lib/zipfile.py
==============================================================================
--- python/branches/release31-maint/Lib/zipfile.py (original)
+++ python/branches/release31-maint/Lib/zipfile.py Fri Nov 26 09:37:46 2010
@@ -158,7 +158,13 @@
"""
Read the ZIP64 end-of-archive records and use that to update endrec
"""
- fpin.seek(offset - sizeEndCentDir64Locator, 2)
+ try:
+ fpin.seek(offset - sizeEndCentDir64Locator, 2)
+ except IOError:
+ # If the seek fails, the file is not large enough to contain a ZIP64
+ # end-of-archive record, so just return the end record we were given.
+ return endrec
+
data = fpin.read(sizeEndCentDir64Locator)
sig, diskno, reloff, disks = struct.unpack(structEndArchive64Locator, data)
if sig != stringEndArchive64Locator:
@@ -723,14 +729,22 @@
if key == 'r':
self._GetContents()
elif key == 'w':
- pass
+ # set the modified flag so central directory gets written
+ # even if no files are added to the archive
+ self._didModify = True
elif key == 'a':
- try: # See if file is a zip file
+ try:
+ # See if file is a zip file
self._RealGetContents()
# seek to start of directory and overwrite
self.fp.seek(self.start_dir, 0)
- except BadZipfile: # file is not a zip file, just append
+ except BadZipfile:
+ # file is not a zip file, just append
self.fp.seek(0, 2)
+
+ # set the modified flag so central directory gets written
+ # even if no files are added to the archive
+ self._didModify = True
else:
if not self._filePassed:
self.fp.close()
@@ -751,7 +765,10 @@
def _RealGetContents(self):
"""Read in the table of contents for the ZIP file."""
fp = self.fp
- endrec = _EndRecData(fp)
+ try:
+ endrec = _EndRecData(fp)
+ except IOError:
+ raise BadZipfile("File is not a zip file")
if not endrec:
raise BadZipfile("File is not a zip file")
if self.debug > 1:
Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS (original)
+++ python/branches/release31-maint/Misc/NEWS Fri Nov 26 09:37:46 2010
@@ -18,6 +18,10 @@
- Issue #10459: Update CJK character names to Unicode 5.1.
+- Issue #1710703: Write structures for an empty ZIP archive when a ZipFile is
+ created in modes 'a' or 'w' and then closed without adding any files. Raise
+ BadZipfile (rather than IOError) when opening small non-ZIP files.
+
- Issue #4493: urllib.request adds '/' in front of path components which does not
start with '/. Common behavior exhibited by browsers and other clients.
Modified: python/branches/release31-maint/Tools/README
==============================================================================
--- python/branches/release31-maint/Tools/README (original)
+++ python/branches/release31-maint/Tools/README Fri Nov 26 09:37:46 2010
@@ -26,9 +26,10 @@
pynche A Tkinter-based color editor.
-scripts A number of useful single-file programs, e.g. tabnanny.py
- (by Tim Peters), which checks for inconsistent mixing
- of tabs and spaces.
+scripts A number of useful single-file programs, e.g. tabnanny.py
+ by Tim Peters, which checks for inconsistent mixing of
+ tabs and spaces, and 2to3, which converts Python 2 code
+ to Python 3 code.
unicode Tools used to generate unicode database files for
Python 2.0 (by Fredrik Lundh).
1
0
r86779 - python/branches/release27-maint/Doc/tools/sphinxext/susp-ignored.csv
by georg.brandl Nov. 26, 2010
by georg.brandl Nov. 26, 2010
Nov. 26, 2010
Author: georg.brandl
Date: Fri Nov 26 09:33:56 2010
New Revision: 86779
Log:
Update suspicious file.
Modified:
python/branches/release27-maint/Doc/tools/sphinxext/susp-ignored.csv
Modified: python/branches/release27-maint/Doc/tools/sphinxext/susp-ignored.csv
==============================================================================
--- python/branches/release27-maint/Doc/tools/sphinxext/susp-ignored.csv (original)
+++ python/branches/release27-maint/Doc/tools/sphinxext/susp-ignored.csv Fri Nov 26 09:33:56 2010
@@ -200,8 +200,8 @@
faq/programming,,::,for x in sequence[::-1]:
faq/windows,229,:EOF,@setlocal enableextensions & python -x %~f0 %* & goto :EOF
faq/windows,393,:REG,.py :REG_SZ: c:\<path to python>\python.exe -u %s %s
-library/bisect,32,:hi,all(val >= x for val in a[i:hi])
-library/bisect,42,:hi,all(val > x for val in a[i:hi])
+library/bisect,,:hi,all(val >= x for val in a[i:hi])
+library/bisect,,:hi,all(val > x for val in a[i:hi])
library/http.client,52,:port,host:port
library/nntplib,,:bytes,:bytes
library/nntplib,,:lines,:lines
1
0
r86778 - in python/branches/release27-maint: Doc/c-api/codec.rst Doc/c-api/exceptions.rst Doc/c-api/intro.rst Doc/c-api/utilities.rst Doc/library/heapq.rst Include/codecs.h Lib/test/test_socket.py Misc/indent.pro
by georg.brandl Nov. 26, 2010
by georg.brandl Nov. 26, 2010
Nov. 26, 2010
Author: georg.brandl
Date: Fri Nov 26 09:28:05 2010
New Revision: 86778
Log:
Merged revisions 86561-86562,86564-86565,86705,86708,86713 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r86561 | georg.brandl | 2010-11-20 12:47:10 +0100 (Sa, 20 Nov 2010) | 1 line
#10460: Update indent.pro to match PEP 7 better.
........
r86562 | georg.brandl | 2010-11-20 14:44:41 +0100 (Sa, 20 Nov 2010) | 1 line
#10439: document PyCodec C APIs.
........
r86564 | georg.brandl | 2010-11-20 15:08:53 +0100 (Sa, 20 Nov 2010) | 1 line
#10460: an even better indent.pro.
........
r86565 | georg.brandl | 2010-11-20 15:16:17 +0100 (Sa, 20 Nov 2010) | 1 line
socket.gethostbyname(socket.gethostname()) can fail when host name resolution is not set up correctly; do not fail test_socket if this is the case.
........
r86705 | georg.brandl | 2010-11-23 08:54:19 +0100 (Di, 23 Nov 2010) | 1 line
#10468: document Unicode exception creation and access functions.
........
r86708 | georg.brandl | 2010-11-23 09:37:54 +0100 (Di, 23 Nov 2010) | 2 lines
#10511: clarification of what heaps are; suggested by Johannes Hoff.
........
r86713 | georg.brandl | 2010-11-23 19:14:57 +0100 (Di, 23 Nov 2010) | 1 line
assert.h is also included. Thanks to Savio Sena.
........
Added:
python/branches/release27-maint/Doc/c-api/codec.rst
- copied, changed from r86565, /python/branches/py3k/Doc/c-api/codec.rst
Modified:
python/branches/release27-maint/ (props changed)
python/branches/release27-maint/Doc/c-api/exceptions.rst
python/branches/release27-maint/Doc/c-api/intro.rst
python/branches/release27-maint/Doc/c-api/utilities.rst
python/branches/release27-maint/Doc/library/heapq.rst
python/branches/release27-maint/Include/codecs.h
python/branches/release27-maint/Lib/test/test_socket.py
python/branches/release27-maint/Misc/indent.pro
Copied: python/branches/release27-maint/Doc/c-api/codec.rst (from r86565, /python/branches/py3k/Doc/c-api/codec.rst)
==============================================================================
--- /python/branches/py3k/Doc/c-api/codec.rst (original)
+++ python/branches/release27-maint/Doc/c-api/codec.rst Fri Nov 26 09:28:05 2010
@@ -3,19 +3,19 @@
Codec registry and support functions
====================================
-.. c:function:: int PyCodec_Register(PyObject *search_function)
+.. cfunction:: int PyCodec_Register(PyObject *search_function)
Register a new codec search function.
As side effect, this tries to load the :mod:`encodings` package, if not yet
done, to make sure that it is always first in the list of search functions.
-.. c:function:: int PyCodec_KnownEncoding(const char *encoding)
+.. cfunction:: int PyCodec_KnownEncoding(const char *encoding)
Return ``1`` or ``0`` depending on whether there is a registered codec for
the given *encoding*.
-.. c:function:: PyObject* PyCodec_Encode(PyObject *object, const char *encoding, const char *errors)
+.. cfunction:: PyObject* PyCodec_Encode(PyObject *object, const char *encoding, const char *errors)
Generic codec based encoding API.
@@ -24,7 +24,7 @@
be *NULL* to use the default method defined for the codec. Raises a
:exc:`LookupError` if no encoder can be found.
-.. c:function:: PyObject* PyCodec_Decode(PyObject *object, const char *encoding, const char *errors)
+.. cfunction:: PyObject* PyCodec_Decode(PyObject *object, const char *encoding, const char *errors)
Generic codec based decoding API.
@@ -42,27 +42,27 @@
effectively case-insensitive. If no codec is found, a :exc:`KeyError` is set
and *NULL* returned.
-.. c:function:: PyObject* PyCodec_Encoder(const char *encoding)
+.. cfunction:: PyObject* PyCodec_Encoder(const char *encoding)
Get an encoder function for the given *encoding*.
-.. c:function:: PyObject* PyCodec_Decoder(const char *encoding)
+.. cfunction:: PyObject* PyCodec_Decoder(const char *encoding)
Get a decoder function for the given *encoding*.
-.. c:function:: PyObject* PyCodec_IncrementalEncoder(const char *encoding, const char *errors)
+.. cfunction:: PyObject* PyCodec_IncrementalEncoder(const char *encoding, const char *errors)
Get an :class:`IncrementalEncoder` object for the given *encoding*.
-.. c:function:: PyObject* PyCodec_IncrementalDecoder(const char *encoding, const char *errors)
+.. cfunction:: PyObject* PyCodec_IncrementalDecoder(const char *encoding, const char *errors)
Get an :class:`IncrementalDecoder` object for the given *encoding*.
-.. c:function:: PyObject* PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors)
+.. cfunction:: PyObject* PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors)
Get a :class:`StreamReader` factory function for the given *encoding*.
-.. c:function:: PyObject* PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors)
+.. cfunction:: PyObject* PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors)
Get a :class:`StreamWriter` factory function for the given *encoding*.
@@ -70,7 +70,7 @@
Registry API for Unicode encoding error handlers
------------------------------------------------
-.. c:function:: int PyCodec_RegisterError(const char *name, PyObject *error)
+.. cfunction:: int PyCodec_RegisterError(const char *name, PyObject *error)
Register the error handling callback function *error* under the given *name*.
This callback function will be called by a codec when it encounters
@@ -80,40 +80,38 @@
The callback gets a single argument, an instance of
:exc:`UnicodeEncodeError`, :exc:`UnicodeDecodeError` or
:exc:`UnicodeTranslateError` that holds information about the problematic
- sequence of characters or bytes and their offset in the original string. The
+ sequence of characters or bytes and their offset in the original string (see
+ :ref:`unicodeexceptions` for functions to extract this information). The
callback must either raise the given exception, or return a two-item tuple
containing the replacement for the problematic sequence, and an integer
giving the offset in the original string at which encoding/decoding should be
resumed.
- .. XXX once they are documented, link to PyUnicode*Error access functions
- to show how to get at the exception properties
-
Return ``0`` on success, ``-1`` on error.
-.. c:function:: PyObject* PyCodec_LookupError(const char *name)
+.. cfunction:: PyObject* PyCodec_LookupError(const char *name)
Lookup the error handling callback function registered under *name*. As a
special case *NULL* can be passed, in which case the error handling callback
for "strict" will be returned.
-.. c:function:: PyObject* PyCodec_StrictErrors(PyObject *exc)
+.. cfunction:: PyObject* PyCodec_StrictErrors(PyObject *exc)
Raise *exc* as an exception.
-.. c:function:: PyObject* PyCodec_IgnoreErrors(PyObject *exc)
+.. cfunction:: PyObject* PyCodec_IgnoreErrors(PyObject *exc)
Ignore the unicode error, skipping the faulty input.
-.. c:function:: PyObject* PyCodec_ReplaceErrors(PyObject *exc)
+.. cfunction:: PyObject* PyCodec_ReplaceErrors(PyObject *exc)
Replace the unicode encode error with ``?`` or ``U+FFFD``.
-.. c:function:: PyObject* PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
+.. cfunction:: PyObject* PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
Replace the unicode encode error with XML character references.
-.. c:function:: PyObject* PyCodec_BackslashReplaceErrors(PyObject *exc)
+.. cfunction:: PyObject* PyCodec_BackslashReplaceErrors(PyObject *exc)
Replace the unicode encode error with backslash escapes (``\x``, ``\u`` and
``\U``).
Modified: python/branches/release27-maint/Doc/c-api/exceptions.rst
==============================================================================
--- python/branches/release27-maint/Doc/c-api/exceptions.rst (original)
+++ python/branches/release27-maint/Doc/c-api/exceptions.rst Fri Nov 26 09:28:05 2010
@@ -454,6 +454,83 @@
the warning message.
+.. _unicodeexceptions:
+
+Unicode Exception Objects
+=========================
+
+The following functions are used to create and modify Unicode exceptions from C.
+
+.. cfunction:: PyObject* PyUnicodeDecodeError_Create(const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
+
+ Create a :class:`UnicodeDecodeError` object with the attributes *encoding*,
+ *object*, *length*, *start*, *end* and *reason*.
+
+.. cfunction:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
+
+ Create a :class:`UnicodeEncodeError` object with the attributes *encoding*,
+ *object*, *length*, *start*, *end* and *reason*.
+
+.. cfunction:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
+
+ Create a :class:`UnicodeTranslateError` object with the attributes *object*,
+ *length*, *start*, *end* and *reason*.
+
+.. cfunction:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
+ PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)
+
+ Return the *encoding* attribute of the given exception object.
+
+.. cfunction:: PyObject* PyUnicodeDecodeError_GetObject(PyObject *exc)
+ PyObject* PyUnicodeEncodeError_GetObject(PyObject *exc)
+ PyObject* PyUnicodeTranslateError_GetObject(PyObject *exc)
+
+ Return the *object* attribute of the given exception object.
+
+.. cfunction:: int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start)
+ int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)
+ int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start)
+
+ Get the *start* attribute of the given exception object and place it into
+ *\*start*. *start* must not be *NULL*. Return ``0`` on success, ``-1`` on
+ failure.
+
+.. cfunction:: int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start)
+ int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start)
+ int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start)
+
+ Set the *start* attribute of the given exception object to *start*. Return
+ ``0`` on success, ``-1`` on failure.
+
+.. cfunction:: int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
+ int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
+ int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *end)
+
+ Get the *end* attribute of the given exception object and place it into
+ *\*end*. *end* must not be *NULL*. Return ``0`` on success, ``-1`` on
+ failure.
+
+.. cfunction:: int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end)
+ int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end)
+ int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end)
+
+ Set the *end* attribute of the given exception object to *end*. Return ``0``
+ on success, ``-1`` on failure.
+
+.. cfunction:: PyObject* PyUnicodeDecodeError_GetReason(PyObject *exc)
+ PyObject* PyUnicodeEncodeError_GetReason(PyObject *exc)
+ PyObject* PyUnicodeTranslateError_GetReason(PyObject *exc)
+
+ Return the *reason* attribute of the given exception object.
+
+.. cfunction:: int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason)
+ int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason)
+ int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason)
+
+ Set the *reason* attribute of the given exception object to *reason*. Return
+ ``0`` on success, ``-1`` on failure.
+
+
Recursion Control
=================
Modified: python/branches/release27-maint/Doc/c-api/intro.rst
==============================================================================
--- python/branches/release27-maint/Doc/c-api/intro.rst (original)
+++ python/branches/release27-maint/Doc/c-api/intro.rst Fri Nov 26 09:28:05 2010
@@ -41,8 +41,8 @@
#include "Python.h"
This implies inclusion of the following standard headers: ``<stdio.h>``,
-``<string.h>``, ``<errno.h>``, ``<limits.h>``, and ``<stdlib.h>`` (if
-available).
+``<string.h>``, ``<errno.h>``, ``<limits.h>``, ``<assert.h>`` and ``<stdlib.h>``
+(if available).
.. note::
Modified: python/branches/release27-maint/Doc/c-api/utilities.rst
==============================================================================
--- python/branches/release27-maint/Doc/c-api/utilities.rst (original)
+++ python/branches/release27-maint/Doc/c-api/utilities.rst Fri Nov 26 09:28:05 2010
@@ -19,3 +19,4 @@
arg.rst
conversion.rst
reflection.rst
+ codec.rst
Modified: python/branches/release27-maint/Doc/library/heapq.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/heapq.rst (original)
+++ python/branches/release27-maint/Doc/library/heapq.rst Fri Nov 26 09:28:05 2010
@@ -18,11 +18,12 @@
Latest version of the `heapq Python source code
<http://svn.python.org/view/python/branches/release27-maint/Lib/heapq.py?vieā¦>`_
-Heaps are arrays for which ``heap[k] <= heap[2*k+1]`` and ``heap[k] <=
-heap[2*k+2]`` for all *k*, counting elements from zero. For the sake of
-comparison, non-existing elements are considered to be infinite. The
-interesting property of a heap is that ``heap[0]`` is always its smallest
-element.
+Heaps are binary trees for which every parent node has a value less than or
+equal to any of its children. This implementation uses arrays for which
+``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k*, counting
+elements from zero. For the sake of comparison, non-existing elements are
+considered to be infinite. The interesting property of a heap is that its
+smallest element is always the root, ``heap[0]``.
The API below differs from textbook heap algorithms in two aspects: (a) We use
zero-based indexing. This makes the relationship between the index for a node
Modified: python/branches/release27-maint/Include/codecs.h
==============================================================================
--- python/branches/release27-maint/Include/codecs.h (original)
+++ python/branches/release27-maint/Include/codecs.h Fri Nov 26 09:28:05 2010
@@ -133,7 +133,7 @@
/* Unicode encoding error handling callback registry API */
-/* Register the error handling callback function error under the name
+/* Register the error handling callback function error under the given
name. This function will be called by the codec when it encounters
unencodable characters/undecodable bytes and doesn't know the
callback name, when name is specified as the error parameter
@@ -141,8 +141,8 @@
Return 0 on success, -1 on error */
PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
-/* Lookup the error handling callback function registered under the
- name error. As a special case NULL can be passed, in which case
+/* Lookup the error handling callback function registered under the given
+ name. As a special case NULL can be passed, in which case
the error handling callback for "strict" will be returned. */
PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
@@ -152,7 +152,7 @@
/* ignore the unicode error, skipping the faulty input */
PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
-/* replace the unicode error with ? or U+FFFD */
+/* replace the unicode encode error with ? or U+FFFD */
PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
/* replace the unicode encode error with XML character references */
Modified: python/branches/release27-maint/Lib/test/test_socket.py
==============================================================================
--- python/branches/release27-maint/Lib/test/test_socket.py (original)
+++ python/branches/release27-maint/Lib/test/test_socket.py Fri Nov 26 09:28:05 2010
@@ -523,7 +523,11 @@
# XXX(nnorwitz): http://tinyurl.com/os5jz seems to indicate
# it reasonable to get the host's addr in addition to 0.0.0.0.
# At least for eCos. This is required for the S/390 to pass.
- my_ip_addr = socket.gethostbyname(socket.gethostname())
+ try:
+ my_ip_addr = socket.gethostbyname(socket.gethostname())
+ except socket.error:
+ # Probably name lookup wasn't set up right; skip this test
+ return
self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
self.assertEqual(name[1], port)
Modified: python/branches/release27-maint/Misc/indent.pro
==============================================================================
--- python/branches/release27-maint/Misc/indent.pro (original)
+++ python/branches/release27-maint/Misc/indent.pro Fri Nov 26 09:28:05 2010
@@ -1,15 +1,24 @@
--sob
--nbad
--bap
--br
--nce
--ncs
--npcs
--i8
--ip8
--c25
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--braces-after-func-def-line
+--braces-on-if-line
+--braces-on-struct-decl-line
+--break-after-boolean-operator
+--comment-indentation25
+--comment-line-length79
+--continue-at-parentheses
+--dont-cuddle-do-while
+--dont-cuddle-else
+--indent-level4
+--line-length79
+--no-space-after-casts
+--no-space-after-function-call-names
+--no-space-after-parentheses
+--no-tabs
+--procnames-start-lines
+--space-after-for
+--space-after-if
+--space-after-while
+--swallow-optional-blank-lines
+-T PyCFunction
-T PyObject
-
-
-
-
1
0
Author: georg.brandl
Date: Fri Nov 26 09:25:00 2010
New Revision: 86777
Log:
Blocked revisions 86479-86480,86537,86550,86608,86619,86725 via svnmerge
........
r86479 | georg.brandl | 2010-11-16 16:15:29 +0100 (Di, 16 Nov 2010) | 1 line
Add stub for PEP 3148.
........
r86480 | georg.brandl | 2010-11-16 16:15:56 +0100 (Di, 16 Nov 2010) | 1 line
Post-release bumps.
........
r86537 | georg.brandl | 2010-11-19 23:09:04 +0100 (Fr, 19 Nov 2010) | 1 line
Do not put a raw REPLACEMENT CHARACTER in the document.
........
r86550 | georg.brandl | 2010-11-20 11:24:34 +0100 (Sa, 20 Nov 2010) | 1 line
Fix rst markup errors.
........
r86608 | georg.brandl | 2010-11-20 20:54:36 +0100 (Sa, 20 Nov 2010) | 1 line
#9724: add nonlocal to pydoc topics.
........
r86619 | georg.brandl | 2010-11-20 23:40:10 +0100 (Sa, 20 Nov 2010) | 1 line
Add error handling in range_count.
........
r86725 | georg.brandl | 2010-11-24 10:09:29 +0100 (Mi, 24 Nov 2010) | 1 line
Remove UTF-8 BOM.
........
Modified:
python/branches/release27-maint/ (props changed)
1
0
Nov. 26, 2010
Author: georg.brandl
Date: Fri Nov 26 09:20:18 2010
New Revision: 86776
Log:
Merged revisions 85843,85849-85850,85867,85907,85914,86134,86187,86315-86316,86390,86424-86425,86428 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85843 | georg.brandl | 2010-10-26 08:59:23 +0200 (Di, 26 Okt 2010) | 1 line
Markup fix.
........
r85849 | georg.brandl | 2010-10-26 21:31:06 +0200 (Di, 26 Okt 2010) | 1 line
#10200: typo.
........
r85850 | georg.brandl | 2010-10-26 21:58:11 +0200 (Di, 26 Okt 2010) | 1 line
#10200: typo.
........
r85867 | georg.brandl | 2010-10-27 22:01:51 +0200 (Mi, 27 Okt 2010) | 1 line
Add David.
........
r85907 | georg.brandl | 2010-10-29 06:54:13 +0200 (Fr, 29 Okt 2010) | 1 line
#10222: fix for overzealous AIX compiler.
........
r85914 | georg.brandl | 2010-10-29 08:17:38 +0200 (Fr, 29 Okt 2010) | 1 line
(?:...) is a non-capturing, but still grouping construct.
........
r86134 | georg.brandl | 2010-11-03 08:41:00 +0100 (Mi, 03 Nov 2010) | 1 line
A newline in lineno output breaks pyframe output.
........
r86187 | georg.brandl | 2010-11-05 08:10:41 +0100 (Fr, 05 Nov 2010) | 1 line
Move glossary entry to the right position and fix link.
........
r86315 | georg.brandl | 2010-11-08 12:05:18 +0100 (Mo, 08 Nov 2010) | 1 line
Fix latex conversion glitch in property/feature descriptions.
........
r86316 | georg.brandl | 2010-11-08 12:08:35 +0100 (Mo, 08 Nov 2010) | 1 line
Fix typo.
........
r86390 | georg.brandl | 2010-11-10 08:57:10 +0100 (Mi, 10 Nov 2010) | 1 line
Fix typo.
........
r86424 | georg.brandl | 2010-11-12 07:19:48 +0100 (Fr, 12 Nov 2010) | 1 line
Build a PDF of the FAQs too.
........
r86425 | georg.brandl | 2010-11-12 07:20:12 +0100 (Fr, 12 Nov 2010) | 1 line
#10008: Fix duplicate index entry.
........
r86428 | georg.brandl | 2010-11-12 09:09:26 +0100 (Fr, 12 Nov 2010) | 1 line
Fix weird line block in table.
........
Modified:
python/branches/release27-maint/ (props changed)
python/branches/release27-maint/Doc/conf.py
python/branches/release27-maint/Doc/glossary.rst
python/branches/release27-maint/Doc/howto/sorting.rst
python/branches/release27-maint/Doc/library/itertools.rst
python/branches/release27-maint/Doc/library/locale.rst
python/branches/release27-maint/Doc/library/re.rst
python/branches/release27-maint/Doc/library/string.rst
python/branches/release27-maint/Doc/library/warnings.rst
python/branches/release27-maint/Doc/library/xml.sax.handler.rst
python/branches/release27-maint/Doc/library/zipfile.rst
python/branches/release27-maint/Misc/developers.txt
python/branches/release27-maint/Misc/gdbinit
Modified: python/branches/release27-maint/Doc/conf.py
==============================================================================
--- python/branches/release27-maint/Doc/conf.py (original)
+++ python/branches/release27-maint/Doc/conf.py Fri Nov 26 09:20:18 2010
@@ -126,6 +126,8 @@
'Python Tutorial', _stdauthor, 'manual'),
('using/index', 'using.tex',
'Python Setup and Usage', _stdauthor, 'manual'),
+ ('faq/index', 'faq.tex',
+ 'Python Frequently Asked Questions', _stdauthor, 'manual'),
('whatsnew/' + version, 'whatsnew.tex',
'What\'s New in Python', 'A. M. Kuchling', 'howto'),
]
Modified: python/branches/release27-maint/Doc/glossary.rst
==============================================================================
--- python/branches/release27-maint/Doc/glossary.rst (original)
+++ python/branches/release27-maint/Doc/glossary.rst Fri Nov 26 09:20:18 2010
@@ -356,6 +356,26 @@
More information can be found in :ref:`typeiter`.
+ key function
+ A key function or collation function is a callable that returns a value
+ used for sorting or ordering. For example, :func:`locale.strxfrm` is
+ used to produce a sort key that is aware of locale specific sort
+ conventions.
+
+ A number of tools in Python accept key functions to control how elements
+ are ordered or grouped. They include :func:`min`, :func:`max`,
+ :func:`sorted`, :meth:`list.sort`, :func:`heapq.nsmallest`,
+ :func:`heapq.nlargest`, and :func:`itertools.groupby`.
+
+ There are several ways to create a key function. For example. the
+ :meth:`str.lower` method can serve as a key function for case insensitive
+ sorts. Alternatively, an ad-hoc key function can be built from a
+ :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also,
+ the :mod:`operator` module provides three key function constuctors:
+ :func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and
+ :func:`~operator.methodcaller`. See the :ref:`Sorting HOW TO
+ <sortinghowto>` for examples of how to create and use key functions.
+
keyword argument
Arguments which are preceded with a ``variable_name=`` in the call.
The variable name designates the local name in the function to which the
@@ -379,7 +399,7 @@
:keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also,
the :mod:`operator` module provides three key function constuctors:
:func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and
- :func:`~operator.methodcaller`. See the :ref:`sorting-howto` for
+ :func:`~operator.methodcaller`. See the :ref:`sortinghowto` for
examples of how to create and use key functions.
lambda
Modified: python/branches/release27-maint/Doc/howto/sorting.rst
==============================================================================
--- python/branches/release27-maint/Doc/howto/sorting.rst (original)
+++ python/branches/release27-maint/Doc/howto/sorting.rst Fri Nov 26 09:20:18 2010
@@ -1,4 +1,4 @@
-.. _sorting-howto:
+.. _sortinghowto:
Sorting HOW TO
**************
Modified: python/branches/release27-maint/Doc/library/itertools.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/itertools.rst (original)
+++ python/branches/release27-maint/Doc/library/itertools.rst Fri Nov 26 09:20:18 2010
@@ -72,7 +72,6 @@
:func:`permutations` p[, r] r-length tuples, all possible orderings, no repeated elements
:func:`combinations` p, r r-length tuples, in sorted order, no repeated elements
:func:`combinations_with_replacement` p, r r-length tuples, in sorted order, with repeated elements
-|
``product('ABCD', repeat=2)`` ``AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD``
``permutations('ABCD', 2)`` ``AB AC AD BA BC BD CA CB CD DA DB DC``
``combinations('ABCD', 2)`` ``AB AC AD BC BD CD``
Modified: python/branches/release27-maint/Doc/library/locale.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/locale.rst (original)
+++ python/branches/release27-maint/Doc/library/locale.rst Fri Nov 26 09:20:18 2010
@@ -554,7 +554,7 @@
Python applications should normally find no need to invoke these functions, and
should use :mod:`gettext` instead. A known exception to this rule are
-applications that link use additional C libraries which internally invoke
+applications that link with additional C libraries which internally invoke
:cfunc:`gettext` or :func:`dcgettext`. For these applications, it may be
necessary to bind the text domain, so that the libraries can properly locate
their message catalogs.
Modified: python/branches/release27-maint/Doc/library/re.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/re.rst (original)
+++ python/branches/release27-maint/Doc/library/re.rst Fri Nov 26 09:20:18 2010
@@ -224,7 +224,7 @@
undefined.
``(?:...)``
- A non-grouping version of regular parentheses. Matches whatever regular
+ A non-capturing version of regular parentheses. Matches whatever regular
expression is inside the parentheses, but the substring matched by the group
*cannot* be retrieved after performing a match or referenced later in the
pattern.
Modified: python/branches/release27-maint/Doc/library/string.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/string.rst (original)
+++ python/branches/release27-maint/Doc/library/string.rst Fri Nov 26 09:20:18 2010
@@ -146,7 +146,7 @@
Loop over the format_string and return an iterable of tuples
(*literal_text*, *field_name*, *format_spec*, *conversion*). This is used
- by :meth:`vformat` to break the string in to either literal text, or
+ by :meth:`vformat` to break the string into either literal text, or
replacement fields.
The values in the tuple conceptually represent a span of literal text
Modified: python/branches/release27-maint/Doc/library/warnings.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/warnings.rst (original)
+++ python/branches/release27-maint/Doc/library/warnings.rst Fri Nov 26 09:20:18 2010
@@ -164,7 +164,7 @@
* :exc:`BytesWarning` is ignored unless the :option:`-b` option is given once or
twice; in this case this warning is either printed (``-b``) or turned into an
- exception (``-bb`).
+ exception (``-bb``).
.. versionchanged:: 3.2
:exc:`DeprecationWarning` is now ignored by default in addition to
Modified: python/branches/release27-maint/Doc/library/xml.sax.handler.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/xml.sax.handler.rst (original)
+++ python/branches/release27-maint/Doc/library/xml.sax.handler.rst Fri Nov 26 09:20:18 2010
@@ -52,52 +52,57 @@
.. data:: feature_namespaces
- Value: ``"http://xml.org/sax/features/namespaces"`` --- true: Perform Namespace
- processing. --- false: Optionally do not perform Namespace processing (implies
- namespace-prefixes; default). --- access: (parsing) read-only; (not parsing)
- read/write
+ | value: ``"http://xml.org/sax/features/namespaces"``
+ | true: Perform Namespace processing.
+ | false: Optionally do not perform Namespace processing (implies
+ namespace-prefixes; default).
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: feature_namespace_prefixes
- Value: ``"http://xml.org/sax/features/namespace-prefixes"`` --- true: Report
- the original prefixed names and attributes used for Namespace
- declarations. --- false: Do not report attributes used for Namespace
- declarations, and optionally do not report original prefixed names
- (default). --- access: (parsing) read-only; (not parsing) read/write
+ | value: ``"http://xml.org/sax/features/namespace-prefixes"``
+ | true: Report the original prefixed names and attributes used for Namespace
+ declarations.
+ | false: Do not report attributes used for Namespace declarations, and
+ optionally do not report original prefixed names (default).
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: feature_string_interning
- Value: ``"http://xml.org/sax/features/string-interning"`` --- true: All element
- names, prefixes, attribute names, Namespace URIs, and local names are interned
- using the built-in intern function. --- false: Names are not necessarily
- interned, although they may be (default). --- access: (parsing) read-only; (not
- parsing) read/write
+ | value: ``"http://xml.org/sax/features/string-interning"``
+ | true: All element names, prefixes, attribute names, Namespace URIs, and
+ local names are interned using the built-in intern function.
+ | false: Names are not necessarily interned, although they may be (default).
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: feature_validation
- Value: ``"http://xml.org/sax/features/validation"`` --- true: Report all
- validation errors (implies external-general-entities and
- external-parameter-entities). --- false: Do not report validation errors. ---
- access: (parsing) read-only; (not parsing) read/write
+ | value: ``"http://xml.org/sax/features/validation"``
+ | true: Report all validation errors (implies external-general-entities and
+ external-parameter-entities).
+ | false: Do not report validation errors.
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: feature_external_ges
- Value: ``"http://xml.org/sax/features/external-general-entities"`` --- true:
- Include all external general (text) entities. --- false: Do not include
- external general entities. --- access: (parsing) read-only; (not parsing)
- read/write
+ | value: ``"http://xml.org/sax/features/external-general-entities"``
+ | true: Include all external general (text) entities.
+ | false: Do not include external general entities.
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: feature_external_pes
- Value: ``"http://xml.org/sax/features/external-parameter-entities"`` --- true:
- Include all external parameter entities, including the external DTD subset. ---
- false: Do not include any external parameter entities, even the external DTD
- subset. --- access: (parsing) read-only; (not parsing) read/write
+ | value: ``"http://xml.org/sax/features/external-parameter-entities"``
+ | true: Include all external parameter entities, including the external DTD
+ subset.
+ | false: Do not include any external parameter entities, even the external
+ DTD subset.
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: all_features
@@ -107,34 +112,38 @@
.. data:: property_lexical_handler
- Value: ``"http://xml.org/sax/properties/lexical-handler"`` --- data type:
- xml.sax.sax2lib.LexicalHandler (not supported in Python 2) --- description: An
- optional extension handler for lexical events like comments. --- access:
- read/write
+ | value: ``"http://xml.org/sax/properties/lexical-handler"``
+ | data type: xml.sax.sax2lib.LexicalHandler (not supported in Python 2)
+ | description: An optional extension handler for lexical events like
+ comments.
+ | access: read/write
.. data:: property_declaration_handler
- Value: ``"http://xml.org/sax/properties/declaration-handler"`` --- data type:
- xml.sax.sax2lib.DeclHandler (not supported in Python 2) --- description: An
- optional extension handler for DTD-related events other than notations and
- unparsed entities. --- access: read/write
+ | value: ``"http://xml.org/sax/properties/declaration-handler"``
+ | data type: xml.sax.sax2lib.DeclHandler (not supported in Python 2)
+ | description: An optional extension handler for DTD-related events other
+ than notations and unparsed entities.
+ | access: read/write
.. data:: property_dom_node
- Value: ``"http://xml.org/sax/properties/dom-node"`` --- data type:
- org.w3c.dom.Node (not supported in Python 2) --- description: When parsing,
- the current DOM node being visited if this is a DOM iterator; when not parsing,
- the root DOM node for iteration. --- access: (parsing) read-only; (not parsing)
- read/write
+ | value: ``"http://xml.org/sax/properties/dom-node"``
+ | data type: org.w3c.dom.Node (not supported in Python 2)
+ | description: When parsing, the current DOM node being visited if this is
+ a DOM iterator; when not parsing, the root DOM node for iteration.
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: property_xml_string
- Value: ``"http://xml.org/sax/properties/xml-string"`` --- data type: String ---
- description: The literal string of characters that was the source for the
- current event. --- access: read-only
+ | value: ``"http://xml.org/sax/properties/xml-string"``
+ | data type: String
+ | description: The literal string of characters that was the source for the
+ current event.
+ | access: read-only
.. data:: all_properties
Modified: python/branches/release27-maint/Doc/library/zipfile.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/zipfile.rst (original)
+++ python/branches/release27-maint/Doc/library/zipfile.rst Fri Nov 26 09:20:18 2010
@@ -39,6 +39,7 @@
.. class:: ZipFile
+ :noindex:
The class for reading and writing ZIP files. See section
:ref:`zipfile-objects` for constructor details.
Modified: python/branches/release27-maint/Misc/developers.txt
==============================================================================
--- python/branches/release27-maint/Misc/developers.txt (original)
+++ python/branches/release27-maint/Misc/developers.txt Fri Nov 26 09:20:18 2010
@@ -23,6 +23,9 @@
Permissions History
-------------------
+- David Malcolm was given commit access on Oct 27 2010 by GFB,
+ at recommendation by Antoine Pitrou and Raymond Hettinger.
+
- Tal Einat was given commit access on Oct 4 2010 by MvL,
for improving IDLE.
Modified: python/branches/release27-maint/Misc/gdbinit
==============================================================================
--- python/branches/release27-maint/Misc/gdbinit (original)
+++ python/branches/release27-maint/Misc/gdbinit Fri Nov 26 09:20:18 2010
@@ -66,7 +66,7 @@
set $__p = $__p + 1
end
end
- printf "%d\n", $__li
+ printf "%d", $__li
end
# print the current frame - verbose
1
0
Author: georg.brandl
Date: Fri Nov 26 09:16:26 2010
New Revision: 86775
Log:
Blocked revisions 85875-85877,85888-85889,85908-85911,85979,86256,86324,86409,86427,86429,86444-86446,86451 via svnmerge
........
r85875 | georg.brandl | 2010-10-28 10:38:30 +0200 (Do, 28 Okt 2010) | 1 line
Fix bytes/str issues in get-remote-certificate.py.
........
r85876 | georg.brandl | 2010-10-28 11:03:20 +0200 (Do, 28 Okt 2010) | 1 line
#10218: return timeout status from Condition.wait, mirroring other primitives' behavior.
........
r85877 | georg.brandl | 2010-10-28 11:24:56 +0200 (Do, 28 Okt 2010) | 1 line
Condition.wait now returns bool.
........
r85888 | georg.brandl | 2010-10-28 15:01:06 +0200 (Do, 28 Okt 2010) | 1 line
Support new Condition return value in the multiprocessing version.
........
r85889 | georg.brandl | 2010-10-28 15:07:50 +0200 (Do, 28 Okt 2010) | 1 line
Review new Barrier docs.
........
r85908 | georg.brandl | 2010-10-29 07:22:17 +0200 (Fr, 29 Okt 2010) | 1 line
send_bytes obviously needs bytes...
........
r85909 | georg.brandl | 2010-10-29 07:24:24 +0200 (Fr, 29 Okt 2010) | 1 line
Re-add "debugger" label, it is used in pydoc-topics.
........
r85910 | georg.brandl | 2010-10-29 07:30:17 +0200 (Fr, 29 Okt 2010) | 1 line
Port suspicious markup builder and patchlevel.py so that they can be used with Python 2 and 3 without conversion.
........
r85911 | georg.brandl | 2010-10-29 07:36:28 +0200 (Fr, 29 Okt 2010) | 1 line
Fix markup error and update false positive entries from "make suspicious".
........
r85979 | georg.brandl | 2010-10-30 16:33:28 +0200 (Sa, 30 Okt 2010) | 1 line
Fix test_mailbox by supporting context manager protocol for get_file() returns.
........
r86256 | georg.brandl | 2010-11-06 08:19:35 +0100 (Sa, 06 Nov 2010) | 1 line
#10334: add a role to refer to Python source files in SVN.
........
r86324 | georg.brandl | 2010-11-08 17:57:52 +0100 (Mo, 08 Nov 2010) | 1 line
Fix next version name.
........
r86409 | georg.brandl | 2010-11-11 08:26:40 +0100 (Do, 11 Nov 2010) | 1 line
Review the new configparser docs.
........
r86427 | georg.brandl | 2010-11-12 09:09:11 +0100 (Fr, 12 Nov 2010) | 1 line
Switch to Sphinx 1.0.5.
........
r86429 | georg.brandl | 2010-11-12 09:57:12 +0100 (Fr, 12 Nov 2010) | 1 line
Add a deprecated-removed directive that allows to give the version of removal for deprecations.
........
r86444 | georg.brandl | 2010-11-13 07:36:58 +0100 (Sa, 13 Nov 2010) | 1 line
Update pydoc topics.
........
r86445 | georg.brandl | 2010-11-13 07:38:37 +0100 (Sa, 13 Nov 2010) | 1 line
Ignore suspicious-ignore file.
........
r86446 | georg.brandl | 2010-11-13 07:39:58 +0100 (Sa, 13 Nov 2010) | 1 line
Bump to 3.2a4.
........
r86451 | georg.brandl | 2010-11-13 14:25:40 +0100 (Sa, 13 Nov 2010) | 1 line
Minor edits.
........
Modified:
python/branches/release27-maint/ (props changed)
1
0
Author: georg.brandl
Date: Fri Nov 26 09:12:40 2010
New Revision: 86774
Log:
Blocked revisions 85807,85820,85822,85824,85828,85840,85844-85845,85851,85855-85856,85874 via svnmerge
........
r85807 | georg.brandl | 2010-10-23 19:31:52 +0200 (Sa, 23 Okt 2010) | 1 line
#6518: enable context manager protocol for ossaudiodev types.
........
r85820 | georg.brandl | 2010-10-24 16:20:22 +0200 (So, 24 Okt 2010) | 1 line
Remove usage of exception indexing.
........
r85822 | georg.brandl | 2010-10-24 16:21:42 +0200 (So, 24 Okt 2010) | 1 line
Add casts (one needed, one for consistency).
........
r85824 | georg.brandl | 2010-10-24 17:11:22 +0200 (So, 24 Okt 2010) | 6 lines
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
except when configured --with-pydebug.
Emit this warning from the GC shutdown procedure, rather than just printing to stderr.
........
r85828 | georg.brandl | 2010-10-24 22:47:32 +0200 (So, 24 Okt 2010) | 1 line
These are true PyCFunctions, after adding the second argument to oss_self, no need to cast.
........
r85840 | georg.brandl | 2010-10-25 19:50:20 +0200 (Mo, 25 Okt 2010) | 1 line
#3018: tkinter demo fixes for py3k.
........
r85844 | georg.brandl | 2010-10-26 12:39:14 +0200 (Di, 26 Okt 2010) | 1 line
Work a bit more on tkinter demos.
........
r85845 | georg.brandl | 2010-10-26 12:42:16 +0200 (Di, 26 Okt 2010) | 1 line
faqwiz is removed.
........
r85851 | georg.brandl | 2010-10-26 22:12:37 +0200 (Di, 26 Okt 2010) | 1 line
Fix import.
........
r85855 | georg.brandl | 2010-10-27 09:21:54 +0200 (Mi, 27 Okt 2010) | 1 line
Encoding fix.
........
r85856 | georg.brandl | 2010-10-27 09:27:06 +0200 (Mi, 27 Okt 2010) | 1 line
#5975: add unix_dialect to csv module.
........
r85874 | georg.brandl | 2010-10-28 08:42:33 +0200 (Do, 28 Okt 2010) | 1 line
#7351: add more consistent exception name alias.
........
Modified:
python/branches/release27-maint/ (props changed)
1
0