Interesting discovery from automatic tools (python code)
Pavel Sanda
sanda at lyx.org
Thu Aug 11 18:29:25 UTC 2022
On Thu, Aug 11, 2022 at 05:55:47PM +0100, José Matos wrote:
> On Thu, 2022-08-11 at 17:07 +0200, Pavel Sanda wrote:
> > It seems that subprocess.check_call is raising exception instead of
> > returning non-zero,
> > so I gave it except block.
>
> What type of exception did you get?
convert-im6.q16: attempt to perform an operation not allowed by the security policy `PS' @ error/constitute.c/IsCoderAuthorized/421.
convert-im6.q16: no images defined `mock.png' @ error/convert.c/ConvertImageCommand/3229.
Traceback (most recent call last):
File "/home/lyx/devel/lib/configure.py", line 2077, in <module>
checkConverterEntries()
File "/home/lyx/devel/lib/configure.py", line 1202, in checkConverterEntries
if subprocess.check_call([cmd, "mock.eps", "mock.png"])==0:
File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['convert', 'mock.eps', 'mock.png']' returned non-zero exit status 1.
Systemcall.cpp (306): Systemcall: 'python3 -tt "/home/lyx/devel/lib/configure.py" --binary-dir="/home/lyx/devel/src/"' finished with exit code 1
> I did not use the exceptions to understand the failure reasons.
> The issue with the except is that it is a catch all option and so the
> exception could be caused by faulty assumptions from us in the initial
> code.
My understanding is that subprocess.check_call does not return nonzero
to signal nonzero exit status of the called subroutine, but raises
exception. So the correct thing is to catch exception, not checking
return value of subprocess.check_call. (?)
Pavel
More information about the lyx-devel
mailing list