Commits

Georg Brandl committed 18ee47d

Keep sphinx/__init__.py executable with Python 3.

Comments (0)

Files changed (1)

sphinx/__init__.py

     :license: BSD, see LICENSE for details.
 """
 
+# Keep this file executable as-is in Python 3!
+# (Otherwise getting the version out of it from setup.py is impossible.)
+
 import sys
 from os import path
 
 
 def main(argv=sys.argv):
     if sys.version_info[:3] < (2, 4, 0):
-        print >>sys.stderr, \
-              'Error: Sphinx requires at least Python 2.4 to run.'
+        sys.stderr.write('Error: Sphinx requires at least '
+                         'Python 2.4 to run.\n')
         return 1
 
     try:
         from sphinx import cmdline
-    except ImportError, err:
+    except ImportError:
+        err = sys.exc_info()[1]
         errstr = str(err)
         if errstr.lower().startswith('no module named'):
             whichmod = errstr[16:]
                 whichmod = 'roman module (which is distributed with Docutils)'
                 hint = ('This can happen if you upgraded docutils using\n'
                         'easy_install without uninstalling the old version'
-                        'first.')
+                        'first.\n')
             else:
                 whichmod += ' module'
-            print >>sys.stderr, ('Error: The %s cannot be found. '
-                                 'Did you install Sphinx and its dependencies '
-                                 'correctly?' % whichmod)
+            sys.stderr.write('Error: The %s cannot be found. '
+                             'Did you install Sphinx and its dependencies '
+                             'correctly?\n' % whichmod)
             if hint:
-                print >> sys.stderr, hint
+                sys.stderr.write(hint)
             return 1
         raise
     return cmdline.main(argv)