Skip to content

Commit 69a84ec

Browse files
committed
CommandLineRunner is extremely sensitive to argument order
It will fail in strange ways unless the file URIs *precede* all of the other arguments, including --raw.
1 parent 4f1f647 commit 69a84ec

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

zxing/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def decode(self, filenames, try_harder=False, possible_formats=None, pure_barcod
8585
fn = fn_or_im
8686
file_uris.append(pathlib.Path(fn).absolute().as_uri())
8787

88-
cmd = [self.java, '-cp', self.classpath, self.cls]
88+
cmd = [self.java, '-cp', self.classpath, self.cls] + file_uris
8989
if self.zxing_version_info and self.zxing_version_info >= (3, 5, 0):
9090
cmd.append('--raw')
9191
if try_harder:
@@ -97,7 +97,6 @@ def decode(self, filenames, try_harder=False, possible_formats=None, pure_barcod
9797
if possible_formats:
9898
for pf in possible_formats:
9999
cmd += ['--possible_formats', pf]
100-
cmd += file_uris
101100

102101
try:
103102
p = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.STDOUT, universal_newlines=False)
@@ -129,7 +128,7 @@ def decode(self, filenames, try_harder=False, possible_formats=None, pure_barcod
129128
fn = file_uri_to_path(stdout.splitlines()[0][63:].decode())
130129
raise BarCodeReaderException("Java library could not read image (is it in a supported format?)", fn)
131130
elif stdout.startswith(b'''Exception '''):
132-
raise BarCodeReaderException("Unknown Java exception", self.java) from RuntimeError(stdout)
131+
raise BarCodeReaderException("Unknown Java exception", self.java) from sp.CalledProcessError(0, cmd, stdout)
133132
elif p.returncode:
134133
raise BarCodeReaderException("Unexpected Java subprocess return code", self.java) from sp.CalledProcessError(p.returncode, cmd, stdout)
135134

0 commit comments

Comments
 (0)