Use Python's builtin machinery to prevent creation of Line objects
This commit is contained in:
parent
8f2b722dd7
commit
f2d60d6a4e
1 changed files with 1 additions and 10 deletions
11
kitty/line.c
11
kitty/line.c
|
|
@ -13,12 +13,6 @@
|
|||
|
||||
extern PyTypeObject Cursor_Type;
|
||||
|
||||
static PyObject *
|
||||
new_line_object(PyTypeObject UNUSED *type, PyObject UNUSED *args, PyObject UNUSED *kwds) {
|
||||
PyErr_SetString(PyExc_TypeError, "Line objects cannot be instantiated directly, create them using LineBuf.line()");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
dealloc(Line* self) {
|
||||
if (self->needs_free) {
|
||||
|
|
@ -976,13 +970,10 @@ PyTypeObject Line_Type = {
|
|||
.tp_richcompare = richcmp,
|
||||
.tp_doc = "Lines",
|
||||
.tp_methods = methods,
|
||||
.tp_new = new_line_object
|
||||
};
|
||||
|
||||
Line *alloc_line(void) {
|
||||
Line *ans = (Line*)PyType_GenericAlloc(&Line_Type, 0);
|
||||
ans->needs_free = 0;
|
||||
return ans;
|
||||
return (Line*)Line_Type.tp_alloc(&Line_Type, 0);
|
||||
}
|
||||
|
||||
RICHCMP(Line)
|
||||
|
|
|
|||
Loading…
Reference in a new issue