called with a non-string parameter.
.. note::
- These functions have been renamed to PyBytes_* in Python 3.x. The PyBytes
- names are also available in 2.6.
+
+ These functions have been renamed to PyBytes_* in Python 3.x. Unless
+ otherwise noted, the PyBytes functions available in 3.x are aliased to their
+ PyString_* equivalents to help porting.
.. index:: object: string
reference-count-neutral; you own the object after the call if and only if you
owned it before the call.)
+ .. note::
+
+ This function is not available in 3.x and does not have a PyBytes alias.
+
.. cfunction:: PyObject* PyString_InternFromString(const char *v)
been interned, or a new ("owned") reference to an earlier interned string object
with the same value.
+ .. note::
+
+ This function is not available in 3.x and does not have a PyBytes alias.
+
.. cfunction:: PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
The codec to be used is looked up using the Python codec registry. Return
*NULL* if an exception was raised by the codec.
+ .. note::
+
+ This function is not available in 3.x and does not have a PyBytes alias.
+
.. versionchanged:: 2.5
This function used an :ctype:`int` type for *size*. This might require
changes in your code for properly supporting 64-bit systems.
The codec to be used is looked up using the Python codec registry. Return *NULL*
if an exception was raised by the codec.
+ .. note::
+
+ This function is not available in 3.x and does not have a PyBytes alias.
+
.. cfunction:: PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
:meth:`encode` method. The codec to be used is looked up using the Python codec
registry. Return *NULL* if an exception was raised by the codec.
+ .. note::
+
+ This function is not available in 3.x and does not have a PyBytes alias.
+
.. versionchanged:: 2.5
This function used an :ctype:`int` type for *size*. This might require
changes in your code for properly supporting 64-bit systems.
parameters of the same name in the string :meth:`encode` method. The codec to be
used is looked up using the Python codec registry. Return *NULL* if an exception
was raised by the codec.
+
+ .. note::
+
+ This function is not available in 3.x and does not have a PyBytes alias.
.. class:: StringIO([initial_value[, encoding[, errors[, newline]]]])
- An in-memory stream for text. It in inherits :class:`TextIOWrapper`.
+ An in-memory stream for text. It inherits :class:`TextIOWrapper`.
Create a new StringIO stream with an inital value, encoding, error handling,
and newline setting. See :class:`TextIOWrapper`\'s constructor for more
.. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...))
- This is another name for :func:`linux_distribution`.
+ This is an old version of the functionality now provided by
+ :func:`linux_distribution`. For new code, please use the
+ :func:`linux_distribution`.
+
+ The only difference between the two is that ``dist()`` always
+ returns the short name of the distribution taken from the
+ ``supported_dists`` parameter.
+
+ .. deprecated:: 2.6
.. function:: linux_distribution(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...), full_distribution_name=1)
parameters. ``id`` is the item in parentheses after the version number. It
is usually the version codename.
+ .. versionadded:: 2.6
+
.. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=2048)
Tries to determine the libc version against which the file executable (defaults
Some notes on socket blocking and timeouts: A socket object can be in one of
three modes: blocking, non-blocking, or timeout. Sockets are always created in
-blocking mode. In blocking mode, operations block until complete. In
+blocking mode. In blocking mode, operations block until complete or
+the system returns an error (such as connection timed out). In
non-blocking mode, operations fail (with an error that is unfortunately
system-dependent) if they cannot be completed immediately. In timeout mode,
operations fail if they cannot be completed within the timeout specified for the
-socket. The :meth:`setblocking` method is simply a shorthand for certain
-:meth:`settimeout` calls.
+socket or if the system returns an error. The :meth:`setblocking` method is simply
+a shorthand for certain :meth:`settimeout` calls.
Timeout mode internally sets the socket in non-blocking mode. The blocking and
timeout modes are shared between file descriptors and socket objects that refer
Note that the :meth:`connect` operation is subject to the timeout setting, and
in general it is recommended to call :meth:`settimeout` before calling
-:meth:`connect`.
+:meth:`connect` or pass a timeout parameter to :meth:`create_connection`.
+The system network stack may return a connection timeout error
+of its own regardless of any python socket timeout setting.
.. method:: socket.setsockopt(level, optname, value)
Flush the internal buffer, like ``stdio``'s :cfunc:`fflush`. This may be a
no-op on some file-like objects.
+ .. note::
+
+ :meth:`flush` does not necessarily write the file's data to disk. Use
+ :meth:`flush` followed by :func:`os.fsync` to ensure this behavior.
+
.. method:: file.fileno()