Commits

Lenard Lindstrom  committed b8dcf30

fix Python3.3 compatibility issue with makeref.py

  • Participants
  • Parent commits f52af9c

Comments (0)

Files changed (1)

File docs/reST/ext/utils.py

 import docutils.nodes
 import sphinx.addnodes
 
+import sys
+
 
 class GetError(LookupError):
     pass
 # as_unicode: Allow a Python "r" string to represent a unicode string.
 #   e.g.: as_unicode(r"Bo\u00F6tes") == u"Bo\u00F6tes" # Python 2.x
 #         as_unicode(r"Bo\u00F6tes") == "Bo\u00F6tes"  # Python 3.x
-try:
-    eval("u'a'")
+if sys.version_info < (3,):
     def as_bytes(string):
         """ '<binary literal>' => '<binary literal>' """
         return string
         """ r'<Unicode literal>' => u'<Unicode literal>' """
         return rstring.decode('unicode_escape', 'strict')
         
-except SyntaxError:
+else:
     def as_bytes(string):
         """ '<binary literal>' => b'<binary literal>' """
         return string.encode('latin-1', 'strict')