[pypy-commit] pypy py3.3: PEP3151: OSError is IOError is EnvironmentError is socket.error is select.error!
amauryfa
noreply at buildbot.pypy.org
Thu Jul 3 23:58:16 CEST 2014
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3.3
Changeset: r72344:38117d8ea60f
Date: 2014-06-23 09:47 +0200
http://bitbucket.org/pypy/pypy/changeset/38117d8ea60f/
Log: PEP3151: OSError is IOError is EnvironmentError is socket.error is
select.error!
diff --git a/pypy/module/_socket/interp_socket.py b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -565,8 +565,7 @@
class SocketAPI:
def __init__(self, space):
- self.w_error = space.new_exception_class(
- "_socket.error", space.w_IOError)
+ self.w_error = space.w_OSError
self.w_herror = space.new_exception_class(
"_socket.herror", self.w_error)
self.w_gaierror = space.new_exception_class(
diff --git a/pypy/module/exceptions/interp_exceptions.py b/pypy/module/exceptions/interp_exceptions.py
--- a/pypy/module/exceptions/interp_exceptions.py
+++ b/pypy/module/exceptions/interp_exceptions.py
@@ -33,11 +33,11 @@
+-- AssertionError
+-- AttributeError
+-- BufferError
- +-- EnvironmentError
- | +-- IOError
- | +-- OSError
- | +-- WindowsError (Windows)
- | +-- VMSError (VMS)
+ +-- OSError
+ | = EnvironmentError
+ | = IOError
+ | = WindowsError (Windows)
+ | = VMSError (VMS)
+-- EOFError
+-- ImportError
+-- LookupError
@@ -439,8 +439,8 @@
W_Warning,
"""Base class for warnings about features which will be deprecated in the future.""")
-class W_EnvironmentError(W_Exception):
- """Base class for I/O related errors."""
+class W_OSError(W_Exception):
+ """OS system call failed."""
def __init__(self, space):
self.w_errno = space.w_None
@@ -484,21 +484,21 @@
))
return W_BaseException.descr_str(self, space)
-W_EnvironmentError.typedef = TypeDef(
- 'EnvironmentError',
+W_OSError.typedef = TypeDef(
+ 'OSError',
W_Exception.typedef,
- __doc__ = W_EnvironmentError.__doc__,
- __new__ = _new(W_EnvironmentError),
- __reduce__ = interp2app(W_EnvironmentError.descr_reduce),
- __init__ = interp2app(W_EnvironmentError.descr_init),
- __str__ = interp2app(W_EnvironmentError.descr_str),
- errno = readwrite_attrproperty_w('w_errno', W_EnvironmentError),
- strerror = readwrite_attrproperty_w('w_strerror', W_EnvironmentError),
- filename = readwrite_attrproperty_w('w_filename', W_EnvironmentError),
+ __doc__ = W_OSError.__doc__,
+ __new__ = _new(W_OSError),
+ __reduce__ = interp2app(W_OSError.descr_reduce),
+ __init__ = interp2app(W_OSError.descr_init),
+ __str__ = interp2app(W_OSError.descr_str),
+ errno = readwrite_attrproperty_w('w_errno', W_OSError),
+ strerror = readwrite_attrproperty_w('w_strerror', W_OSError),
+ filename = readwrite_attrproperty_w('w_filename', W_OSError),
)
-W_OSError = _new_exception('OSError', W_EnvironmentError,
- """OS system call failed.""")
+W_EnvironmentError = W_OSError
+W_IOError = W_OSError
class W_WindowsError(W_OSError):
"""MS-Windows OS system call failed."""
@@ -643,9 +643,6 @@
W_NameError = _new_exception('NameError', W_Exception,
"""Name not found globally.""")
-W_IOError = _new_exception('IOError', W_EnvironmentError,
- """I/O operation failed.""")
-
class W_SyntaxError(W_Exception):
"""Invalid syntax."""
diff --git a/pypy/module/select/__init__.py b/pypy/module/select/__init__.py
--- a/pypy/module/select/__init__.py
+++ b/pypy/module/select/__init__.py
@@ -11,7 +11,7 @@
interpleveldefs = {
'select': 'interp_select.select',
- 'error' : 'space.fromcache(interp_select.Cache).w_error'
+ 'error' : 'space.w_OSError',
}
if os.name =='posix':
diff --git a/pypy/module/select/interp_select.py b/pypy/module/select/interp_select.py
--- a/pypy/module/select/interp_select.py
+++ b/pypy/module/select/interp_select.py
@@ -7,10 +7,6 @@
defaultevents = rpoll.POLLIN | rpoll.POLLOUT | rpoll.POLLPRI
-class Cache:
- def __init__(self, space):
- self.w_error = space.new_exception_class("select.error")
-
def poll(space):
"""Returns a polling object, which supports registering and
unregistering file descriptors, and then polling them for I/O events."""
@@ -63,9 +59,8 @@
try:
retval = rpoll.poll(self.fddict, timeout)
except rpoll.PollError, e:
- w_errortype = space.fromcache(Cache).w_error
message = e.get_msg()
- raise OperationError(w_errortype,
+ raise OperationError(space.w_OSError,
space.newtuple([space.wrap(e.errno),
space.wrap(message)]))
finally:
@@ -125,8 +120,7 @@
if res < 0:
errno = _c.geterrno()
msg = _c.socket_strerror_str(errno)
- w_errortype = space.fromcache(Cache).w_error
- raise OperationError(w_errortype, space.newtuple([
+ raise OperationError(space.w_OSError, space.newtuple([
space.wrap(errno), space.wrap(msg)]))
resin_w = []
More information about the pypy-commit
mailing list