[pypy-commit] pypy default: Issue #2625
arigo
pypy.commits at gmail.com
Sun Aug 27 03:11:29 EDT 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r92266:99fff483bea8
Date: 2017-08-27 09:10 +0200
http://bitbucket.org/pypy/pypy/changeset/99fff483bea8/
Log: Issue #2625
ctypes.cast("some-string", TP)
diff --git a/lib_pypy/_ctypes/pointer.py b/lib_pypy/_ctypes/pointer.py
--- a/lib_pypy/_ctypes/pointer.py
+++ b/lib_pypy/_ctypes/pointer.py
@@ -142,6 +142,10 @@
ptr._buffer = tp._ffiarray(1, autofree=True)
ptr._buffer[0] = obj._buffer
result = ptr
+ elif isinstance(obj, bytes):
+ result = tp()
+ result._buffer[0] = buffer(obj)._pypy_raw_address()
+ return result
elif not (isinstance(obj, _CData) and type(obj)._is_pointer_like()):
raise TypeError("cast() argument 1 must be a pointer, not %s"
% (type(obj),))
More information about the pypy-commit
mailing list