beginning with Python 3 compat
authorVolker Birk <vb@pep.foundation>
Sat, 10 Dec 2016 10:11:31 +0100
changeset 7 f81a4471bc28
parent 6 5ea9477ef8bb
child 8 b49a28a57f67
beginning with Python 3 compat
yml2c
yml2proc
--- a/yml2c	Wed Aug 24 21:22:51 2016 +0200
+++ b/yml2c	Sat Dec 10 10:11:31 2016 +0100
@@ -75,7 +75,7 @@
     result = parse(ymlC, files, True, comment, packrat=True)
 
     if options.parseonly:
-        print result
+        print(result)
     else:
         result = backend.finish(result)
         if options.normalization != "none":
@@ -86,17 +86,17 @@
             outfile.write(codecs.encode(result, options.encoding))
             outfile.close()
         else:
-            print codecs.encode(result, options.encoding)
+            print(codecs.encode(result, options.encoding))
 
 except KeyboardInterrupt:
     w("\n")
     sys.exit(1)
-except KeyError, msg:
+except KeyError as msg:
     w(u"not found: " + u(msg) + u"\n")
     sys.exit(4)
-except LookupError, msg:
+except LookupError as msg:
     w(u"not found: " + u(msg) + u"\n")
     sys.exit(4)
-except Exception, msg:
+except Exception as msg:
     w(msg)
     sys.exit(5)
--- a/yml2proc	Wed Aug 24 21:22:51 2016 +0200
+++ b/yml2proc	Sat Dec 10 10:11:31 2016 +0100
@@ -132,7 +132,7 @@
         else:
             result = parse(ymlC, files, True, comment)
             if options.parseonly:
-                print result
+                print(result)
                 sys.exit(0)
             else:
                 rtext = backend.finish(result)
@@ -224,25 +224,25 @@
         outfile.write(plaintext)
         outfile.close()
     else:
-        print plaintext
+        print(plaintext)
 
 except KeyboardInterrupt:
     w("\n")
     sys.exit(1)
-except YMLAssert, msg:
+except YMLAssert as msg:
     w(u"YML Assertion failed: " + u(msg) + u"\n")
     sys.exit(2)
-except KeyError, msg:
+except KeyError as msg:
     w(u"not found: " + u(msg) + u"\n")
     sys.exit(4)
-except LookupError, msg:
+except LookupError as msg:
     w(u"not found: " + u(msg) + u"\n")
     sys.exit(4)
-except etree.XMLSyntaxError, e:
+except etree.XMLSyntaxError as e:
     log = e.error_log.filter_from_level(etree.ErrorLevels.FATAL)
     for entry in log:
         w(u"XML error: " + u(entry.message) + u"\n")
     sys.exit(5)
-except Exception, msg:
+except Exception as msg:
     w(msg)
     sys.exit(5)