gpt4 book ai didi

python - 类型错误 : execv() arg 2 must contain only strings

转载 作者:行者123 更新时间:2023-11-30 23:30:48 25 4
gpt4 key购买 nike

我遇到了以下错误,错误所指向的第 158 行如下所示。任何人都可以帮助解决问题是什么以及如何解决它吗?

def getGerritInfo(num):
user = pwd.getpwuid(os.getuid())[0]
gerritCmd = ("ssh -p 29418 review-android.quicinc.com gerrit query --format=JSON --dependencies ").split(' ')
xargs = ['change:'+num]
gerritPipe = Popen(gerritCmd+xargs, stdout=PIPE, stderr=PIPE) --> line 158
(output, error) = gerritPipe.communicate()
if error != "":
print error
raise IOError, "gerrit command %s failed" % (gerritCmd)
d = json.loads(output.split('\n')[0])
if len(d) == 3:
return {}
return d

错误:-

  File "find_dependencies.py", line 437, in <module>
main()
File "find_dependencies.py", line 211, in main
(dep_gerrit,depgerrit_status,depgerrit_error)=findinternaldep(internal_dep,num)
File "find_dependencies.py", line 100, in findinternaldep
gerrit = getGerritInfo(change)
File "find_dependencies.py", line 158, in getGerritInfo
gerritPipe = Popen(gerritCmd+xargs, stdout=PIPE, stderr=PIPE)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
TypeError: execv() arg 2 must contain only strings

最佳答案

尝试:

xargs = ['change:%s' % str(num)]

这将确保所有部分都是字符串。

就我个人而言,我还会在您的错误处理程序中设置 d = {} 而不是 return {} 以确保您只有一个 return >.

关于python - 类型错误 : execv() arg 2 must contain only strings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20321251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com