[Python-checkins] cpython: Replace mentions of socket.error.
antoine.pitrou
python-checkins at python.org
Wed Oct 12 17:57:30 CEST 2011
http://hg.python.org/cpython/rev/aeff792ea043
changeset: 72884:aeff792ea043
user: Antoine Pitrou <solipsis at pitrou.net>
date: Wed Oct 12 17:53:43 2011 +0200
summary:
Replace mentions of socket.error.
files:
Doc/library/ftplib.rst | 3 +-
Doc/library/socket.rst | 35 ++++++++++++-----------
Doc/library/ssl.rst | 8 +++--
Doc/library/telnetlib.rst | 6 +++-
Doc/library/urllib.error.rst | 3 +-
5 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst
--- a/Doc/library/ftplib.rst
+++ b/Doc/library/ftplib.rst
@@ -144,8 +144,7 @@
The set of all exceptions (as a tuple) that methods of :class:`FTP`
instances may raise as a result of problems with the FTP connection (as
opposed to programming errors made by the caller). This set includes the
- four exceptions listed above as well as :exc:`socket.error` and
- :exc:`IOError`.
+ four exceptions listed above as well as :exc:`OSError`.
.. seealso::
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -104,8 +104,9 @@
numeric address in *host* portion.
All errors raise exceptions. The normal exceptions for invalid argument types
-and out-of-memory conditions can be raised; errors related to socket or address
-semantics raise :exc:`socket.error` or one of its subclasses.
+and out-of-memory conditions can be raised; starting from Python 3.3, errors
+related to socket or address semantics raise :exc:`OSError` or one of its
+subclasses (they used to raise :exc:`socket.error`).
Non-blocking mode is supported through :meth:`~socket.setblocking`. A
generalization of this based on timeouts is supported through
@@ -481,7 +482,7 @@
Unix manual page :manpage:`inet(3)` for details.
If the IPv4 address string passed to this function is invalid,
- :exc:`socket.error` will be raised. Note that exactly what is valid depends on
+ :exc:`OSError` will be raised. Note that exactly what is valid depends on
the underlying C implementation of :c:func:`inet_aton`.
:func:`inet_aton` does not support IPv6, and :func:`inet_pton` should be used
@@ -498,7 +499,7 @@
argument.
If the byte sequence passed to this function is not exactly 4 bytes in
- length, :exc:`socket.error` will be raised. :func:`inet_ntoa` does not
+ length, :exc:`OSError` will be raised. :func:`inet_ntoa` does not
support IPv6, and :func:`inet_ntop` should be used instead for IPv4/v6 dual
stack support.
@@ -512,7 +513,7 @@
Supported values for *address_family* are currently :const:`AF_INET` and
:const:`AF_INET6`. If the IP address string *ip_string* is invalid,
- :exc:`socket.error` will be raised. Note that exactly what is valid depends on
+ :exc:`OSError` will be raised. Note that exactly what is valid depends on
both the value of *address_family* and the underlying implementation of
:c:func:`inet_pton`.
@@ -530,7 +531,7 @@
Supported values for *address_family* are currently :const:`AF_INET` and
:const:`AF_INET6`. If the string *packed_ip* is not the correct length for the
specified address family, :exc:`ValueError` will be raised. A
- :exc:`socket.error` is raised for errors from the call to :func:`inet_ntop`.
+ :exc:`OSError` is raised for errors from the call to :func:`inet_ntop`.
Availability: Unix (maybe not all platforms).
@@ -596,7 +597,7 @@
.. function:: sethostname(name)
Set the machine's hostname to *name*. This will raise a
- :exc:`socket.error` if you don't have enough rights.
+ :exc:`OSError` if you don't have enough rights.
Availability: Unix.
@@ -607,7 +608,7 @@
Return a list of network interface information
(index int, name string) tuples.
- :exc:`socket.error` if the system call fails.
+ :exc:`OSError` if the system call fails.
Availability: Unix.
@@ -618,7 +619,7 @@
Return a network interface index number corresponding to an
interface name.
- :exc:`socket.error` if no interface with the given name exists.
+ :exc:`OSError` if no interface with the given name exists.
Availability: Unix.
@@ -629,7 +630,7 @@
Return a network interface name corresponding to a
interface index number.
- :exc:`socket.error` if no interface with the given index exists.
+ :exc:`OSError` if no interface with the given index exists.
Availability: Unix.
@@ -1182,13 +1183,13 @@
af, socktype, proto, canonname, sa = res
try:
s = socket.socket(af, socktype, proto)
- except socket.error as msg:
+ except OSError as msg:
s = None
continue
try:
s.bind(sa)
s.listen(1)
- except socket.error as msg:
+ except OSError as msg:
s.close()
s = None
continue
@@ -1217,12 +1218,12 @@
af, socktype, proto, canonname, sa = res
try:
s = socket.socket(af, socktype, proto)
- except socket.error as msg:
+ except OSError as msg:
s = None
continue
try:
s.connect(sa)
- except socket.error as msg:
+ except OSError as msg:
s.close()
s = None
continue
@@ -1294,18 +1295,18 @@
try:
s.send(cf)
- except socket.error:
+ except OSError:
print('Error sending CAN frame')
try:
s.send(build_can_frame(0x01, b'\x01\x02\x03'))
- except socket.error:
+ except OSError:
print('Error sending CAN frame')
Running an example several times with too small delay between executions, could
lead to this error::
- socket.error: [Errno 98] Address already in use
+ OSError: [Errno 98] Address already in use
This is because the previous execution has left the socket in a ``TIME_WAIT``
state, and can't be immediately reused.
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -53,9 +53,11 @@
(currently provided by the OpenSSL library). This signifies some
problem in the higher-level encryption and authentication layer that's
superimposed on the underlying network connection. This error
- is a subtype of :exc:`socket.error`, which in turn is a subtype of
- :exc:`IOError`. The error code and message of :exc:`SSLError` instances
- are provided by the OpenSSL library.
+ is a subtype of :exc:`OSError`. The error code and message of
+ :exc:`SSLError` instances are provided by the OpenSSL library.
+
+ .. versionchanged:: 3.3
+ :exc:`SSLError` used to be a subtype of :exc:`socket.error`.
.. exception:: CertificateError
diff --git a/Doc/library/telnetlib.rst b/Doc/library/telnetlib.rst
--- a/Doc/library/telnetlib.rst
+++ b/Doc/library/telnetlib.rst
@@ -162,9 +162,13 @@
.. method:: Telnet.write(buffer)
Write a byte string to the socket, doubling any IAC characters. This can
- block if the connection is blocked. May raise :exc:`socket.error` if the
+ block if the connection is blocked. May raise :exc:`OSError` if the
connection is closed.
+ .. versionchanged:: 3.3
+ This method used to raise :exc:`socket.error`, which is now an alias
+ of :exc:`OSError`.
+
.. method:: Telnet.interact()
diff --git a/Doc/library/urllib.error.rst b/Doc/library/urllib.error.rst
--- a/Doc/library/urllib.error.rst
+++ b/Doc/library/urllib.error.rst
@@ -21,8 +21,7 @@
.. attribute:: reason
The reason for this error. It can be a message string or another
- exception instance (:exc:`socket.error` for remote URLs, :exc:`OSError`
- for local URLs).
+ exception instance such as :exc:`OSError`.
.. exception:: HTTPError
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list