]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Make dependency on the parser module optional.
authorChristopher Lenz <cmlenz@gmail.com>
Fri, 11 Apr 2008 12:51:12 +0000 (12:51 +0000)
committerChristopher Lenz <cmlenz@gmail.com>
Fri, 11 Apr 2008 12:51:12 +0000 (12:51 +0000)
babel/util.py

index 2ef92d654c4f4bac2054ee315d6fdba3a8b52bae..195e538f9c849c36c1c7e1d7d1eb081b264c0744 100644 (file)
@@ -16,7 +16,6 @@
 import codecs
 from datetime import timedelta, tzinfo
 import os
-import parser
 import re
 try:
     set
@@ -75,8 +74,9 @@ def parse_encoding(fp):
         m = PYTHON_MAGIC_COMMENT_re.match(line1)
         if not m:
             try:
+                import parser
                 parser.suite(line1)
-            except SyntaxError:
+            except ImportError, SyntaxError:
                 # Either it's a real syntax error, in which case the source is
                 # not valid python source, or line2 is a continuation of line1,
                 # in which case we don't want to scan line2 for a magic