diff options
Diffstat (limited to 'dcoppython/shell/gen_marshal_code.py')
| -rw-r--r-- | dcoppython/shell/gen_marshal_code.py | 20 | 
1 files changed, 10 insertions, 10 deletions
| diff --git a/dcoppython/shell/gen_marshal_code.py b/dcoppython/shell/gen_marshal_code.py index b6ae516f..5d947102 100644 --- a/dcoppython/shell/gen_marshal_code.py +++ b/dcoppython/shell/gen_marshal_code.py @@ -33,13 +33,13 @@ class DictMaker:      def handle_string_marsh(self, attribute):          """Handle marshalling of string item from the dictionary.""" -        return ["if (%s && !PyString_Check(%s)) return false;" % (attribute, attribute), -                "if (%s) { qobj.%s(TQString(PyString_AsString(%s)));" % (attribute, set_method(attribute), attribute), +        return ["if (%s && !PyBytes_Check(%s)) return false;" % (attribute, attribute), +                "if (%s) { qobj.%s(TQString::fromUtf8(PyBytes_AS_STRING(%s)));" % (attribute, set_method(attribute), attribute),                  "PyDict_DelItemString(dict,(char*)\"%s\"); } " % (attribute)]      def handle_string_demarsh(self, attribute):          """Handle demarshalling of string items into the dictionary.""" -        return ["PyObject *%s = PyString_FromString(qobj.%s().utf8().data() );" % (attribute ,attribute), +        return ["PyObject *%s = PyBytes_FromString(qobj.%s().utf8().data() );" % (attribute ,attribute),                  "PyDict_SetItemString(dict, (char*)\"%s\", %s);" % (attribute, attribute)                  ] @@ -141,7 +141,7 @@ class DocType:  MARSHAL, DEMARSHAL, TOPYOBJ, FROMPYOBJ = 0,1,2,3  if len(sys.argv)!=4: -    print "Use: gen_marshal_code.py <input file> <output file> <doc-xml-output file>" +    print("Use: gen_marshal_code.py <input file> <output file> <doc-xml-output file>")      raise RuntimeError  nowt, in_name, code_name, doc_xml_name = tuple(sys.argv) @@ -267,10 +267,10 @@ out_file.writelines([x + '\n' for x in gen_code_comments])  out_file.writelines([x + '\n' for x in code])  out_file.close() -xml_file = file(doc_xml_name,"w") -print >>xml_file, '<?xml version="1.0" ?>' -print >>xml_file, '<!-- This file was auto-generated by gen_marshal_code.py. Changes will be lost! -->' -print >>xml_file, "<types>" -[ [xml_file.write(x+"\n") for x in doc.xml()] for doc in doc_types.values() ] # silly one-liner -print >>xml_file, "</types>" +xml_file = open(doc_xml_name,"w") +print('<?xml version="1.0" ?>', file=xml_file) +print('<!-- This file was auto-generated by gen_marshal_code.py. Changes will be lost! -->', file=xml_file) +print("<types>", file=xml_file) +[ [xml_file.write(x+"\n") for x in doc.xml()] for doc in list(doc_types.values()) ] # silly one-liner +print("</types>", file=xml_file)  xml_file.close() | 
