1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-07-29 15:41:13 +03:00

Finish and clean up Python 3 support

- Handle Python 3 types similar to libxml2
- Copy new versions of libxml_xmlXPathDestructNsNode and
  libxml_xmlXPathObjectPtrConvert from libxml2
- Fix compiler warnings
- Fix whitespace
- Remove unneeded imports from __future__
- Remove test in extelem.py (StringIO can't be converted to FILE under
  Python 3)
- string.lower() works in both Python 2 and 3

Closes #25.
This commit is contained in:
Nick Wellnhofer
2020-11-19 16:08:03 +01:00
parent a2db8da1ac
commit b3076bccdb
10 changed files with 230 additions and 284 deletions

View File

@ -1,6 +1,4 @@
#!/usr/bin/python -u
from __future__ import print_function
import sys
import libxml2
# Memory debug specific

View File

@ -1,6 +1,4 @@
#!/usr/bin/python -u
from __future__ import print_function
import sys
import libxml2
# Memory debug specific

View File

@ -1,15 +1,6 @@
#!/usr/bin/python -u
from __future__ import print_function
import sys
import string
import sys
if sys.version_info < (3, 0):
import StringIO as io
else:
import io
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
@ -42,7 +33,7 @@ def transform_test(ctx, node, inst, comp):
pass
tctxt.insertNode().addContent('SUCCESS')
styledoc = libxml2.parseDoc("""
@ -65,14 +56,6 @@ result = style.applyStylesheet(doc, None)
style.freeStylesheet()
doc.freeDoc()
extensions = io.StringIO()
libxslt.debugDumpExtensions(extensions)
if 0 and extensions.buf.find(EXT_URL) < 0:
print("Element extension not registered (or dumping broken)")
sys.exit(1)
root = result.children
if root.name != "article":

View File

@ -1,6 +1,4 @@
#!/usr/bin/python -u
from __future__ import print_function
import sys
import string
import libxml2
@ -24,7 +22,7 @@ def f(ctx, str):
except:
pass
return string.upper(str)
return str.upper()
libxslt.registerExtModuleFunction("foo", "http://example.com/foo", f)

View File

@ -4,8 +4,6 @@
# bindings, not complete yet and shows up the things missing
# from the existing python interfaces
#
from __future__ import print_function
import sys
import time
import os
@ -150,7 +148,7 @@ def main(args = None):
args = sys.argv[1:]
if len(args) <= 0:
usage(sys.argv[0])
i = 0
while i < len(args):
@ -211,12 +209,12 @@ def main(args = None):
print("Unknown option %s" % (args[i]))
usage()
return(3)
i = i + 1
libxml2.lineNumbersDefault(1)
libxml2.substituteEntitiesDefault(1)
# TODO: xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS