[pypy-svn] pypy jitypes2: (david, antocuni)
antocuni
commits-noreply at bitbucket.org
Thu Jan 20 19:52:09 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: jitypes2
Changeset: r41082:b9d43da084ad
Date: 2011-01-20 18:09 +0100
http://bitbucket.org/pypy/pypy/changeset/b9d43da084ad/
Log: (david, antocuni) IN-PROGRESS: move logic to a helper method, so
that we don't have to rewrite it in the specialized class
diff --git a/lib-python/modified-2.7.0/test/test_support.py b/lib-python/modified-2.7.0/test/test_support.py
--- a/lib-python/modified-2.7.0/test/test_support.py
+++ b/lib-python/modified-2.7.0/test/test_support.py
@@ -1066,7 +1066,7 @@
if '--pdb' in sys.argv:
import pdb, traceback
traceback.print_tb(exc_info[2])
- pdb.post_mortem(exc_info[2], pdb.Pdb)
+ pdb.pdb.post_mortem(exc_info[2])
# ----------------------------------
diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -232,8 +232,22 @@
argtypes = [type(arg) for arg in args]
newargs = self._unwrap_args(argtypes, args)
- restype = self._restype_
- funcptr = self._getfuncptr(argtypes, restype, thisarg)
+ funcptr = self._getfuncptr(argtypes, self._restype_, thisarg)
+ result = self._call_funcptr(funcptr, *newargs)
+ # The 'errcheck' protocol
+ if self._errcheck_:
+ v = self._errcheck_(result, self, args)
+ # If the errcheck funtion failed, let it throw
+ # If the errcheck function returned callargs unchanged,
+ # continue normal processing.
+ # If the errcheck function returned something else,
+ # use that as result.
+ if v is not args:
+ result = v
+ return result
+
+ def _call_funcptr(self, funcptr, *newargs):
+
if self._flags_ & _rawffi.FUNCFLAG_USE_ERRNO:
set_errno(_rawffi.get_errno())
if self._flags_ & _rawffi.FUNCFLAG_USE_LASTERROR:
@@ -247,20 +261,8 @@
set_errno(_rawffi.get_errno())
if self._flags_ & _rawffi.FUNCFLAG_USE_LASTERROR:
set_last_error(_rawffi.get_last_error())
- result = self._build_result(restype, result, newargs)
-
- # The 'errcheck' protocol
- if self._errcheck_:
- v = self._errcheck_(result, self, args)
- # If the errcheck funtion failed, let it throw
- # If the errcheck function returned callargs unchanged,
- # continue normal processing.
- # If the errcheck function returned something else,
- # use that as result.
- if v is not args:
- result = v
-
- return result
+ #
+ return self._build_result(self._restype_, result, newargs)
def _getfuncptr_fromaddress(self, argshapes, resshape):
address = self._get_address()
@@ -534,7 +536,8 @@
return (len(args) == self._num_args and
self.callable is None and
not self._com_index and
- self._argtypes_ is not None)
+ self._argtypes_ is not None and
+ self._errcheck_ is None)
def __call__(self, *args):
if not self._are_assumptions_met(args):
@@ -550,32 +553,6 @@
restype = self._restype_
funcptr = self._getfuncptr(argtypes, restype, thisarg)
- if self._flags_ & _rawffi.FUNCFLAG_USE_ERRNO:
- set_errno(_rawffi.get_errno())
- if self._flags_ & _rawffi.FUNCFLAG_USE_LASTERROR:
- set_last_error(_rawffi.get_last_error())
- try:
- result = funcptr(*newargs)
- ## resbuffer = funcptr(*[arg._get_buffer_for_param()._buffer
- ## for arg in args])
- finally:
- if self._flags_ & _rawffi.FUNCFLAG_USE_ERRNO:
- set_errno(_rawffi.get_errno())
- if self._flags_ & _rawffi.FUNCFLAG_USE_LASTERROR:
- set_last_error(_rawffi.get_last_error())
- result = self._build_result(restype, result, newargs)
-
- # The 'errcheck' protocol
- if self._errcheck_:
- v = self._errcheck_(result, self, args)
- # If the errcheck funtion failed, let it throw
- # If the errcheck function returned callargs unchanged,
- # continue normal processing.
- # If the errcheck function returned something else,
- # use that as result.
- if v is not args:
- result = v
-
- return result
+ return self._call_funcptr(funcptr, *newargs)
return CFuncPtr_1
More information about the Pypy-commit
mailing list