[pypy-svn] r74659 - in pypy/trunk/pypy/module/cpyext: . test
afa at codespeak.net
afa at codespeak.net
Fri May 21 23:57:20 CEST 2010
Author: afa
Date: Fri May 21 23:57:17 2010
New Revision: 74659
Modified:
pypy/trunk/pypy/module/cpyext/api.py
pypy/trunk/pypy/module/cpyext/eval.py
pypy/trunk/pypy/module/cpyext/test/test_eval.py
Log:
really fix this line, with a test this time.
Modified: pypy/trunk/pypy/module/cpyext/api.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/api.py (original)
+++ pypy/trunk/pypy/module/cpyext/api.py Fri May 21 23:57:17 2010
@@ -67,6 +67,7 @@
FILEP = rffi.COpaquePtr('FILE')
fopen = rffi.llexternal('fopen', [CONST_STRING, CONST_STRING], FILEP)
+fclose = rffi.llexternal('fclose', [FILEP], rffi.INT)
fwrite = rffi.llexternal('fwrite',
[rffi.VOIDP, rffi.SIZE_T, rffi.SIZE_T, FILEP],
rffi.SIZE_T)
Modified: pypy/trunk/pypy/module/cpyext/eval.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/eval.py (original)
+++ pypy/trunk/pypy/module/cpyext/eval.py Fri May 21 23:57:17 2010
@@ -106,7 +106,7 @@
if count < BUF_SIZE:
if feof(fp):
break
- PyErr_SetFromErrno(PyExc_IOError)
+ PyErr_SetFromErrno(space, space.w_IOError)
finally:
lltype.free(buf, flavor='raw')
return run_string(space, source, filename, start, w_globals, w_locals)
Modified: pypy/trunk/pypy/module/cpyext/test/test_eval.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/test/test_eval.py (original)
+++ pypy/trunk/pypy/module/cpyext/test/test_eval.py Fri May 21 23:57:17 2010
@@ -3,7 +3,7 @@
from pypy.module.cpyext.test.test_api import BaseApiTest
from pypy.module.cpyext.eval import (
Py_single_input, Py_file_input, Py_eval_input)
-from pypy.module.cpyext.api import fopen
+from pypy.module.cpyext.api import fopen, fclose
from pypy.interpreter.gateway import interp2app
from pypy.tool.udir import udir
@@ -87,10 +87,17 @@
filename = rffi.str2charp(str(filepath))
w_globals = w_locals = space.newdict()
api.PyRun_File(fp, filename, Py_file_input, w_globals, w_locals)
- rffi.free_charp(filename)
+ fclose(fp)
assert api.PyErr_Occurred() is space.w_ZeroDivisionError
api.PyErr_Clear()
+ # retry on closed file
+ api.PyRun_File(fp, filename, Py_file_input, w_globals, w_locals)
+ assert api.PyErr_Occurred() is space.w_OSError
+ api.PyErr_Clear()
+
+ rffi.free_charp(filename)
+
def test_getbuiltins(self, space, api):
assert api.PyEval_GetBuiltins() is space.builtin.w_dict
More information about the Pypy-commit
mailing list