summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs
Commit message (Expand)AuthorAgeFilesLines
* bpo-15999: Accept arbitrary values for boolean parameters. (#15609)Serhiy Storchaka2022-12-032-9/+9
* gh-99537: Use Py_SETREF(var, NULL) in C code (#99687)Victor Stinner2022-11-231-2/+1
* gh-99537: Use Py_SETREF() function in C code (#99656)Victor Stinner2022-11-221-4/+2
* gh-99300: Use Py_NewRef() in Modules/ directory (#99469)Victor Stinner2022-11-141-14/+7
* gh-90928: Improve static initialization of keywords tuple in AC (#95907)Erlend E. Aasland2022-08-131-123/+39
* gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code (...Eric Snow2022-08-111-7/+211
* gh-93741: Add private C API _PyImport_GetModuleAttrString() (GH-93742)Serhiy Storchaka2022-06-141-8/+1
* gh-84508: tool to generate cjk traditional chinese mappings (gh-93272)Davide Rizzo2022-06-112-0/+3
* gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210)Victor Stinner2022-05-031-11/+11
* gh-91583: AC: Fix regression for functions with defining_class (GH-91739)Serhiy Storchaka2022-04-301-18/+15
* bpo-46541: Remove usage of _Py_IDENTIFIER from multibytecodec (GH-31475)Dong-hee Na2022-03-012-25/+103
* bpo-46613: Add PyType_GetModuleByDef to the public API (GH-31081)Petr Viktorin2022-02-111-1/+1
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized g...Eric Snow2022-02-081-0/+1
* bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351)Erlend Egeberg Aasland2021-06-171-5/+9
* bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)Erlend Egeberg Aasland2021-04-301-1/+2
* bpo-42866: Add traverse func to _multibytecodec.MultibyteCodec (GH-24166)Victor Stinner2021-01-081-3/+13
* bpo-42866: Fix refleak in CJK getcodec() (GH-24165)Victor Stinner2021-01-081-0/+1
* bpo-42846: Convert CJK codec extensions to multiphase init (GH-24157)Victor Stinner2021-01-071-29/+39
* bpo-1635741: Convert _multibytecodec to multi-phase init (GH-24095)Erlend Egeberg Aasland2021-01-042-261/+218
* bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)Victor Stinner2020-12-011-1/+1
* bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)Victor Stinner2020-12-011-2/+2
* bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka2020-05-261-11/+1
* bpo-40328: Add tool for generating cjk mapping headers (GH-19602)Dong-hee Na2020-04-295-3/+6
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-1/+1
* bpo-39943: Add the const qualifier to pointers on non-mutable PyBytes data. (...Serhiy Storchaka2020-04-121-1/+1
* bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode data....Serhiy Storchaka2020-04-113-4/+4
* bpo-40024: Update C extension modules to use PyModule_AddType() (GH-19119)Dong-hee Na2020-03-241-8/+4
* bpo-39573: Finish converting to new Py_IS_TYPE() macro (GH-18601)Andy Lester2020-03-041-1/+1
* bpo-39245: Switch to public API for Vectorcall (GH-18460)Petr Viktorin2020-02-112-2/+2
* bpo-39573: Use Py_TYPE() macro in Modules directory (GH-18393)Victor Stinner2020-02-072-2/+2
* bpo-38631: Avoid Py_FatalError() in _multibytecodec init (GH-17233)Victor Stinner2019-11-181-1/+0
* bpo-37206: Unrepresentable default values no longer represented as None. (GH-...Serhiy Storchaka2019-09-141-4/+4
* bpo-37034: Display argument name on errors with keyword arguments with Argume...RĂ©mi Lapeyre2019-08-291-7/+7
* Fix typos in comments, docs and test names (#15018)Min ho Kim2019-07-301-1/+1
* bpo-37547: add _PyObject_CallMethodOneArg (GH-14685)Jeroen Demeyer2019-07-111-2/+2
* bpo-37483: add _PyObject_CallOneArg() function (#14558)Jeroen Demeyer2019-07-042-13/+3
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async (G...Jeroen Demeyer2019-05-311-10/+10
* bpo-35194: cjkcodec: check the encoded value is not truncated (GH-10432)Alexey Izbyshev2019-03-291-18/+20
* bpo-36127: Argument Clinic: inline parsing code for keyword parameters. (GH-1...Serhiy Storchaka2019-03-141-13/+107
* bpo-35582: Argument Clinic: Optimize the "all boring objects" case. (GH-11520)Serhiy Storchaka2019-01-111-10/+19
* bpo-35582: Argument Clinic: inline parsing code for positional parameters. (G...Serhiy Storchaka2019-01-111-3/+3
* bpo-23867: Argument Clinic: inline parsing code for a single positional param...Serhiy Storchaka2018-12-251-3/+7
* bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11...Zackery Spytz2018-12-171-0/+4
* bpo-33029: Fix signatures of getter and setter functions. (GH-10746)Serhiy Storchaka2018-11-271-1/+1
* bpo-33012: Fix invalid function cast warnings with gcc 8 in Argument Clinic. ...Serhiy Storchaka2018-11-271-8/+8
* cjkcodecs: Fix compiler warning (GH-10651)Victor Stinner2018-11-221-2/+2
* bpo-35194: Fix a wrong constant in cp932 codec (GH-10420)Alexey Izbyshev2018-11-091-1/+1
* bpo-33578: Fix getstate/setstate for CJK decoder (GH-10290)Christopher Thorne2018-11-021-5/+22
* bpo-33578: Add getstate/setstate for CJK codec (GH-6984)Christopher Thorne2018-11-014-22/+273
* bpo-32240: Add the const qualifier to declarations of PyObject* array argumen...Serhiy Storchaka2017-12-151-8/+8
self->x_attr); return 0; } static void Xxo_finalize(PyObject *self_obj) { XxoObject *self = (XxoObject *)self_obj; Py_CLEAR(self->x_attr); } static void Xxo_dealloc(PyObject *self) { PyObject_GC_UnTrack(self); Xxo_finalize(self); PyTypeObject *tp = Py_TYPE(self); freefunc free = PyType_GetSlot(tp, Py_tp_free); free(self); Py_DECREF(tp); } /* Xxo attribute handling */ static PyObject * Xxo_getattro(XxoObject *self, PyObject *name) { if (self->x_attr != NULL) { PyObject *v = PyDict_GetItemWithError(self->x_attr, name); if (v != NULL) { return Py_NewRef(v); } else if (PyErr_Occurred()) { return NULL; } } return PyObject_GenericGetAttr((PyObject *)self, name); } static int Xxo_setattro(XxoObject *self, PyObject *name, PyObject *v) { if (self->x_attr == NULL) { // prepare the attribute dict self->x_attr = PyDict_New(); if (self->x_attr == NULL) { return -1; } } if (v == NULL) { // delete an attribute int rv = PyDict_DelItem(self->x_attr, name); if (rv < 0 && PyErr_ExceptionMatches(PyExc_KeyError)) { PyErr_SetString(PyExc_AttributeError, "delete non-existing Xxo attribute"); return -1; } return rv; } else { // set an attribute return PyDict_SetItem(self->x_attr, name, v); } } /* Xxo methods */ static PyObject * Xxo_demo(XxoObject *self, PyTypeObject *defining_class, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { if (kwnames != NULL && PyObject_Length(kwnames)) { PyErr_SetString(PyExc_TypeError, "demo() takes no keyword arguments"); return NULL; } if (nargs != 1) { PyErr_SetString(PyExc_TypeError, "demo() takes exactly 1 argument"); return NULL; } PyObject *o = args[0]; /* Test if the argument is "str" */ if (PyUnicode_Check(o)) { return Py_NewRef(o); } /* test if the argument is of the Xxo class */ if (PyObject_TypeCheck(o, defining_class)) { return Py_NewRef(o); } return Py_NewRef(Py_None); } static PyMethodDef Xxo_methods[] = { {"demo", _PyCFunction_CAST(Xxo_demo), METH_METHOD | METH_FASTCALL | METH_KEYWORDS, PyDoc_STR("demo(o) -> o")}, {NULL, NULL} /* sentinel */ }; /* Xxo buffer interface */ static int Xxo_getbuffer(XxoObject *self, Py_buffer *view, int flags) { int res = PyBuffer_FillInfo(view, (PyObject*)self, (void *)self->x_buffer, BUFSIZE, 0, flags); if (res == 0) { self->x_exports++; } return res; } static void Xxo_releasebuffer(XxoObject *self, Py_buffer *view) { self->x_exports--; } static PyObject * Xxo_get_x_exports(XxoObject *self, void *c) { return PyLong_FromSsize_t(self->x_exports); } /* Xxo type definition */ PyDoc_STRVAR(Xxo_doc, "A class that explicitly stores attributes in an internal dict"); static PyGetSetDef Xxo_getsetlist[] = { {"x_exports", (getter) Xxo_get_x_exports, NULL, NULL}, {NULL}, }; static PyType_Slot Xxo_Type_slots[] = { {Py_tp_doc, (char *)Xxo_doc}, {Py_tp_traverse, Xxo_traverse}, {Py_tp_clear, Xxo_clear}, {Py_tp_finalize, Xxo_finalize}, {Py_tp_dealloc, Xxo_dealloc}, {Py_tp_getattro, Xxo_getattro}, {Py_tp_setattro, Xxo_setattro}, {Py_tp_methods, Xxo_methods}, {Py_bf_getbuffer, Xxo_getbuffer}, {Py_bf_releasebuffer, Xxo_releasebuffer}, {Py_tp_getset, Xxo_getsetlist}, {0, 0}, /* sentinel */ }; static PyType_Spec Xxo_Type_spec = { .name = "xxlimited.Xxo", .basicsize = sizeof(XxoObject), .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, .slots = Xxo_Type_slots, }; /* Str type definition*/ static PyType_Slot Str_Type_slots[] = { {0, 0}, /* sentinel */ }; static PyType_Spec Str_Type_spec = { .name = "xxlimited.Str", .basicsize = 0, .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, .slots = Str_Type_slots, }; /* Function of two integers returning integer (with C "long int" arithmetic) */ PyDoc_STRVAR(xx_foo_doc, "foo(i,j)\n\ \n\ Return the sum of i and j."); static PyObject * xx_foo(PyObject *module, PyObject *args) { long i, j; long res; if (!PyArg_ParseTuple(args, "ll:foo", &i, &j)) return NULL; res = i+j; /* XXX Do something here */ return PyLong_FromLong(res); } /* Function of no arguments returning new Xxo object */ static PyObject * xx_new(PyObject *module, PyObject *Py_UNUSED(unused)) { XxoObject *rv; rv = newXxoObject(module); if (rv == NULL) return NULL; return (PyObject *)rv; } /* List of functions defined in the module */ static PyMethodDef xx_methods[] = { {"foo", xx_foo, METH_VARARGS, xx_foo_doc}, {"new", xx_new, METH_NOARGS, PyDoc_STR("new() -> new Xx object")}, {NULL, NULL} /* sentinel */ }; /* The module itself */ PyDoc_STRVAR(module_doc, "This is a template module just for instruction."); static int xx_modexec(PyObject *m) { xx_state *state = PyModule_GetState(m); state->Error_Type = PyErr_NewException("xxlimited.Error", NULL, NULL); if (state->Error_Type == NULL) { return -1; } if (PyModule_AddType(m, (PyTypeObject*)state->Error_Type) < 0) { return -1; } state->Xxo_Type = PyType_FromModuleAndSpec(m, &Xxo_Type_spec, NULL); if (state->Xxo_Type == NULL) { return -1; } if (PyModule_AddType(m, (PyTypeObject*)state->Xxo_Type) < 0) { return -1; } // Add the Str type. It is not needed from C code, so it is only // added to the module dict. // It does not inherit from "object" (PyObject_Type), but from "str" // (PyUnincode_Type). PyObject *Str_Type = PyType_FromModuleAndSpec( m, &Str_Type_spec, (PyObject *)&PyUnicode_Type); if (Str_Type == NULL) { return -1; } if (PyModule_AddType(m, (PyTypeObject*)Str_Type) < 0) { return -1; } Py_DECREF(Str_Type); return 0; } static PyModuleDef_Slot xx_slots[] = { {Py_mod_exec, xx_modexec}, {0, NULL} }; static int xx_traverse(PyObject *module, visitproc visit, void *arg) { xx_state *state = PyModule_GetState(module); Py_VISIT(state->Xxo_Type); Py_VISIT(state->Error_Type); return 0; } static int xx_clear(PyObject *module) { xx_state *state = PyModule_GetState(module); Py_CLEAR(state->Xxo_Type); Py_CLEAR(state->Error_Type); return 0; } static struct PyModuleDef xxmodule = { PyModuleDef_HEAD_INIT, .m_name = "xxlimited", .m_doc = module_doc, .m_size = sizeof(xx_state), .m_methods = xx_methods, .m_slots = xx_slots, .m_traverse = xx_traverse, .m_clear = xx_clear, /* m_free is not necessary here: xx_clear clears all references, * and the module state is deallocated along with the module. */ }; /* Export function for the module (*must* be called PyInit_xx) */ PyMODINIT_FUNC PyInit_xxlimited(void) { return PyModuleDef_Init(&xxmodule); }