Index: src/local_doctest.py
===================================================================
--- src/local_doctest.py	(revision 76339)
+++ src/local_doctest.py	(working copy)
@@ -369,9 +369,9 @@
 # [XX] Normalize with respect to os.path.pardir?
 def _module_relative_path(module, path):
     if not inspect.ismodule(module):
-        raise TypeError, 'Expected a module: %r' % module
+        raise TypeError('Expected a module: %r' % module)
     if path.startswith('/'):
-        raise ValueError, 'Module-relative files may not have absolute paths'
+        raise ValueError('Module-relative files may not have absolute paths')
 
     # Find the base directory for the path.
     if hasattr(module, '__file__'):
@@ -897,7 +897,7 @@
         add them to `tests`.
         """
         if self._verbose:
-            print 'Finding tests in %s' % name
+            print('Finding tests in %s' % name)
 
         # If we've already processed this object, then ignore it.
         if id(obj) in seen:
@@ -1059,7 +1059,7 @@
         >>> tests = DocTestFinder().find(_TestClass)
         >>> runner = DocTestRunner(verbose=False)
         >>> for test in tests:
-        ...     print runner.run(test)
+        ...     print(runner.run(test))
         (0, 2)
         (0, 1)
         (0, 2)
@@ -1252,8 +1252,8 @@
             # keyboard interrupts.)
             try:
                 # Don't blink!  This is where the user's code gets run.
-                exec compile(example.source, filename, "single",
-                             compileflags, 1) in test.globs
+                exec(compile(example.source, filename, "single",
+                             compileflags, 1), test.globs)
                 self.debugger.set_continue() # ==== Example Finished ====
                 exception = None
             except KeyboardInterrupt:
@@ -1427,28 +1427,28 @@
                 failed.append(x)
         if verbose:
             if notests:
-                print len(notests), "items had no tests:"
+                print("%s items had no tests:" % len(notests))
                 notests.sort()
                 for thing in notests:
-                    print "   ", thing
+                    print("    %s" % thing)
             if passed:
-                print len(passed), "items passed all tests:"
+                print("%s items passed all tests:" % len(passed))
                 passed.sort()
                 for thing, count in passed:
-                    print " %3d tests in %s" % (count, thing)
+                    print(" %3d tests in %s" % (count, thing))
         if failed:
-            print self.DIVIDER
-            print len(failed), "items had failures:"
+            print(self.DIVIDER)
+            print("%s items had failures:" % len(failed))
             failed.sort()
             for thing, (f, t) in failed:
-                print " %3d of %3d in %s" % (f, t, thing)
+                print(" %3d of %3d in %s" % (f, t, thing))
         if verbose:
-            print totalt, "tests in", len(self._name2ft), "items."
-            print totalt - totalf, "passed and", totalf, "failed."
+            print("%s tests in %s items." % (totalt, len(self._name2ft)))
+            print("%s passed and %s failed." % (totalt - totalf, totalf))
         if totalf:
-            print "***Test Failed***", totalf, "failures."
+            print("***Test Failed*** %s failures." % totalf)
         elif verbose:
-            print "Test passed."
+            print("Test passed.")
         return totalf, totalt
 
     #/////////////////////////////////////////////////////////////////
@@ -1458,8 +1458,8 @@
         d = self._name2ft
         for name, (f, t) in other._name2ft.items():
             if name in d:
-                print "*** DocTestRunner.merge: '" + name + "' in both" \
-                    " testers; summing outcomes."
+                print("*** DocTestRunner.merge: '" + name + "' in both"
+                    " testers; summing outcomes.") 
                 f2, t2 = d[name]
                 f = f + f2
                 t = t + t2
@@ -2037,10 +2037,10 @@
     def runstring(self, s, name):
         test = DocTestParser().get_doctest(s, self.globs, name, None, None)
         if self.verbose:
-            print "Running string", name
+            print("Running string %s" % name)
         (f,t) = self.testrunner.run(test)
         if self.verbose:
-            print f, "of", t, "examples failed in string", name
+            print("%s of %s examples failed in string %s" % (f, t, name))
         return (f,t)
 
     def rundoc(self, object, name=None, module=None):
@@ -2487,7 +2487,7 @@
        ...           Ho hum
        ...           '''
 
-       >>> print script_from_examples(text)
+       >>> print(script_from_examples(text))
        # Here are examples of simple math.
        #
        #     Python has super accurate integer addition
@@ -2578,7 +2578,7 @@
             try:
                 execfile(srcfilename, globs, globs)
             except:
-                print sys.exc_info()[1]
+                print(sys.exc_info()[1])
                 pdb.post_mortem(sys.exc_info()[2])
         else:
             # Note that %r is vital here.  '%s' instead can, e.g., cause
@@ -2620,7 +2620,7 @@
         """val -> _TestClass object with associated value val.
 
         >>> t = _TestClass(123)
-        >>> print t.get()
+        >>> print(t.get())
         123
         """
 
@@ -2640,7 +2640,7 @@
         """get() -> return TestClass's associated value.
 
         >>> x = _TestClass(-42)
-        >>> print x.get()
+        >>> print(x.get())
         -42
         """
 
@@ -2672,7 +2672,7 @@
 
             "blank lines": r"""
                 Blank lines can be marked with <BLANKLINE>:
-                    >>> print 'foo\n\nbar\n'
+                    >>> print('foo\n\nbar\n')
                     foo
                     <BLANKLINE>
                     bar
@@ -2682,14 +2682,14 @@
             "ellipsis": r"""
                 If the ellipsis flag is used, then '...' can be used to
                 elide substrings in the desired output:
-                    >>> print range(1000) #doctest: +ELLIPSIS
+                    >>> print(range(1000)) #doctest: +ELLIPSIS
                     [0, 1, 2, ..., 999]
             """,
 
             "whitespace normalization": r"""
                 If the whitespace normalization flag is used, then
                 differences in whitespace are ignored.
-                    >>> print range(30) #doctest: +NORMALIZE_WHITESPACE
+                    >>> print(range(30)) #doctest: +NORMALIZE_WHITESPACE
                     [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
                      15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
                      27, 28, 29]
Index: src/lxml/tests/test_errors.py
===================================================================
--- src/lxml/tests/test_errors.py	(revision 76339)
+++ src/lxml/tests/test_errors.py	(working copy)
@@ -1,4 +1,4 @@
-﻿# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
 import unittest, doctest
 
 # These tests check that error handling in the Pyrex code is
Index: src/lxml/html/tests/transform_feedparser_data.py
===================================================================
--- src/lxml/html/tests/transform_feedparser_data.py	(revision 76339)
+++ src/lxml/html/tests/transform_feedparser_data.py	(working copy)
@@ -88,10 +88,10 @@
     try:
         output = serialize_content(parse_content(c))
     except:
-        print 'Bad data in %s:' % filename
-        print c
+        print('Bad data in %s:' % filename)
+        print(c)
         traceback.print_exc()
-        print '-'*60
+        print('-'*60)
         return
     new = os.path.splitext(filename)[0] + '.data'
     f = open(new, 'wb')
Index: src/lxml/html/_diffcommand.py
===================================================================
--- src/lxml/html/_diffcommand.py	(revision 76339)
+++ src/lxml/html/_diffcommand.py	(working copy)
@@ -82,6 +82,6 @@
     return pre, html, post
 
 def annotate(options, args):
-    print "Not yet implemented"
+    print("Not yet implemented")
     sys.exit(1)
     
