Repository navigation
CalledProcessError attempting to add a blurb #275
Description
Activity
Running the command manually succeeded. Not sure why git would fail with an exit code of 128 and not emit any output. Oh, because the code swallows the output.
Running a second time with pdb, I did not encounter the error (though I did encounter another error):
cpython bdd249c68f $ rwt blurb -- -m pdb -m blurb Collecting blurb Using cached https://files.pythonhosted.org/packages/41/90/cdce96c5f5767e08a87dad88cb2da0b962c692e826d2083d983d1f6f4019/blurb-1.0.7-py3-none-any.whl Installing collected packages: blurb Successfully installed blurb-1.0.7 > /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/rwt-1gtoodu2/blurb.py(2)<module>() -> """Command-line tool to manage CPython Misc/NEWS.d entries.""" (Pdb) b blurb:1111 Breakpoint 1 at /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/rwt-1gtoodu2/blurb.py:1111 (Pdb) c > /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/rwt-1gtoodu2/blurb.py(1111)flush_git_add_files() -> subprocess.run(["git", "add", "-f", *git_add_files], stdout=subprocess.PIPE, stderr=subprocess.PIPE).check_returncode() (Pdb) subprocess.PIPE=None (Pdb) n > /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/rwt-1gtoodu2/blurb.py(1112)flush_git_add_files() -> git_add_files.clear() (Pdb) c Ready for commit. The program exited via sys.exit(). Exit status: > /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/rwt-1gtoodu2/blurb.py(2)<module>() -> """Command-line tool to manage CPython Misc/NEWS.d entries.""" (Pdb) q Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/rwt-1gtoodu2/blurb.py", line 888, in <lambda> atexit.register(lambda : os.unlink(tmp_path)) NameError: name 'os' is not defined@jaraco how is git put on your PATH? It looks like
shell=Trueisn't set which would mean that if you're adding git through e.g..bashrcit wouldn't be available tosubprocess.I'm on macOS 10.13.6 with
git2.18.0 in/usr/local/binas installed by homebrew. And I use programs dozens of times daily that invokesubprocess.Popen(['git', ...])(manly setuptools_scm).I honestly can't imagine what might have gone wrong.
I tried running the command a couple more times (same as before), but this time didn't encounter the error.
Still, I wonder if it would be better to let the output from the git invocation be piped directly to stdout/stderr:
core-workflow master $ git diff diff --git a/blurb/blurb.py b/blurb/blurb.py index 10dac4d..001c7bd 100755 --- a/blurb/blurb.py +++ b/blurb/blurb.py @@ -697,7 +697,7 @@ def chdir_to_repo_root(): # find the root of the local CPython repo # note that we can't ask git, because we might # be in an exported directory tree! - + # we intentionally start in a (probably nonexistant) subtree # the first thing the while loop does is .., basically path = os.path.abspath("garglemox") @@ -1108,14 +1108,14 @@ Python News git_add_files = [] def flush_git_add_files(): if git_add_files: - subprocess.run(["git", "add", "-f", *git_add_files], stdout=subprocess.PIPE, stderr=subprocess.PIPE).check_returncode() + subprocess.run(["git", "add", "-f", *git_add_files]).check_returncode() git_add_files.clear() git_rm_files = [] def flush_git_rm_files(): if git_rm_files: try: - subprocess.run(["git", "rm", "-f", *git_rm_files], stdout=subprocess.PIPE, stderr=subprocess.PIPE).check_returncode() + subprocess.run(["git", "rm", "-f", *git_rm_files]).check_returncode() except subprocess.CalledProcessError: passOr if there's some reason to capture the output (there isn't any output at all in my use case), use that output when reporting an exception.
I can see there is some output from
git rmthat would be suppressed by the PIPE parameter. Perhaps better would be to usegit rm -qif blurb wishes for the command to run with minimal output.- added a commit that references this issue
on Jul 14, 2018 JFYI
$ git rm -f non-existing-filereturns code128. This could've happened because of double-run of this command on the same file, for example. (First run removes file from fs successfully with rc 0, second fails to locate it and returns 128)Also, this happens to untracked files (not
git added):$ touch some_file $ git rm -f some_file fatal: pathspec 'some_file' did not match any files $ echo $? 128
The original error I hit was during git add.
git adding non-existing file is also128.
I'm attempting to use blurb for the first time, but right off the bat, I'm getting a CalledProcessError: