@@ -20,6 +20,37 @@ PyCell_New(PyObject *obj)
2020 return (PyObject * )op ;
2121}
2222
23+ PyDoc_STRVAR (cell_new_doc ,
24+ "cell([contents])\n"
25+ "--\n"
26+ "\n"
27+ "Create a new cell object.\n"
28+ "\n"
29+ " contents\n"
30+ " the contents of the cell. If not specified, the cell will be empty,\n"
31+ " and \n further attempts to access its cell_contents attribute will\n"
32+ " raise a ValueError." );
33+
34+
35+ static PyObject *
36+ cell_new (PyTypeObject * type , PyObject * args , PyObject * kwargs )
37+ {
38+ PyObject * return_value = NULL ;
39+ PyObject * obj = NULL ;
40+
41+ if (!_PyArg_NoKeywords ("cell" , kwargs )) {
42+ goto exit ;
43+ }
44+ /* min = 0: we allow the cell to be empty */
45+ if (!PyArg_UnpackTuple (args , "cell" , 0 , 1 , & obj )) {
46+ goto exit ;
47+ }
48+ return_value = PyCell_New (obj );
49+
50+ exit :
51+ return return_value ;
52+ }
53+
2354PyObject *
2455PyCell_Get (PyObject * op )
2556{
@@ -146,7 +177,7 @@ PyTypeObject PyCell_Type = {
146177 0 , /* tp_setattro */
147178 0 , /* tp_as_buffer */
148179 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC , /* tp_flags */
149- 0 , /* tp_doc */
180+ cell_new_doc , /* tp_doc */
150181 (traverseproc )cell_traverse , /* tp_traverse */
151182 (inquiry )cell_clear , /* tp_clear */
152183 cell_richcompare , /* tp_richcompare */
@@ -156,4 +187,13 @@ PyTypeObject PyCell_Type = {
156187 0 , /* tp_methods */
157188 0 , /* tp_members */
158189 cell_getsetlist , /* tp_getset */
190+ 0 , /* tp_base */
191+ 0 , /* tp_dict */
192+ 0 , /* tp_descr_get */
193+ 0 , /* tp_descr_set */
194+ 0 , /* tp_dictoffset */
195+ 0 , /* tp_init */
196+ 0 , /* tp_alloc */
197+ (newfunc )cell_new , /* tp_new */
198+ 0 , /* tp_free */
159199};
0 commit comments