diff options
author | maxim-yurchuk <maxim-yurchuk@yandex-team.com> | 2024-10-09 12:29:46 +0300 |
---|---|---|
committer | maxim-yurchuk <maxim-yurchuk@yandex-team.com> | 2024-10-09 13:14:22 +0300 |
commit | 9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch) | |
tree | a8fb3181d5947c0d78cf402aa56e686130179049 /contrib/python/py3c | |
parent | a44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff) | |
download | ydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz |
publishFullContrib: true for ydb
<HIDDEN_URL>
commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/python/py3c')
-rw-r--r-- | contrib/python/py3c/py3c/fileshim.h | 50 | ||||
-rw-r--r-- | contrib/python/py3c/py3c/tpflags.h | 52 |
2 files changed, 102 insertions, 0 deletions
diff --git a/contrib/python/py3c/py3c/fileshim.h b/contrib/python/py3c/py3c/fileshim.h new file mode 100644 index 0000000000..d5615187b1 --- /dev/null +++ b/contrib/python/py3c/py3c/fileshim.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2015, Red Hat, Inc. and/or its affiliates + * Licensed under the MIT license; see py3c.h + */ + +#ifndef _PY3C_FILESHIM_H_ +#define _PY3C_FILESHIM_H_ +#include <Python.h> +#include <py3c/compat.h> + +/* + +For debugging purposes only. +Caveats: + * Only works on file-like objects backed by an actual file + * All C-level writes should be done before additional + Python-level writes are allowed (e.g. by running Python code). + * Though the function tries to flush, there is no guarantee that + writes will be reordered due to different layers of buffering. + +*/ + +static char FLUSH[] = "flush"; +static char EMPTY_STRING[] = ""; + +_py3c_STATIC_INLINE_FUNCTION(FILE* py3c_PyFile_AsFileWithMode(PyObject *py_file, const char *mode)) { + FILE *f; + PyObject *ret; + int fd; + + ret = PyObject_CallMethod(py_file, FLUSH, EMPTY_STRING); + if (ret == NULL) { + return NULL; + } + Py_DECREF(ret); + + fd = PyObject_AsFileDescriptor(py_file); + if (fd == -1) { + return NULL; + } + + f = fdopen(fd, mode); + if (f == NULL) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + + return f; +} + +#endif /* _PY3C_FILESHIM_H_ */ diff --git a/contrib/python/py3c/py3c/tpflags.h b/contrib/python/py3c/py3c/tpflags.h new file mode 100644 index 0000000000..aa57035236 --- /dev/null +++ b/contrib/python/py3c/py3c/tpflags.h @@ -0,0 +1,52 @@ +/* Copyright (c) 2015, Red Hat, Inc. and/or its affiliates + * Licensed under the MIT license; see py3c.h + */ + +/* + * WARNING: These flags are only to be used in class definitions. + * + * Before including this header file, check that you do not use + * these flags with with PyType_HasFeature. Example command: + * grep -r PyType_HasFeature . + * + * In Python 3, *all objects* have the features corresponding to removed flags. + */ + +#ifndef _PY3C_TPFLAGS_H_ +#define _PY3C_TPFLAGS_H_ +#include <Python.h> + +#if PY_MAJOR_VERSION >= 3 + +#define Py_TPFLAGS_HAVE_GETCHARBUFFER 0 +#define Py_TPFLAGS_HAVE_SEQUENCE_IN 0 +#define Py_TPFLAGS_HAVE_INPLACEOPS 0 +#define Py_TPFLAGS_CHECKTYPES 0 +#define Py_TPFLAGS_HAVE_RICHCOMPARE 0 +#define Py_TPFLAGS_HAVE_WEAKREFS 0 +#define Py_TPFLAGS_HAVE_ITER 0 +#define Py_TPFLAGS_HAVE_CLASS 0 +/* Py_TPFLAGS_HEAPTYPE is still optional in py3 */ +/* Py_TPFLAGS_BASETYPE is still optional in py3 */ +/* Py_TPFLAGS_READY is still useful in py3 */ +/* Py_TPFLAGS_READYING is still useful in py3 */ +/* Py_TPFLAGS_HAVE_GC is still optional in py3 */ +/* Py_TPFLAGS_HAVE_STACKLESS_EXTENSION is still optional in py3 */ +#define Py_TPFLAGS_HAVE_INDEX 0 +/* Py_TPFLAGS_HAVE_VERSION_TAG is still optional in py3 */ +/* Py_TPFLAGS_VALID_VERSION_TAG is still optional in py3 */ +/* Py_TPFLAGS_IS_ABSTRACT is still optional in py3 */ +#define Py_TPFLAGS_HAVE_NEWBUFFER 0 +/* Py_TPFLAGS_INT_SUBCLASS is still optional in py3 */ +/* Py_TPFLAGS_LONG_SUBCLASS is still optional in py3 */ +/* Py_TPFLAGS_LIST_SUBCLASS is still optional in py3 */ +/* Py_TPFLAGS_TUPLE_SUBCLASS is still optional in py3 */ +/* Py_TPFLAGS_STRING_SUBCLASS is still optional in py3 */ +/* Py_TPFLAGS_UNICODE_SUBCLASS is still optional in py3 */ +/* Py_TPFLAGS_DICT_SUBCLASS is still optional in py3 */ +/* Py_TPFLAGS_BASE_EXC_SUBCLASS is still optional in py3 */ +/* Py_TPFLAGS_TYPE_SUBCLASS is still optional in py3 */ + +/* py 3.4 adds Py_TPFLAGS_HAVE_FINALIZE */ +#endif +#endif /* _PY3C_TPFLAGS_H_ */ |