]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Reinstate changeset r362, but this time properly wrap the exception list in
authorJeroen Ruigrok van der Werven <asmodai@in-nomine.org>
Fri, 2 May 2008 22:13:17 +0000 (22:13 +0000)
committerJeroen Ruigrok van der Werven <asmodai@in-nomine.org>
Fri, 2 May 2008 22:13:17 +0000 (22:13 +0000)
braces.

Submitted by: cboos

babel/util.py

index 2ef92d654c4f4bac2054ee315d6fdba3a8b52bae..47f59afef07c6821f207cacf05fab897f28d8830 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