Discussion:
[Python-3000-checkins] r65850 - in python/branches/py3k: Lib/ctypes/__init__.py Lib/ctypes/test/test_memfunctions.py Misc/NEWS
thomas.heller
2008-08-19 06:38:12 UTC
Permalink
Author: thomas.heller
Date: Tue Aug 19 08:38:12 2008
New Revision: 65850

Log:
Merged revisions 65681-65682,65684 via svnmerge from
svn+ssh://pythondev at 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.
........


Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/ctypes/__init__.py
python/branches/py3k/Lib/ctypes/test/test_memfunctions.py
python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/ctypes/__init__.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/__init__.py (original)
+++ python/branches/py3k/Lib/ctypes/__init__.py Tue Aug 19 08:38:12 2008
@@ -485,7 +485,7 @@
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 @@
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


Modified: python/branches/py3k/Lib/ctypes/test/test_memfunctions.py
==============================================================================
--- python/branches/py3k/Lib/ctypes/test/test_memfunctions.py (original)
+++ python/branches/py3k/Lib/ctypes/test/test_memfunctions.py Tue Aug 19 08:38:12 2008
@@ -3,6 +3,16 @@
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.

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Tue Aug 19 08:38:12 2008
@@ -103,6 +103,12 @@

- Removed the sunaudio module. Use sunau instead.

+- Issue #3554: ctypes.string_at and ctypes.wstring_at did call Python
+ api functions without holding the GIL, which could lead to a fatal
+ error when they failed.
+
+- Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap Tcl command objects.
+
- Removed "ast" function aliases from the parser module.

- Issue #3313: Fixed a crash when a failed dlopen() call does not set
Loading...