threads / patch / 57189

patchgit-p4: fixed instantiation of CalledProcessError

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

## tl;dr

2 messages between Jan 5, 2022 and Jan 6, 2022. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Joel Holdsworth· Jan 5, 2022, 14:14 UTC · lore

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.
---
 git-p4.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Show changes to git-p4.py +3 −3
diff --git a/git-p4.py b/git-p4.py
index cb37545455..ab3822696c 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -406,7 +406,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
 
@@ -416,7 +416,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()))
@@ -4110,7 +4110,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
Eric Sunshine· Jan 6, 2022, 17:49 UTC · re: Joel Holdsworth · lore

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

On Thu, Jan 6, 2022 at 1:56 AM Joel Holdsworth <jholdsworth@nvidia.com> wrote:
Show 8 quoted lines
> 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.
> ---
MIssing sign-off.

← back to recent threads