1.3, 1.3.1 fail if HOME not in environment. #125

Closed
spazm opened this Issue Sep 6, 2012 · 1 comment

Comments

Projects
None yet
2 participants

spazm commented Sep 6, 2012

This was introduced with pull 22 and fixed by the changes for issue 95.

Strangely enough, my jenkins build doesn't get a HOME entry in its environment. Documenting in case someone else hits the same issue.

(perrylib_ve)[vm53@vm53] 1179% echo $HOME
/home/vm53
(perrylib_ve)[vm53@vm53] 1180% pep8 --version
1.3
(perrylib_ve)[vm53@vm53] 1229% pep8 --version
Traceback (most recent call last):
  File "/home/vm53/src/austin/perrylib/perrylib_ve/bin/pep8", line 8, in <module>
    load_entry_point('pep8==1.3', 'console_scripts', 'pep8')()
  File "/home/vm53/src/austin/perrylib/perrylib_ve/local/lib/python2.7/site-packages/pkg_resources.py", line 318, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/vm53/src/austin/perrylib/perrylib_ve/local/lib/python2.7/site-packages/pkg_resources.py", line 2221, in load_entry_point
    return ep.load()
  File "/home/vm53/src/austin/perrylib/perrylib_ve/local/lib/python2.7/site-packages/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/home/vm53/src/austin/perrylib/perrylib_ve/local/lib/python2.7/site-packages/pep8.py", line 118, in <module>
    os.path.join(os.getenv("HOME"), ".config"), "pep8")
  File "/home/vm53/src/austin/perrylib/perrylib_ve/lib/python2.7/posixpath.py", line 68, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'

(perrylib_ve)[vm53@vm53] 1179% echo $HOME
/home/vm53
(perrylib_ve)[vm53@vm53] 1180% pep8 --version
1.3.1

(perrylib_ve)[vm53@vm53] 1181% unset HOME
(perrylib_ve)[vm53@vm53] 1182% pep8 --version
Traceback (most recent call last):
  File "/home/vm53/src/austin/perrylib/perrylib_ve/bin/pep8", line 9, in <module>
    load_entry_point('pep8==1.3.1', 'console_scripts', 'pep8')()
  File "/home/vm53/src/austin/perrylib/perrylib_ve/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 318, in load_entry_point
    """Locate distribution `dist_spec` and run its `script_name` script"""
  File "/home/vm53/src/austin/perrylib/perrylib_ve/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2221, in load_entry_point
    for line in self.get_metadata_lines(name):
  File "/home/vm53/src/austin/perrylib/perrylib_ve/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1954, in load
    """
  File "/home/vm53/src/austin/perrylib/perrylib_ve/local/lib/python2.7/site-packages/pep8.py", line 117, in <module>
    os.path.join(os.getenv("HOME"), ".config"), "pep8")
  File "/home/vm53/src/austin/perrylib/perrylib_ve/lib/python2.7/posixpath.py", line 68, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'

(perrylib_ve)[vm53@vm53] 1221% unset HOME
(perrylib_ve)[vm53@vm53] 1222% pep8 --version
1.3.2

@spazm spazm closed this Sep 6, 2012

Owner

sigmavirus24 commented Sep 6, 2012

I wonder if amending that logic to use something like

os.path.join(os.environ('HOME', './'), ...)

Would be a better idea. That would prevent a bizarre error like this entirely. Or you could even just make it default to an empty string.

Edit Somehow I skipped over the beginning of your message mentioning that this was already fixed. Whoops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment