[pypy-commit] pypy py3.3: fix OSError aliases (Environment/IOError) causing an obscure clash of names w/
pjenvey
noreply at buildbot.pypy.org
Fri Jul 25 21:17:12 CEST 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3.3
Changeset: r72483:2fd763f1298c
Date: 2014-07-25 12:15 -0700
http://bitbucket.org/pypy/pypy/changeset/2fd763f1298c/
Log: fix OSError aliases (Environment/IOError) causing an obscure clash
of names w/ export_struct as used by cpyext. fixes translation but
breaks their cpyext API names for now (+ a failing test for this)
diff --git a/pypy/module/_io/interp_io.py b/pypy/module/_io/interp_io.py
--- a/pypy/module/_io/interp_io.py
+++ b/pypy/module/_io/interp_io.py
@@ -4,7 +4,6 @@
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import (
TypeDef, interp_attrproperty, generic_new_descr)
-from pypy.module.exceptions.interp_exceptions import W_IOError
from pypy.module._io.interp_fileio import W_FileIO
from pypy.module._io.interp_textio import W_TextIOWrapper
from rpython.rtyper.module.ll_os_stat import STAT_FIELD_TYPES
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -454,6 +454,10 @@
# PyExc_NameError, PyExc_MemoryError, PyExc_RuntimeError,
# PyExc_UnicodeEncodeError, PyExc_UnicodeDecodeError, ...
for exc_name in exceptions.Module.interpleveldefs.keys():
+ if exc_name in ('EnvironmentError', 'IOError'):
+ # FIXME: aliases of OSError cause a clash of names via
+ # export_struct
+ continue
GLOBALS['PyExc_' + exc_name] = (
'PyTypeObject*',
'space.gettypeobject(interp_exceptions.W_%s.typedef)'% (exc_name, ))
diff --git a/pypy/module/cpyext/test/test_exception.py b/pypy/module/cpyext/test/test_exception.py
--- a/pypy/module/cpyext/test/test_exception.py
+++ b/pypy/module/cpyext/test/test_exception.py
@@ -1,4 +1,5 @@
from pypy.module.cpyext.test.test_api import BaseApiTest
+from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
from pypy.module.cpyext.pyobject import make_ref
class TestExceptions(BaseApiTest):
@@ -27,3 +28,16 @@
api.PyException_SetCause(w_exc, make_ref(space, w_cause))
assert space.is_w(api.PyException_GetCause(w_exc), w_cause)
+
+class AppTestExceptions(AppTestCpythonExtensionBase):
+
+ def test_OSError_aliases(self):
+ module = self.import_extension('foo', [
+ ("get_aliases", "METH_NOARGS",
+ """
+ return PyTuple_Pack(2,
+ PyExc_EnvironmentError,
+ PyExc_IOError);
+ """),
+ ])
+ assert module.get_aliases() == (OSError, OSError)
diff --git a/pypy/module/exceptions/__init__.py b/pypy/module/exceptions/__init__.py
--- a/pypy/module/exceptions/__init__.py
+++ b/pypy/module/exceptions/__init__.py
@@ -21,14 +21,14 @@
'ConnectionResetError': 'interp_exceptions.W_ConnectionResetError',
'DeprecationWarning' : 'interp_exceptions.W_DeprecationWarning',
'EOFError' : 'interp_exceptions.W_EOFError',
- 'EnvironmentError' : 'interp_exceptions.W_EnvironmentError',
+ 'EnvironmentError' : 'interp_exceptions.W_OSError',
'Exception' : 'interp_exceptions.W_Exception',
'FileExistsError': 'interp_exceptions.W_FileExistsError',
'FileNotFoundError': 'interp_exceptions.W_FileNotFoundError',
'FloatingPointError' : 'interp_exceptions.W_FloatingPointError',
'FutureWarning' : 'interp_exceptions.W_FutureWarning',
'GeneratorExit' : 'interp_exceptions.W_GeneratorExit',
- 'IOError' : 'interp_exceptions.W_IOError',
+ 'IOError' : 'interp_exceptions.W_OSError',
'ImportError' : 'interp_exceptions.W_ImportError',
'ImportWarning' : 'interp_exceptions.W_ImportWarning',
'IndentationError' : 'interp_exceptions.W_IndentationError',
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
@@ -497,9 +497,6 @@
filename = readwrite_attrproperty_w('w_filename', W_OSError),
)
-W_EnvironmentError = W_OSError
-W_IOError = W_OSError
-
class W_WindowsError(W_OSError):
"""MS-Windows OS system call failed."""
More information about the pypy-commit
mailing list