Merged revisions 79822,79828,79862,80067,80069,80080-80081,80084,80432-80433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79822 | georg.brandl | 2010-04-06 08:18:15 +0000 (Di, 06 Apr 2010) | 1 line
#8320: document return value of recv_into().
........
r79828 | georg.brandl | 2010-04-06 14:33:44 +0000 (Di, 06 Apr 2010) | 1 line
Add JP.
........
r79862 | georg.brandl | 2010-04-06 20:27:59 +0000 (Di, 06 Apr 2010) | 1 line
Fix syntax.
........
r80067 | georg.brandl | 2010-04-14 08:53:38 +0000 (Mi, 14 Apr 2010) | 1 line
#5341: typo.
........
r80069 | georg.brandl | 2010-04-14 13:50:31 +0000 (Mi, 14 Apr 2010) | 1 line
Add an x-ref to where the O_ constants are documented and move the SEEK_ constants after lseek().
........
r80080 | georg.brandl | 2010-04-14 19:16:38 +0000 (Mi, 14 Apr 2010) | 1 line
#8399: add note about Windows and O_BINARY.
........
r80081 | georg.brandl | 2010-04-14 21:34:44 +0000 (Mi, 14 Apr 2010) | 1 line
#5250: document __instancecheck__ and __subclasscheck__. I hope the part about the class/metaclass distinction is understandable.
........
r80084 | georg.brandl | 2010-04-14 21:46:45 +0000 (Mi, 14 Apr 2010) | 1 line
Fix missing.
........
r80432 | georg.brandl | 2010-04-24 08:56:58 +0000 (Sa, 24 Apr 2010) | 1 line
Markup fixes.
........
r80433 | georg.brandl | 2010-04-24 09:08:10 +0000 (Sa, 24 Apr 2010) | 1 line
#7507: quote "!" in pipes.quote(); it is a special character for some shells.
........
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 1bc9126..eb9cb19 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -677,6 +677,16 @@
Availability: Unix, Windows.
+.. data:: SEEK_SET
+ SEEK_CUR
+ SEEK_END
+
+ Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
+ respectively. Availability: Windows, Unix.
+
+ .. versionadded:: 2.5
+
+
.. function:: open(file, flags[, mode])
Open the file *file* and set various flags according to *flags* and possibly its
@@ -686,7 +696,8 @@
For a description of the flag and mode values, see the C run-time documentation;
flag constants (like :const:`O_RDONLY` and :const:`O_WRONLY`) are defined in
- this module too (see below).
+ this module too (see :ref:`open-constants`). In particular, on Windows adding
+ :const:`O_BINARY` is needed to open files in binary mode.
Availability: Unix, Windows.
@@ -774,6 +785,12 @@
:func:`fdopen`, or :data:`sys.stdout` or :data:`sys.stderr`, use its
:meth:`~file.write` method.
+
+.. _open-constants:
+
+``open()`` flag constants
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
The following constants are options for the *flags* parameter to the
:func:`~os.open` function. They can be combined using the bitwise OR operator
``|``. Some of them are not available on all platforms. For descriptions of
@@ -825,16 +842,6 @@
the C library.
-.. data:: SEEK_SET
- SEEK_CUR
- SEEK_END
-
- Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
- respectively. Availability: Windows, Unix.
-
- .. versionadded:: 2.5
-
-
.. _os-file-dir:
Files and Directories
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index 51f3b82..22579ae 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -664,10 +664,10 @@
.. method:: socket.recv_into(buffer[, nbytes[, flags]])
Receive up to *nbytes* bytes from the socket, storing the data into a buffer
- rather than creating a new string. If *nbytes* is not specified (or 0),
- receive up to the size available in the given buffer. See the Unix manual page
- :manpage:`recv(2)` for the meaning of the optional argument *flags*; it defaults
- to zero.
+ rather than creating a new string. If *nbytes* is not specified (or 0),
+ receive up to the size available in the given buffer. Returns the number of
+ bytes received. See the Unix manual page :manpage:`recv(2)` for the meaning
+ of the optional argument *flags*; it defaults to zero.
.. versionadded:: 2.5
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 5189f1f..8c16d4e 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1757,6 +1757,48 @@
locking/synchronization.
+Customizing instance and subclass checks
+----------------------------------------
+
+.. versionadded:: 2.6
+
+The following methods are used to override the default behavior of the
+:func:`isinstance` and :func:`issubclass` built-in functions.
+
+In particular, the metaclass :class:`abc.ABCMeta` implements these methods in
+order to allow the addition of Abstract Base Classes (ABCs) as "virtual base
+classes" to any class or type (including built-in types), and including to other
+ABCs.
+
+.. method:: class.__instancecheck__(self, instance)
+
+ Return true if *instance* should be considered a (direct or indirect)
+ instance of *class*. If defined, called to implement ``isinstance(instance,
+ class)``.
+
+
+.. method:: class.__subclasscheck__(self, subclass)
+
+ Return true if *subclass* should be considered a (direct or indirect)
+ subclass of *class*. If defined, called to implement ``issubclass(subclass,
+ class)``.
+
+
+Note that these methods are looked up on the type (metaclass) of a class. They
+cannot be defined as class methods in the actual class. This is consistent with
+the lookup of special methods that are called on instances, only that in this
+case the instance is itself a class.
+
+.. seealso::
+
+ :pep:`3119` - Introducing Abstract Base Classes
+ Includes the specification for customizing :func:`isinstance` and
+ :func:`issubclass` behavior through :meth:`__instancecheck__` and
+ :meth:`__subclasscheck__`, with motivation for this functionality in the
+ context of adding Abstract Base Classes (see the :mod:`abc` module) to the
+ language.
+
+
.. _callable-types:
Emulating callable objects