# HG changeset patch # User cmlenz # Date 1207918272 0 # Node ID eabe96c809c39aeeec90e872c289cd8155d17149 # Parent 85c7bc435674c46b5b7e225733ef830af15985a8 Make dependency on the parser module optional. diff --git a/babel/util.py b/babel/util.py --- a/babel/util.py +++ b/babel/util.py @@ -16,7 +16,6 @@ import codecs from datetime import timedelta, tzinfo import os -import parser import re try: set @@ -75,8 +74,9 @@ 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