summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-03-09 20:21:16 (GMT)
committerThomas Heller <theller@ctypes.org>2007-03-09 20:21:16 (GMT)
commitf7eed5e2d1667f8caec2ddbea20915566e5fbd98 (patch)
tree1f332e8cb0619b9c3dbdd923d4f9d57718df7b7e /Lib
parente7881559f23800d45c04fe7bc8e6a7031fb5e665 (diff)
downloadcpython-f7eed5e2d1667f8caec2ddbea20915566e5fbd98.zip
cpython-f7eed5e2d1667f8caec2ddbea20915566e5fbd98.tar.gz
cpython-f7eed5e2d1667f8caec2ddbea20915566e5fbd98.tar.bz2
Merged revisions 54244 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk/Lib/ctypes ........ r54244 | thomas.heller | 2007-03-09 20:21:28 +0100 (Fr, 09 Mär 2007) | 3 lines Fix bug #1646630: ctypes.string_at(buf, 0) and ctypes.wstring_at(buf, 0) returned string up to the first NUL character. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/__init__.py4
-rw-r--r--Lib/ctypes/test/test_memfunctions.py2
2 files changed, 4 insertions, 2 deletions
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index 4ebdb79..5937304 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -478,7 +478,7 @@ def cast(obj, typ):
return _cast(obj, obj, typ)
_string_at = CFUNCTYPE(py_object, c_void_p, c_int)(_string_at_addr)
-def string_at(ptr, size=0):
+def string_at(ptr, size=-1):
"""string_at(addr[, size]) -> string
Return the string at addr."""
@@ -490,7 +490,7 @@ except ImportError:
pass
else:
_wstring_at = CFUNCTYPE(py_object, c_void_p, c_int)(_wstring_at_addr)
- def wstring_at(ptr, size=0):
+ def wstring_at(ptr, size=-1):
"""wstring_at(addr[, size]) -> string
Return the string at addr."""
diff --git a/Lib/ctypes/test/test_memfunctions.py b/Lib/ctypes/test/test_memfunctions.py
index fbae2ce..aef7a73 100644
--- a/Lib/ctypes/test/test_memfunctions.py
+++ b/Lib/ctypes/test/test_memfunctions.py
@@ -14,6 +14,7 @@ class MemFunctionsTest(unittest.TestCase):
self.failUnlessEqual(string_at(result), "Hello, World")
self.failUnlessEqual(string_at(result, 5), "Hello")
self.failUnlessEqual(string_at(result, 16), "Hello, World\0\0\0\0")
+ self.failUnlessEqual(string_at(result, 0), "")
def test_memset(self):
a = create_string_buffer(1000000)
@@ -54,6 +55,7 @@ class MemFunctionsTest(unittest.TestCase):
self.failUnlessEqual(wstring_at(a), "Hello, World")
self.failUnlessEqual(wstring_at(a, 5), "Hello")
self.failUnlessEqual(wstring_at(a, 16), "Hello, World\0\0\0\0")
+ self.failUnlessEqual(wstring_at(a, 0), "")
if __name__ == "__main__":
unittest.main()