Skip to content

Apostrophe in syspath causes error #625

Closed

Description

@seanon414

Runtime

$ pre-commit
An unexpected error has occurred: ValueError: No closing quotation
Check the log at /Users/sean.o'neill/.cache/pre-commit/pre-commit.log

Stacktrace

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py", line 279, in split
    return list(lex)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py", line 269, in next
    token = self.get_token()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py", line 96, in get_token
    raw = self.read_token()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py", line 172, in read_token
    raise ValueError, "No closing quotation"
ValueError: No closing quotation

Username in path has an apostrophe in it (not by choice) and causes pre-commit to bomb

Computer info

OS: Mac El Caption 10.11.6
Version: pre-commit 1.1.2

Activity

  1. asottile commented on Sep 21, 2017

    @asottile
    Member

    Thanks for the report! Could you include the full contents of the log file (currently the stack trace doesn't include any of our code so I don't know what to fix!)

  2. asottile commented on Sep 21, 2017

    @asottile
    Member

    Through some guesswork, I've been able to reproduce this. Here's a full trace:

    An unexpected error has occurred: ValueError: No closing quotation
    Traceback (most recent call last):
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/error_handler.py", line 44, in error_handler
        yield
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/main.py", line 231, in main
        return run(runner, args)
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/commands/run.py", line 267, in run
        return _run_hooks(runner.config, repo_hooks, args, environ)
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/commands/run.py", line 189, in _run_hooks
        retval |= _run_single_hook(filenames, hook, repo, args, skips, cols)
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/commands/run.py", line 103, in _run_single_hook
        tuple(filenames) if hook['pass_filenames'] else (),
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/repository.py", line 198, in run_hook
        return languages[language_name].run_hook(cmd_runner, hook, file_args)
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/languages/system.py", line 14, in run_hook
        return xargs(helpers.to_cmd(hook), file_args)
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/xargs.py", line 63, in xargs
        *run_cmd, encoding=None, retcode=None
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/util.py", line 174, in cmd_output
        cmd = parse_shebang.normalize_cmd(cmd)
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/parse_shebang.py", line 68, in normalize_cmd
        cmd = parse_filename(exe) + (exe,) + cmd[1:]
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/pre_commit/parse_shebang.py", line 18, in parse_filename
        return parse_shebang_from_file(filename)
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/identify/identify.py", line 150, in parse_shebang_from_file
        return parse_shebang(f)
      File "/tmp/foo'bar/venv/local/lib/python2.7/site-packages/identify/identify.py", line 136, in parse_shebang
        cmd = tuple(shlex.split(first_line))
      File "/usr/lib/python2.7/shlex.py", line 279, in split
        return list(lex)
      File "/usr/lib/python2.7/shlex.py", line 269, in next
        token = self.get_token()
      File "/usr/lib/python2.7/shlex.py", line 96, in get_token
        raw = self.read_token()
      File "/usr/lib/python2.7/shlex.py", line 172, in read_token
        raise ValueError, "No closing quotation"
    ValueError: No closing quotation
    

    It seems this is a bug in an upstream library, I'm going to close this -- please track the fix in pre-commit/identify#26

  3. seanon414 commented on Sep 21, 2017

    @seanon414
    Author

    Yes here is full stuck trace for the record

    An unexpected error has occurred: ValueError: No closing quotation
    Traceback (most recent call last):
      File "/Library/Python/2.7/site-packages/pre_commit/error_handler.py", line 44, in error_handler
        yield
      File "/Library/Python/2.7/site-packages/pre_commit/main.py", line 231, in main
        return run(runner, args)
      File "/Library/Python/2.7/site-packages/pre_commit/commands/run.py", line 250, in run
        repo_hooks = list(get_repo_hooks(runner))
      File "/Library/Python/2.7/site-packages/pre_commit/commands/run.py", line 203, in get_repo_hooks
        for repo in runner.repositories:
      File "/Library/Python/2.7/site-packages/cached_property.py", line 26, in __get__
        value = obj.__dict__[self.func.__name__] = self.func(obj)
      File "/Library/Python/2.7/site-packages/pre_commit/runner.py", line 50, in repositories
        repo.require_installed()
      File "/Library/Python/2.7/site-packages/pre_commit/repository.py", line 185, in require_installed
        _install_all(self._venvs, self.repo_config['repo'], self.store)
      File "/Library/Python/2.7/site-packages/pre_commit/repository.py", line 99, in _install_all
        language.install_environment(cmd_runner, version, deps)
      File "/Library/Python/2.7/site-packages/pre_commit/languages/python.py", line 130, in install_environment
        ('pip', 'install', '.') + additional_dependencies,
      File "/Library/Python/2.7/site-packages/pre_commit/languages/helpers.py", line 9, in run_setup_cmd
        cmd_output(*cmd, cwd=runner.prefix_dir, encoding=None)
      File "/Library/Python/2.7/site-packages/pre_commit/util.py", line 174, in cmd_output
        cmd = parse_shebang.normalize_cmd(cmd)
      File "/Library/Python/2.7/site-packages/pre_commit/parse_shebang.py", line 68, in normalize_cmd
        cmd = parse_filename(exe) + (exe,) + cmd[1:]
      File "/Library/Python/2.7/site-packages/pre_commit/parse_shebang.py", line 18, in parse_filename
        return parse_shebang_from_file(filename)
      File "/Library/Python/2.7/site-packages/identify/identify.py", line 150, in parse_shebang_from_file
        return parse_shebang(f)
      File "/Library/Python/2.7/site-packages/identify/identify.py", line 136, in parse_shebang
        cmd = tuple(shlex.split(first_line))
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py", line 279, in split
        return list(lex)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py", line 269, in next
        token = self.get_token()
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py", line 96, in get_token
        raw = self.read_token()
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py", line 172, in read_token
        raise ValueError, "No closing quotation"
    ValueError: No closing quotation
    
  4. asottile commented on Sep 21, 2017

    @asottile
    Member

    If you upgrade identify to 1.0.6 (usually via pip install identify --upgrade) you should get a fix for this.

    Thanks again for the issue!

  5. seanon414 commented on Sep 21, 2017

    @seanon414
    Author

    Thanks for the fix!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions