--- /dev/null
+*.pyc
+/.tox
+/tests/tmp
+MANIFEST
 
 import xml.sax.handler
 from xml.sax.handler import feature_namespaces
 
-import texmlwr
-import specmap
-import StringIO
+from Texml import texmlwr
+from Texml import specmap
 import string
-import os, sys
 
 # Unbreakable spaces should not be deleted by strip(), but it happens:
 # http://uucode.com/blog/2010/06/01/python-wtf-strip-eats-too-much/
       else:
         msg += '%s not expected' % (local_name)
 
-      raise InvalidXmlException, msg
+      raise InvalidXmlException(msg)
 
   def invalid_xml_other(self, msg):
       # for other types of invalid XML
-      raise InvalidXmlException, msg
+      raise InvalidXmlException(msg)
 
   # -------------------------------------------------------------------
   
 
       encoding     = encoding,
       always_ascii = always_ascii,
       use_context  = use_context)
-except Exception, msg:
+except Exception as msg:
   print sys.stderr, 'texml: %s' % str(msg)
 
 # Clean up resources
 
 PDF     = 4
 WEAK_WS_IS_NEWLINE = 2
 
-import unimap
-import specmap
+from Texml import unimap
+from Texml import specmap
 import codecs
 import os
 import sys
 import string
 
+if sys.version_info[0] >= 3:
+    byteord = lambda c: c
+else:
+    byteord = ord
+
 #
 # Writer&Co class
 #
       if always_ascii:
         encoding        = 'ascii'
       self.stream     = stream_encoder(stream, encoding)
-    except Exception, e:
+    except Exception as e:
       raise ValueError("Can't create encoder: '%s'" % e)
     # Continue initialization
     self.after_char0d     = 1
       try:
         bytes = ch.encode(self.encoding)
         for by in bytes:
-          self.write('^^%02x' % ord(by), 0)
+          self.write('^^%02x' % byteord(by), 0)
         return
-      except Exception, e:
+      except Exception as e:
         pass
     #
     # Symbol have to be rewritten. Let start with math mode.
     """ Write char in Acrobat utf16be encoding """
     bytes = ch.encode('utf_16_be')
     for by in bytes:
-      self.write('\\%03o' % ord(by), 0)
+      self.write('\\%03o' % byteord(by), 0)
       
 #
 # Wrapper over output stream to write is desired encoding
 
 import getopt
 try:
   opts, args = getopt.getopt(sys.argv[1:], 'hcaw:e:', ['help', 'context', 'ascii', 'width=', 'encoding=', ])
-except getopt.GetoptError, e:
+except getopt.GetoptError as e:
   print >>sys.stderr, 'texml: Can\'t parse command line: %s' % e
   print >>sys.stderr, usage
   sys.exit(2)
 if '-' == outfile:
   f = sys.stdout
 else:
-  f = file(outfile, 'wb')
+  f = open(outfile, 'wb')
 
 #
 # An error handler
 try:
   Texml.processor.process(infile, f, encoding, width, always_ascii, use_context)
     
-except Exception, msg:
+except Exception as msg:
   msg = 'texml: %s\n' % (str(msg))
   quit(msg)
 
 
 import re
 import glob
 
-def test_for_sax():
-    try:
-        import xml.sax
-    except ImportError:
-        sys.stderr.write('Please install the python pyxml modules\n')
-        sys.stdout.write('You must have this module before you can install texml\n')
-        sys.exit(1)
-
-def get_dtd_location():
-    """
-    For now, this is not used
-
-    """
-    return
-    return '/home/paul/Documents/data/dtds/'
-
 
 def get_version():
     # Take the version from "scripts/texml.py"
       raise "Can't find version"
     return version
 
-if 'build' in sys.argv:
-    test_for_sax()
 
 version = get_version()
 
 
--- /dev/null
+[tox]
+envlist =
+    py{26,27,34,35,36,37},
+
+[testenv]
+changedir = tests
+commands = 
+       make clean
+       make
+whitelist_externals=make