summaryrefslogtreecommitdiff
path: root/pyflakes/scripts
diff options
context:
space:
mode:
authorexarkun <exarkun>2009-07-06 12:03:57 +0000
committerexarkun <exarkun>2009-07-06 12:03:57 +0000
commit45dd3db9d2c059ad5e9ee85042dd3e618fa5458d (patch)
tree2c87159f4cf87bd0123921bcd46fd087f9b95365 /pyflakes/scripts
parentdd5679736ea780ac74343bde015b13883d7aab83 (diff)
downloadpyflakes-45dd3db9d2c059ad5e9ee85042dd3e618fa5458d.tar.gz
Merge pyflakes-decoding-2.4-2902
Author: exarkun Reviewer: glyph Fixes: #2902 Handle the `MemoryError` Python 2.4 raises when compiling a string which cannot be decoded according to its declared encoding.
Diffstat (limited to 'pyflakes/scripts')
-rw-r--r--pyflakes/scripts/pyflakes.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/pyflakes/scripts/pyflakes.py b/pyflakes/scripts/pyflakes.py
index e3e6d77..da8d2ea 100644
--- a/pyflakes/scripts/pyflakes.py
+++ b/pyflakes/scripts/pyflakes.py
@@ -25,7 +25,14 @@ def check(codeString, filename):
# Since compiler.parse does not reliably report syntax errors, use the
# built in compiler first to detect those.
try:
- compile(codeString, filename, "exec")
+ try:
+ compile(codeString, filename, "exec")
+ except MemoryError:
+ # Python 2.4 will raise MemoryError if the source can't be
+ # decoded.
+ if sys.version_info[:2] == (2, 4):
+ raise SyntaxError(None)
+ raise
except (SyntaxError, IndentationError), value:
msg = value.args[0]