@@ -1400,6 +1400,12 @@ xmlparse_getattr(xmlparseobject *self, char *name)
14001400 }
14011401 }
14021402
1403+ return Py_FindMethod (xmlparse_methods , (PyObject * )self , name );
1404+ }
1405+
1406+ static PyObject *
1407+ xmlparse_dir (PyObject * self , PyObject * noargs )
1408+ {
14031409#define APPEND (list , str ) \
14041410 do { \
14051411 PyObject *o = PyString_FromString(str); \
@@ -1408,36 +1414,39 @@ xmlparse_getattr(xmlparseobject *self, char *name)
14081414 Py_XDECREF(o); \
14091415 } while (0)
14101416
1411- if (strcmp (name , "__members__" ) == 0 ) {
1412- int i ;
1413- PyObject * rc = PyList_New (0 );
1414- if (!rc )
1415- return NULL ;
1416- for (i = 0 ; handler_info [i ].name != NULL ; i ++ ) {
1417- PyObject * o = get_handler_name (& handler_info [i ]);
1418- if (o != NULL )
1419- PyList_Append (rc , o );
1420- Py_XDECREF (o );
1421- }
1422- APPEND (rc , "ErrorCode" );
1423- APPEND (rc , "ErrorLineNumber" );
1424- APPEND (rc , "ErrorColumnNumber" );
1425- APPEND (rc , "ErrorByteIndex" );
1426- APPEND (rc , "CurrentLineNumber" );
1427- APPEND (rc , "CurrentColumnNumber" );
1428- APPEND (rc , "CurrentByteIndex" );
1429- APPEND (rc , "buffer_size" );
1430- APPEND (rc , "buffer_text" );
1431- APPEND (rc , "buffer_used" );
1432- APPEND (rc , "namespace_prefixes" );
1433- APPEND (rc , "ordered_attributes" );
1434- APPEND (rc , "specified_attributes" );
1435- APPEND (rc , "intern" );
1417+ int i ;
1418+ PyObject * rc = PyList_New (0 );
1419+ if (!rc )
1420+ return NULL ;
1421+ for (i = 0 ; handler_info [i ].name != NULL ; i ++ ) {
1422+ PyObject * o = get_handler_name (& handler_info [i ]);
1423+ if (o != NULL )
1424+ PyList_Append (rc , o );
1425+ Py_XDECREF (o );
1426+ }
1427+ APPEND (rc , "ErrorCode" );
1428+ APPEND (rc , "ErrorLineNumber" );
1429+ APPEND (rc , "ErrorColumnNumber" );
1430+ APPEND (rc , "ErrorByteIndex" );
1431+ APPEND (rc , "CurrentLineNumber" );
1432+ APPEND (rc , "CurrentColumnNumber" );
1433+ APPEND (rc , "CurrentByteIndex" );
1434+ APPEND (rc , "buffer_size" );
1435+ APPEND (rc , "buffer_text" );
1436+ APPEND (rc , "buffer_used" );
1437+ APPEND (rc , "namespace_prefixes" );
1438+ APPEND (rc , "ordered_attributes" );
1439+ APPEND (rc , "specified_attributes" );
1440+ APPEND (rc , "intern" );
14361441
14371442#undef APPEND
1438- return rc ;
1443+
1444+ if (PyErr_Occurred ()) {
1445+ Py_DECREF (rc );
1446+ rc = NULL ;
14391447 }
1440- return Py_FindMethod (xmlparse_methods , (PyObject * )self , name );
1448+
1449+ return rc ;
14411450}
14421451
14431452static int
@@ -1560,6 +1569,10 @@ xmlparse_clear(xmlparseobject *op)
15601569
15611570PyDoc_STRVAR (Xmlparsetype__doc__ , "XML parser" );
15621571
1572+ static PyMethodDef xmlparse_tp_methods [] = {
1573+ {"__dir__" , xmlparse_dir , METH_NOARGS }
1574+ };
1575+
15631576static PyTypeObject Xmlparsetype = {
15641577 PyVarObject_HEAD_INIT (NULL , 0 )
15651578 "pyexpat.xmlparser" , /*tp_name*/
@@ -1588,7 +1601,12 @@ static PyTypeObject Xmlparsetype = {
15881601#endif
15891602 Xmlparsetype__doc__ , /* tp_doc - Documentation string */
15901603 (traverseproc )xmlparse_traverse , /* tp_traverse */
1591- (inquiry )xmlparse_clear /* tp_clear */
1604+ (inquiry )xmlparse_clear , /* tp_clear */
1605+ 0 , /* tp_richcompare */
1606+ 0 , /* tp_weaklistoffset */
1607+ 0 , /* tp_iter */
1608+ 0 , /* tp_iternext */
1609+ xmlparse_tp_methods /* tp_methods */
15921610};
15931611
15941612/* End of code for xmlparser objects */
0 commit comments