[pypy-svn] r67595 - in pypy/branch/windowserror/pypy: annotation rpython translator/c/test
afa at codespeak.net
afa at codespeak.net
Wed Sep 9 18:08:41 CEST 2009
Author: afa
Date: Wed Sep 9 18:08:40 2009
New Revision: 67595
Modified:
pypy/branch/windowserror/pypy/annotation/builtin.py
pypy/branch/windowserror/pypy/annotation/classdef.py
pypy/branch/windowserror/pypy/rpython/rbuiltin.py
pypy/branch/windowserror/pypy/translator/c/test/test_extfunc.py
Log:
Provide specific annotation for WindowsError.__init__.
The previous test passes.
Modified: pypy/branch/windowserror/pypy/annotation/builtin.py
==============================================================================
--- pypy/branch/windowserror/pypy/annotation/builtin.py (original)
+++ pypy/branch/windowserror/pypy/annotation/builtin.py Wed Sep 9 18:08:40 2009
@@ -270,6 +270,9 @@
def OSError_init(s_self, *args):
pass
+def WindowsError_init(s_self, *args):
+ pass
+
def termios_error_init(s_self, *args):
pass
@@ -386,6 +389,15 @@
BUILTIN_ANALYZERS[getattr(OSError.__init__, 'im_func', OSError.__init__)] = (
OSError_init)
+try:
+ WindowsError
+except NameError:
+ pass
+else:
+ BUILTIN_ANALYZERS[getattr(WindowsError.__init__, 'im_func',
+ WindowsError.__init__)] = (
+ WindowsError_init)
+
BUILTIN_ANALYZERS[sys.getdefaultencoding] = conf
try:
import unicodedata
Modified: pypy/branch/windowserror/pypy/annotation/classdef.py
==============================================================================
--- pypy/branch/windowserror/pypy/annotation/classdef.py (original)
+++ pypy/branch/windowserror/pypy/annotation/classdef.py Wed Sep 9 18:08:40 2009
@@ -442,6 +442,13 @@
}
try:
+ WindowsError
+except NameError:
+ pass
+else:
+ FORCE_ATTRIBUTES_INTO_CLASSES[WindowsError] = {'winerror': SomeInteger()}
+
+try:
import termios
except ImportError:
pass
Modified: pypy/branch/windowserror/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/branch/windowserror/pypy/rpython/rbuiltin.py (original)
+++ pypy/branch/windowserror/pypy/rpython/rbuiltin.py Wed Sep 9 18:08:40 2009
@@ -268,6 +268,16 @@
v_errno = hop.inputarg(lltype.Signed, arg=1)
r_self.setfield(v_self, 'errno', v_errno, hop.llops)
+def rtype_WindowsError__init__(hop):
+ if hop.nb_args == 2:
+ raise TyperError("WindowsError() should not be called with "
+ "a single argument")
+ if hop.nb_args >= 3:
+ v_self = hop.args_v[0]
+ r_self = hop.args_r[0]
+ v_error = hop.inputarg(lltype.Signed, arg=1)
+ r_self.setfield(v_self, 'winerror', v_error, hop.llops)
+
def rtype_we_are_translated(hop):
hop.exception_cannot_occur()
return hop.inputconst(lltype.Bool, True)
@@ -318,6 +328,15 @@
BUILTIN_TYPER[getattr(OSError.__init__, 'im_func', OSError.__init__)] = (
rtype_OSError__init__)
+try:
+ WindowsError
+except NameError:
+ pass
+else:
+ BUILTIN_TYPER[
+ getattr(WindowsError.__init__, 'im_func', WindowsError.__init__)] = (
+ rtype_WindowsError__init__)
+
BUILTIN_TYPER[object.__init__] = rtype_object__init__
# annotation of low-level types
Modified: pypy/branch/windowserror/pypy/translator/c/test/test_extfunc.py
==============================================================================
--- pypy/branch/windowserror/pypy/translator/c/test/test_extfunc.py (original)
+++ pypy/branch/windowserror/pypy/translator/c/test/test_extfunc.py Wed Sep 9 18:08:40 2009
@@ -180,7 +180,7 @@
try:
os.stat("nonexistentdir/nonexistentfile")
except WindowsError, e:
- return e.winerror, e.errno
+ return e.winerror
f = compile(call_stat, [])
res = f()
expected = call_stat()
More information about the Pypy-commit
mailing list