diff options
author | Thomas Heller <theller@ctypes.org> | 2008-08-19 06:38:12 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2008-08-19 06:38:12 (GMT) |
commit | 47bc809578f87c9ec4a264e88bb716b48573745e (patch) | |
tree | cda6135601e07410e13e3ff11c0a3ebbfeee5e8f /Lib | |
parent | b531bef93ad245ab9533195e284b17d132720e5d (diff) | |
download | cpython-47bc809578f87c9ec4a264e88bb716b48573745e.zip cpython-47bc809578f87c9ec4a264e88bb716b48573745e.tar.gz cpython-47bc809578f87c9ec4a264e88bb716b48573745e.tar.bz2 |
Merged revisions 65681-65682,65684 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65681 | thomas.heller | 2008-08-14 21:10:48 +0200 (Do, 14 Aug 2008) | 4 lines
issue #3554: ctypes.string_at and ctypes.wstring_at must use the
pythonapi calling convention so that the GIL is held and error return
values are checked.
........
r65682 | thomas.heller | 2008-08-14 22:04:38 +0200 (Do, 14 Aug 2008) | 2 lines
Try to fix the test on 64-bit platforms.
........
r65684 | thomas.heller | 2008-08-14 22:19:18 +0200 (Do, 14 Aug 2008) | 2 lines
Disable the test until I have one that works.
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ctypes/__init__.py | 4 | ||||
-rw-r--r-- | Lib/ctypes/test/test_memfunctions.py | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py index d65ea7b..1283f28 100644 --- a/Lib/ctypes/__init__.py +++ b/Lib/ctypes/__init__.py @@ -485,7 +485,7 @@ _cast = PYFUNCTYPE(py_object, c_void_p, py_object, py_object)(_cast_addr) def cast(obj, typ): return _cast(obj, obj, typ) -_string_at = CFUNCTYPE(py_object, c_void_p, c_int)(_string_at_addr) +_string_at = PYFUNCTYPE(py_object, c_void_p, c_int)(_string_at_addr) def string_at(ptr, size=-1): """string_at(addr[, size]) -> string @@ -497,7 +497,7 @@ try: except ImportError: pass else: - _wstring_at = CFUNCTYPE(py_object, c_void_p, c_int)(_wstring_at_addr) + _wstring_at = PYFUNCTYPE(py_object, c_void_p, c_int)(_wstring_at_addr) def wstring_at(ptr, size=-1): """wstring_at(addr[, size]) -> string diff --git a/Lib/ctypes/test/test_memfunctions.py b/Lib/ctypes/test/test_memfunctions.py index 6a6411e..4bee77f 100644 --- a/Lib/ctypes/test/test_memfunctions.py +++ b/Lib/ctypes/test/test_memfunctions.py @@ -3,6 +3,16 @@ import unittest from ctypes import * class MemFunctionsTest(unittest.TestCase): +## def test_overflow(self): +## # string_at and wstring_at must use the Python calling +## # convention (which acquires the GIL and checks the Python +## # error flag). Provoke an error and catch it; see also issue +## # #3554: <http://bugs.python.org/issue3554> +## self.assertRaises((OverflowError, MemoryError, SystemError), +## lambda: wstring_at(u"foo", sys.maxint - 1)) +## self.assertRaises((OverflowError, MemoryError, SystemError), +## lambda: string_at("foo", sys.maxint - 1)) + def test_memmove(self): # large buffers apparently increase the chance that the memory # is allocated in high address space. |