Skip to content

Commit

Permalink
Sanitize the Python 2 check.
Browse files Browse the repository at this point in the history
This broke for me on a project that has a module called 'builtins'.
Let's just do a proper check using the normal `sys.version_info` API.
  • Loading branch information
nvie committed Dec 19, 2013
1 parent c57a450 commit 72263b4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pyflakes/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
import doctest
import os
import sys
try:
builtin_vars = dir(__import__('builtins'))
PY2 = False
except ImportError:
builtin_vars = dir(__import__('__builtin__'))

if sys.version_info < (3, 0):
PY2 = True
builtin_vars = dir(__import__('__builtin__'))
else:
PY2 = False
builtin_vars = dir(__import__('builtins'))

try:
import ast
Expand Down

0 comments on commit 72263b4

Please sign in to comment.