Skip to content

Commit 4f047a1

Browse files
committed
Catch import errors thrown by os.path.expanduser(); issue #297
* This can happen particularly with AppEngine when importing pwd
1 parent 904e376 commit 4f047a1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pep8.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,15 @@
6666

6767
DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__,.tox'
6868
DEFAULT_IGNORE = 'E123,E226,E24,E704'
69-
if sys.platform == 'win32':
70-
DEFAULT_CONFIG = os.path.expanduser(r'~\.pep8')
71-
else:
72-
DEFAULT_CONFIG = os.path.join(os.getenv('XDG_CONFIG_HOME') or
73-
os.path.expanduser('~/.config'), 'pep8')
69+
try:
70+
if sys.platform == 'win32':
71+
DEFAULT_CONFIG = os.path.expanduser(r'~\.pep8')
72+
else:
73+
DEFAULT_CONFIG = os.path.join(os.getenv('XDG_CONFIG_HOME') or
74+
os.path.expanduser('~/.config'), 'pep8')
75+
except ImportError:
76+
DEFAULT_CONFIG = None
77+
7478
PROJECT_CONFIG = ('setup.cfg', 'tox.ini', '.pep8')
7579
TESTSUITE_PATH = os.path.join(os.path.dirname(__file__), 'testsuite')
7680
MAX_LINE_LENGTH = 79

0 commit comments

Comments
 (0)