Skip to content

universal_newlines is not respected if git process times out #1116

Closed

Description

@x-santiaga-x

In Git.execute if kill_check.isSet(): then stderr_value will be encoded to bytes even if universal_newlines is set.

Activity

  1. Byron commented on Jan 28, 2021

    @Byron
    Member

    Can you be more specific as to allow a PR to be created? In that moment I request a change of the subject as well.
    This issue isn't currently actionable.

    This issue will be reopened once the requested information was provided.

  2. x-santiaga-x commented on Jan 28, 2021

    @x-santiaga-x
    ContributorAuthor

    If we run operation long enough to be killed after timeout and use universal_newlines set to True as this

    from git.cmd import Git
    g = Git(r'/path/to/repo')
    g.rev_list('HEAD', kill_after_timeout=1e-6, universal_newlines=True)
    

    script execution stopped with traceback

    Traceback (most recent call last):
      File "../src/test.py", line 28, in <module>
        g.rev_list('HEAD', kill_after_timeout=1e-6, universal_newlines=True)
      File "/venv/path/lib64/python3.6/site-packages/git/cmd.py", line 542, in <lambda>
        return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
      File "/venv/path/lib64/python3.6/site-packages/git/cmd.py", line 1006, in _call_process
        return self.execute(call, **exec_kwargs)
      File "/venv/path/lib64/python3.6/site-packages/git/cmd.py", line 789, in execute
        if stderr_value.endswith(newline):
    TypeError: endswith first arg must be bytes or a tuple of bytes, not str
    

    because stderr_value is an error message about timeout decoded to bytes, but with universal_newlines = True newline is str, not bytes.

  3. reopened this on Jan 28, 2021
  4. changed the title [-]Yet another universal_newlines TypeError[/-] [+]`universal_newlines` is not respected if git process times out[/+] on Jan 28, 2021
  5. Byron commented on Jan 28, 2021

    @Byron
    Member

    Thanks a lot! This looks like the logic here needs to adhere to the universal newlines flag. Would you be able to submit a PR for a fix?

  6. added this to the v3.1.13 - Bugfixes milestone on Jan 28, 2021
  7. added a commit that references this issue on Apr 28, 2025
    3c19a6e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions