--- embedaddon/libxml2/python/tests/reader3.py 2012/02/21 23:38:00 1.1 +++ embedaddon/libxml2/python/tests/reader3.py 2014/06/15 19:53:34 1.1.1.2 @@ -3,8 +3,13 @@ # this tests the entities substitutions with the XmlTextReader interface # import sys -import StringIO import libxml2 +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO docstr=""" """ def myResolver(URL, ID, ctxt): if URL == "simplestruct2.ent": - return(StringIO.StringIO(simplestruct2_ent)) + return(str_io(simplestruct2_ent)) return None libxml2.setEntityLoader(myResolver) -input = libxml2.inputBuffer(StringIO.StringIO(s)) +input = libxml2.inputBuffer(str_io(s)) reader = input.newTextReader("test3") reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) while reader.Read() == 1: @@ -135,8 +140,8 @@ while reader.Read() == 1: reader.Depth(),reader.IsEmptyElement()) if res != expect: - print "test3 failed: unexpected output" - print res + print("test3 failed: unexpected output") + print(res) sys.exit(1) # @@ -149,7 +154,7 @@ del reader # Memory debug specific libxml2.cleanupParser() if libxml2.debugMemory(1) == 0: - print "OK" + print("OK") else: - print "Memory leak %d bytes" % (libxml2.debugMemory(1)) + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) libxml2.dumpMemory()