Mercurial > hg
comparison contrib/python-zstandard/c-ext/bufferutil.c @ 46374:e92ca942ddca
cext: add Python 3.10 support
* Replace "Py_TYPE(obj) = type;" with "Py_SET_TYPE(obj, type);"
* Add pythoncapi_compat.h header file to get Py_SET_TYPE() on Python
2.7-3.8. Header file added to mercurial/ and
contrib/python-zstandard/zstd/common/.
In Python 3.10, Py_TYPE(obj) must not longer be used as an l-value.
pythoncapi_compat.h comes from:
https://github.com/pythoncapi/pythoncapi_compat
Differential Revision: https://phab.mercurial-scm.org/D9825
author | Victor Stinner <vstinner@python.org> |
---|---|
date | Mon, 14 Dec 2020 10:44:29 +0100 |
parents | b1fb341d8a61 |
children |
comparison
equal
deleted
inserted
replaced
46373:711ba0f1057e | 46374:e92ca942ddca |
---|---|
756 0, /* tp_alloc */ | 756 0, /* tp_alloc */ |
757 PyType_GenericNew, /* tp_new */ | 757 PyType_GenericNew, /* tp_new */ |
758 }; | 758 }; |
759 | 759 |
760 void bufferutil_module_init(PyObject* mod) { | 760 void bufferutil_module_init(PyObject* mod) { |
761 Py_TYPE(&ZstdBufferWithSegmentsType) = &PyType_Type; | 761 Py_SET_TYPE(&ZstdBufferWithSegmentsType, &PyType_Type); |
762 if (PyType_Ready(&ZstdBufferWithSegmentsType) < 0) { | 762 if (PyType_Ready(&ZstdBufferWithSegmentsType) < 0) { |
763 return; | 763 return; |
764 } | 764 } |
765 | 765 |
766 Py_INCREF(&ZstdBufferWithSegmentsType); | 766 Py_INCREF(&ZstdBufferWithSegmentsType); |
767 PyModule_AddObject(mod, "BufferWithSegments", (PyObject*)&ZstdBufferWithSegmentsType); | 767 PyModule_AddObject(mod, "BufferWithSegments", (PyObject*)&ZstdBufferWithSegmentsType); |
768 | 768 |
769 Py_TYPE(&ZstdBufferSegmentsType) = &PyType_Type; | 769 Py_SET_TYPE(&ZstdBufferSegmentsType, &PyType_Type); |
770 if (PyType_Ready(&ZstdBufferSegmentsType) < 0) { | 770 if (PyType_Ready(&ZstdBufferSegmentsType) < 0) { |
771 return; | 771 return; |
772 } | 772 } |
773 | 773 |
774 Py_INCREF(&ZstdBufferSegmentsType); | 774 Py_INCREF(&ZstdBufferSegmentsType); |
775 PyModule_AddObject(mod, "BufferSegments", (PyObject*)&ZstdBufferSegmentsType); | 775 PyModule_AddObject(mod, "BufferSegments", (PyObject*)&ZstdBufferSegmentsType); |
776 | 776 |
777 Py_TYPE(&ZstdBufferSegmentType) = &PyType_Type; | 777 Py_SET_TYPE(&ZstdBufferSegmentType, &PyType_Type); |
778 if (PyType_Ready(&ZstdBufferSegmentType) < 0) { | 778 if (PyType_Ready(&ZstdBufferSegmentType) < 0) { |
779 return; | 779 return; |
780 } | 780 } |
781 | 781 |
782 Py_INCREF(&ZstdBufferSegmentType); | 782 Py_INCREF(&ZstdBufferSegmentType); |
783 PyModule_AddObject(mod, "BufferSegment", (PyObject*)&ZstdBufferSegmentType); | 783 PyModule_AddObject(mod, "BufferSegment", (PyObject*)&ZstdBufferSegmentType); |
784 | 784 |
785 Py_TYPE(&ZstdBufferWithSegmentsCollectionType) = &PyType_Type; | 785 Py_SET_TYPE(&ZstdBufferWithSegmentsCollectionType, &PyType_Type); |
786 if (PyType_Ready(&ZstdBufferWithSegmentsCollectionType) < 0) { | 786 if (PyType_Ready(&ZstdBufferWithSegmentsCollectionType) < 0) { |
787 return; | 787 return; |
788 } | 788 } |
789 | 789 |
790 Py_INCREF(&ZstdBufferWithSegmentsCollectionType); | 790 Py_INCREF(&ZstdBufferWithSegmentsCollectionType); |