diff --git a/ChangeLog b/ChangeLog index e7976b7f..94876665 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Fri Jul 16 18:36:33 HKT 2004 William Brack + + * python/generator.py: added a check on the argument for some + classes (e.g. xmlDoc and xmlNode) to prevent a segfault (as + reported on the list). Further enhancement should be done + to auto-create the appropriate object. + * python/libxml.c: minor fix for a warning message; added a + routine, currently not used, to report the description of a + PyCObject. + * python/libxml2class.txt: regenerated + Fri Jul 16 11:01:40 CEST 2004 Daniel Veillard * catalog.c test/catalogs/white* result/catalogs/white*: diff --git a/python/generator.py b/python/generator.py index 3ae57292..6b66c920 100755 --- a/python/generator.py +++ b/python/generator.py @@ -1016,6 +1016,13 @@ def buildWrappers(): classes.write("class %s(%s):\n" % (classname, classes_ancestor[classname])) classes.write(" def __init__(self, _obj=None):\n") + if classes_ancestor[classname] == "xmlCore" or \ + classes_ancestor[classname] == "xmlNode": + classes.write(" if type(_obj).__name__ != ") + classes.write("'PyCObject':\n") + classes.write(" raise TypeError, ") + classes.write("'%s needs a PyCObject argument'\n" % \ + classname) if reference_keepers.has_key(classname): rlist = reference_keepers[classname] for ref in rlist: diff --git a/python/libxml.c b/python/libxml.c index 3db0f5ff..9dda18c7 100644 --- a/python/libxml.c +++ b/python/libxml.c @@ -95,7 +95,8 @@ static void libxml_xmlErrorInitialize(void); /* forward declare */ PyObject * -libxml_xmlMemoryUsed(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) +libxml_xmlMemoryUsed(PyObject * self ATTRIBUTE_UNUSED, + PyObject * args ATTRIBUTE_UNUSED) { long ret; PyObject *py_retval; @@ -107,7 +108,7 @@ libxml_xmlMemoryUsed(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) } PyObject * -libxml_xmlDebugMemory(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) +libxml_xmlDebugMemory(PyObject * self ATTRIBUTE_UNUSED, PyObject * args) { int activate; PyObject *py_retval; @@ -3242,7 +3243,17 @@ libxml_C14NDocSaveTo(ATTRIBUTE_UNUSED PyObject * self, #endif #endif +static PyObject * +libxml_getObjDesc(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { + PyObject *obj; + char *str; + + if (!PyArg_ParseTuple(args, (char *)"O:getObjDesc", &obj)) + return NULL; + str = PyCObject_GetDesc(obj); + return Py_BuildValue((char *)"s", str); +} /************************************************************************ * * @@ -3289,6 +3300,7 @@ static PyMethodDef libxmlMethods[] = { {(char *)"xmlC14NDocSaveTo", libxml_C14NDocSaveTo, METH_VARARGS, NULL}, #endif #endif + {(char *) "getObjDesc", libxml_getObjDesc, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; diff --git a/python/libxml2class.txt b/python/libxml2class.txt index 2f082ea4..90da852c 100644 --- a/python/libxml2class.txt +++ b/python/libxml2class.txt @@ -636,56 +636,6 @@ Class xmlDoc(xmlNode) # functions from module xpointer xpointerNewContext() -Class xpathContext() - # accessors - contextDoc() - contextNode() - contextPosition() - contextSize() - function() - functionURI() - setContextDoc() - setContextNode() - - # functions from module python - registerXPathFunction() - - # functions from module xpath - xpathEval() - xpathEvalExpression() - xpathFreeContext() - - # functions from module xpathInternals - xpathNewParserContext() - xpathNsLookup() - xpathRegisterAllFunctions() - xpathRegisterNs() - xpathRegisteredFuncsCleanup() - xpathRegisteredNsCleanup() - xpathRegisteredVariablesCleanup() - xpathVariableLookup() - xpathVariableLookupNS() - - # functions from module xpointer - xpointerEval() - - -Class xmlAttribute(xmlNode) -Class catalog() - - # functions from module catalog - add() - catalogIsEmpty() - convertSGMLCatalog() - dump() - remove() - resolve() - resolvePublic() - resolveSystem() - resolveURI() - - -Class xmlElement(xmlNode) Class xmlAttr(xmlNode) @@ -704,95 +654,12 @@ Class xmlAttr(xmlNode) # functions from module valid removeID() removeRef() - - -Class xmlTextReader(xmlTextReaderCore) - - # functions from module xmlreader - AttributeCount() - BaseUri() - Close() - CurrentDoc() - CurrentNode() - Depth() - Expand() - GetAttribute() - GetAttributeNo() - GetAttributeNs() - GetParserProp() - GetRemainder() - HasAttributes() - HasValue() - IsDefault() - IsEmptyElement() - IsValid() - LocalName() - LookupNamespace() - MoveToAttribute() - MoveToAttributeNo() - MoveToAttributeNs() - MoveToElement() - MoveToFirstAttribute() - MoveToNextAttribute() - Name() - NamespaceUri() - NewDoc() - NewFd() - NewFile() - NewMemory() - NewWalker() - Next() - NextSibling() - NodeType() - Normalization() - Prefix() - Preserve() - QuoteChar() - Read() - ReadAttributeValue() - ReadInnerXml() - ReadOuterXml() - ReadState() - ReadString() - RelaxNGSetSchema() - RelaxNGValidate() - SetParserProp() - String() - Value() - XmlLang() Class xmlReg() # functions from module xmlregexp regexpExec() regexpIsDeterminist() regexpPrint() - - -Class xmlEntity(xmlNode) - - # functions from module parserInternals - handleEntity() -Class relaxNgSchema() - - # functions from module relaxng - relaxNGDump() - relaxNGDumpTree() - relaxNGNewValidCtxt() - - # functions from module xmlreader - RelaxNGSetSchema() -Class Error() - # accessors - code() - domain() - file() - level() - line() - message() - - # functions from module xmlerror - copyError() - resetError() Class relaxNgValidCtxt() # functions from module relaxng @@ -801,73 +668,6 @@ Class relaxNgValidCtxt() relaxNGValidatePopElement() relaxNGValidatePushCData() relaxNGValidatePushElement() -Class xpathParserContext() - # accessors - context() - - # functions from module xpathInternals - xpathAddValues() - xpathBooleanFunction() - xpathCeilingFunction() - xpathCompareValues() - xpathConcatFunction() - xpathContainsFunction() - xpathCountFunction() - xpathDivValues() - xpathEqualValues() - xpathErr() - xpathEvalExpr() - xpathFalseFunction() - xpathFloorFunction() - xpathFreeParserContext() - xpathIdFunction() - xpathLangFunction() - xpathLastFunction() - xpathLocalNameFunction() - xpathModValues() - xpathMultValues() - xpathNamespaceURIFunction() - xpathNextAncestor() - xpathNextAncestorOrSelf() - xpathNextAttribute() - xpathNextChild() - xpathNextDescendant() - xpathNextDescendantOrSelf() - xpathNextFollowing() - xpathNextFollowingSibling() - xpathNextNamespace() - xpathNextParent() - xpathNextPreceding() - xpathNextPrecedingSibling() - xpathNextSelf() - xpathNormalizeFunction() - xpathNotEqualValues() - xpathNotFunction() - xpathNumberFunction() - xpathParseNCName() - xpathParseName() - xpathPopBoolean() - xpathPopNumber() - xpathPopString() - xpathPositionFunction() - xpathRoot() - xpathRoundFunction() - xpathStartsWithFunction() - xpathStringFunction() - xpathStringLengthFunction() - xpathSubValues() - xpathSubstringAfterFunction() - xpathSubstringBeforeFunction() - xpathSubstringFunction() - xpathSumFunction() - xpathTranslateFunction() - xpathTrueFunction() - xpathValueFlipSign() - xpatherror() - - # functions from module xpointer - xpointerEvalRangePredicate() - xpointerRangeToFunction() Class parserCtxt(parserCtxtCore) @@ -975,6 +775,90 @@ Class xmlDtd(xmlNode) dtdElementDesc() dtdQAttrDesc() dtdQElementDesc() +Class relaxNgParserCtxt() + + # functions from module relaxng + relaxNGParse() + relaxParserSetFlag() +Class xpathParserContext() + # accessors + context() + + # functions from module xpathInternals + xpathAddValues() + xpathBooleanFunction() + xpathCeilingFunction() + xpathCompareValues() + xpathConcatFunction() + xpathContainsFunction() + xpathCountFunction() + xpathDivValues() + xpathEqualValues() + xpathErr() + xpathEvalExpr() + xpathFalseFunction() + xpathFloorFunction() + xpathFreeParserContext() + xpathIdFunction() + xpathLangFunction() + xpathLastFunction() + xpathLocalNameFunction() + xpathModValues() + xpathMultValues() + xpathNamespaceURIFunction() + xpathNextAncestor() + xpathNextAncestorOrSelf() + xpathNextAttribute() + xpathNextChild() + xpathNextDescendant() + xpathNextDescendantOrSelf() + xpathNextFollowing() + xpathNextFollowingSibling() + xpathNextNamespace() + xpathNextParent() + xpathNextPreceding() + xpathNextPrecedingSibling() + xpathNextSelf() + xpathNormalizeFunction() + xpathNotEqualValues() + xpathNotFunction() + xpathNumberFunction() + xpathParseNCName() + xpathParseName() + xpathPopBoolean() + xpathPopNumber() + xpathPopString() + xpathPositionFunction() + xpathRoot() + xpathRoundFunction() + xpathStartsWithFunction() + xpathStringFunction() + xpathStringLengthFunction() + xpathSubValues() + xpathSubstringAfterFunction() + xpathSubstringBeforeFunction() + xpathSubstringFunction() + xpathSumFunction() + xpathTranslateFunction() + xpathTrueFunction() + xpathValueFlipSign() + xpatherror() + + # functions from module xpointer + xpointerEvalRangePredicate() + xpointerRangeToFunction() +Class catalog() + + # functions from module catalog + add() + catalogIsEmpty() + convertSGMLCatalog() + dump() + remove() + resolve() + resolvePublic() + resolveSystem() + resolveURI() Class xmlNs(xmlNode) @@ -998,40 +882,6 @@ Class xmlNs(xmlNode) # functions from module xpathInternals xpathNodeSetFreeNs() - - -Class inputBuffer(ioReadWrapper) - - # functions from module xmlIO - grow() - push() - read() - - # functions from module xmlreader - newTextReader() -Class relaxNgParserCtxt() - - # functions from module relaxng - relaxNGParse() - relaxParserSetFlag() - - -Class outputBuffer(ioWriteWrapper) - - # functions from module HTMLtree - htmlDocContentDumpFormatOutput() - htmlDocContentDumpOutput() - htmlNodeDumpFormatOutput() - htmlNodeDumpOutput() - - # functions from module tree - nodeDumpOutput() - saveFileTo() - saveFormatFileTo() - - # functions from module xmlIO - write() - writeString() Class xmlTextReaderLocator() # functions from module xmlreader @@ -1062,3 +912,153 @@ Class URI() parseURIReference() printURI() saveUri() + + +Class xmlAttribute(xmlNode) +Class xpathContext() + # accessors + contextDoc() + contextNode() + contextPosition() + contextSize() + function() + functionURI() + setContextDoc() + setContextNode() + + # functions from module python + registerXPathFunction() + + # functions from module xpath + xpathEval() + xpathEvalExpression() + xpathFreeContext() + + # functions from module xpathInternals + xpathNewParserContext() + xpathNsLookup() + xpathRegisterAllFunctions() + xpathRegisterNs() + xpathRegisteredFuncsCleanup() + xpathRegisteredNsCleanup() + xpathRegisteredVariablesCleanup() + xpathVariableLookup() + xpathVariableLookupNS() + + # functions from module xpointer + xpointerEval() + + +Class xmlElement(xmlNode) + + +Class xmlTextReader(xmlTextReaderCore) + + # functions from module xmlreader + AttributeCount() + BaseUri() + Close() + CurrentDoc() + CurrentNode() + Depth() + Expand() + GetAttribute() + GetAttributeNo() + GetAttributeNs() + GetParserProp() + GetRemainder() + HasAttributes() + HasValue() + IsDefault() + IsEmptyElement() + IsValid() + LocalName() + LookupNamespace() + MoveToAttribute() + MoveToAttributeNo() + MoveToAttributeNs() + MoveToElement() + MoveToFirstAttribute() + MoveToNextAttribute() + Name() + NamespaceUri() + NewDoc() + NewFd() + NewFile() + NewMemory() + NewWalker() + Next() + NextSibling() + NodeType() + Normalization() + Prefix() + Preserve() + QuoteChar() + Read() + ReadAttributeValue() + ReadInnerXml() + ReadOuterXml() + ReadState() + ReadString() + RelaxNGSetSchema() + RelaxNGValidate() + SetParserProp() + String() + Value() + XmlLang() + + +Class xmlEntity(xmlNode) + + # functions from module parserInternals + handleEntity() +Class Error() + # accessors + code() + domain() + file() + level() + line() + message() + + # functions from module xmlerror + copyError() + resetError() +Class relaxNgSchema() + + # functions from module relaxng + relaxNGDump() + relaxNGDumpTree() + relaxNGNewValidCtxt() + + # functions from module xmlreader + RelaxNGSetSchema() + + +Class inputBuffer(ioReadWrapper) + + # functions from module xmlIO + grow() + push() + read() + + # functions from module xmlreader + newTextReader() + + +Class outputBuffer(ioWriteWrapper) + + # functions from module HTMLtree + htmlDocContentDumpFormatOutput() + htmlDocContentDumpOutput() + htmlNodeDumpFormatOutput() + htmlNodeDumpOutput() + + # functions from module tree + nodeDumpOutput() + saveFileTo() + saveFormatFileTo() + + # functions from module xmlIO + write() + writeString()