diff options
author | dldmitry <dldmitry@yandex-team.ru> | 2022-02-10 16:47:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:17 +0300 |
commit | 10129030876638368b8965c627671fe44be079bc (patch) | |
tree | 681c849a324535feff6f07677873c9ffc4c51520 /library/python/symbols | |
parent | 5c1eb9f48fd0ac41fd72519a8284ded6f0358f6f (diff) | |
download | ydb-10129030876638368b8965c627671fe44be079bc.tar.gz |
Restoring authorship annotation for <dldmitry@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/python/symbols')
-rw-r--r-- | library/python/symbols/python/ut/test_ctypes.py | 72 | ||||
-rw-r--r-- | library/python/symbols/python/ut/ya.make | 16 |
2 files changed, 44 insertions, 44 deletions
diff --git a/library/python/symbols/python/ut/test_ctypes.py b/library/python/symbols/python/ut/test_ctypes.py index 253a10d8b3..b1c15fa68b 100644 --- a/library/python/symbols/python/ut/test_ctypes.py +++ b/library/python/symbols/python/ut/test_ctypes.py @@ -1,37 +1,37 @@ -from ctypes import ( - byref, POINTER, c_int, c_char, c_char_p, - c_void_p, py_object, c_ssize_t, pythonapi, Structure -) - -c_ssize_p = POINTER(c_ssize_t) - - -class Py_buffer(Structure): - _fields_ = [ - ('buf', c_void_p), - ('obj', py_object), - ('len', c_ssize_t), - ('itemsize', c_ssize_t), - ('readonly', c_int), - ('ndim', c_int), - ('format', c_char_p), - ('shape', c_ssize_p), - ('strides', c_ssize_p), - ('suboffsets', c_ssize_p), - ('smalltable', c_ssize_t * 2), - ('internal', c_void_p) - ] - - -def get_buffer(obj): - buf = Py_buffer() - pythonapi.PyObject_GetBuffer(py_object(obj), byref(buf), 0) - try: - buffer_type = c_char * buf.len - return buffer_type.from_address(buf.buf) - finally: - pythonapi.PyBuffer_Release(byref(buf)) - - -def test_buffer(): +from ctypes import ( + byref, POINTER, c_int, c_char, c_char_p, + c_void_p, py_object, c_ssize_t, pythonapi, Structure +) + +c_ssize_p = POINTER(c_ssize_t) + + +class Py_buffer(Structure): + _fields_ = [ + ('buf', c_void_p), + ('obj', py_object), + ('len', c_ssize_t), + ('itemsize', c_ssize_t), + ('readonly', c_int), + ('ndim', c_int), + ('format', c_char_p), + ('shape', c_ssize_p), + ('strides', c_ssize_p), + ('suboffsets', c_ssize_p), + ('smalltable', c_ssize_t * 2), + ('internal', c_void_p) + ] + + +def get_buffer(obj): + buf = Py_buffer() + pythonapi.PyObject_GetBuffer(py_object(obj), byref(buf), 0) + try: + buffer_type = c_char * buf.len + return buffer_type.from_address(buf.buf) + finally: + pythonapi.PyBuffer_Release(byref(buf)) + + +def test_buffer(): assert get_buffer(b'test string') diff --git a/library/python/symbols/python/ut/ya.make b/library/python/symbols/python/ut/ya.make index 2849e01b1e..18c0e6bb51 100644 --- a/library/python/symbols/python/ut/ya.make +++ b/library/python/symbols/python/ut/ya.make @@ -1,14 +1,14 @@ PY23_LIBRARY() - -OWNER(orivej) - + +OWNER(orivej) + TEST_SRCS(test_ctypes.py) - -PEERDIR( + +PEERDIR( library/python/symbols/python -) - -END() +) + +END() RECURSE_FOR_TESTS( py2 |