git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] git-p4: fixed instantiation of CalledProcessError

From
Joel Holdsworth <jholdsworth@nvidia.com>
Date
Jan 6, 2022, 21:41 UTC
Message-ID
<20220106214156.90967-1-jholdsworth@nvidia.com>

CalledProcessError is an exception class from the subprocess namespace. When raising this exception, git-p4 would instantiate CalledProcessError objects without properly referencing the subprocess namespace causing the script to fail.

This patch resolves the issue by replacing CalledProcessError with subprocess.CalledProcessError.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
---
This version adds a previously missing sign-off.
 git-p4.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 986595bef0..eefac27803 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -394,7 +394,7 @@ def system(cmd, ignore_error=False):
         sys.stderr.write("executing %s\n" % str(cmd))
     retcode = subprocess.call(cmd, shell=expand)
     if retcode and not ignore_error:
-        raise CalledProcessError(retcode, cmd)
+        raise subprocess.CalledProcessError(retcode, cmd)
 
     return retcode
 
@@ -404,7 +404,7 @@ def p4_system(cmd):
     expand = not isinstance(real_cmd, list)
     retcode = subprocess.call(real_cmd, shell=expand)
     if retcode:
-        raise CalledProcessError(retcode, real_cmd)
+        raise subprocess.CalledProcessError(retcode, real_cmd)
 
 def die_bad_access(s):
     die("failure accessing depot: {0}".format(s.rstrip()))
@@ -4169,7 +4169,7 @@ def run(self, args):
             init_cmd.append("--bare")
         retcode = subprocess.call(init_cmd)
         if retcode:
-            raise CalledProcessError(retcode, init_cmd)
+            raise subprocess.CalledProcessError(retcode, init_cmd)
 
         if not P4Sync.run(self, depotPaths):
             return False
-- 
2.34.1
Message 1 of 1 in “git-p4: fixed instantiation of CalledProcessError”
  1. git-p4: fixed instantiation of CalledProcessErrorJoel Holdsworth, Jan 6, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.