I encountered an exeption in pathspec when This line gives an error when the string "!\n" is passed, specifically due to a stray linebreak in the .gitignore file. https://github.com/cpburnz/python-path-specification/blob/master/pathspec/patterns/gitwildmatch.py#L112 I am not sure what the expected behaviour is here, but it may be best to ignore rather than crash on the line.