Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when no <directory> arg #3

Merged
merged 1 commit into from
Feb 5, 2015

Conversation

rakjin
Copy link
Contributor

@rakjin rakjin commented Feb 5, 2015

in case of <directory> is None, an error raises, as far as I tested

@@ -39,7 +39,7 @@ def watch(directory=None, auto_clear=False, extensions=[]):
"""Starts a server to render the specified file or directory containing a README."""
if directory and not os.path.isdir(directory):
raise ValueError('Directory not found: ' + directory)
directory = os.path.abspath(directory)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually fail?

When I run os.path.absapth(None) in the interpreter, it returns the absolute path of the current working directory. (On Windows anyway.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using OS X 10.9 and getting this:

$ python
Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os.path
>>> os.path.abspath(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 352, in abspath
    if not isabs(path):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 61, in isabs
    return s.startswith('/')
AttributeError: 'NoneType' object has no attribute 'startswith'
>>> 

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good enough for me.

@joeyespo joeyespo added the bug label Feb 5, 2015
@joeyespo
Copy link
Owner

joeyespo commented Feb 5, 2015

Thanks for the fix, @rakjin!

joeyespo added a commit that referenced this pull request Feb 5, 2015
@joeyespo joeyespo merged commit c2a80d7 into joeyespo:master Feb 5, 2015
@rakjin rakjin deleted the fix-none-directory-error branch February 6, 2015 02:32
@pyup-bot pyup-bot mentioned this pull request Aug 17, 2016
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants