OptionParser on PPC64LE does not split args correctly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python2.7 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
The issue appears on PPC64 LE.
It is OK on (Ubuntu) x86_64.
Version of Python is 2.7.6 on both systems.
The issue is demonstrated while running AVRO Python tests (in lang/py : ant test).
- On Ubuntu / PPC64 LE :
$ pwd
..../lang/py
$ export PYTHONPATH=
$ /home/tony/
{"first": "daffy"}
{"first": "bugs"}
{"first": "tweety"}
{"first": "road"}
{"first": "wile"}
{"first": "pepe"}
{"first": "foghorn"}
Usage: avro cat|write [options] FILE [FILE...]
avro: error: Can't open last - [Errno 2] No such file or directory: 'last'
$ echo $?
2
The issue is that 'first, last' is not parsed correctly. The white space between "," and "last" is parsed in a way that makes "last" been interpreted as a "FILE" instead of an option.
Without the white space, that works fine:
$ /home/tony/
{"last": "duck", "first": "daffy"}
{"last": "bunny", "first": "bugs"}
{"last": "", "first": "tweety"}
{"last": "runner", "first": "road"}
{"last": "e", "first": "wile"}
{"last": "le pew", "first": "pepe"}
{"last": "leghorn", "first": "foghorn"}
$ echo $?
0
- On Ubuntu / x86_64, both 'first, last' and 'first,last' are OK:
$ pwd
..../lang/py
$ export PYTHONPATH=
$ build/test/
{"last": "duck", "first": "daffy"}
{"last": "bunny", "first": "bugs"}
{"last": "", "first": "tweety"}
{"last": "runner", "first": "road"}
{"last": "e", "first": "wile"}
{"last": "le pew", "first": "pepe"}
{"last": "leghorn", "first": "foghorn"}
$ echo $?
0
Source code of: /home/tony/
def main(argv=None):
import sys
from optparse import OptionParser, OptionGroup
argv = argv or sys.argv
parser = OptionParser(
....
So, OptionParser() does not work on PPC64 like it does on x86_64.
In Avro, the issue appears as:
[py-test] ERROR: test_fields (test_script. TestCat) ------- ------- ------- ------- ------- ------- ------- ------- ------- tony/AVRO/ avro-FromFreshI BMSOEGitHub/ lang/py/ build/test/ test_script. py", line 169, in test_fields '--fields' , 'first, last') tony/AVRO/ avro-FromFreshI BMSOEGitHub/ lang/py/ build/test/ test_script. py", line 109, in _run [SCRIPT, "cat", self.avro_file] + list(args)) python2. 7/subprocess. py", line 573, in check_output ror(retcode, cmd, output=output) tony/AVRO/ avro-FromFreshI BMSOEGitHub/ lang/py/ build/test/ ../scripts/ avro', 'cat', '/tmp/tmp3Oiy6H', '--fields', 'first, last']' returned non-zero exit status 2
[py-test] -------
[py-test] Traceback (most recent call last):
[py-test] File "/home/
[py-test] out = self._run(
[py-test] File "/home/
[py-test] out = check_output(
[py-test] File "/usr/lib/
[py-test] raise CalledProcessEr
[py-test] CalledProcessError: Command '['/home/
If the string 'first, last' is replaced by 'first,last' (no space), another issue appears (that does not appear on x86_64), with the string '' :
[py-test] ERROR: test_fields (test_script. TestCat) tony/AVRO/ avro-FromFreshI BMSOEGitHub/ lang/py/ build/test/ test_script. py", line 173, in test_fields '--fields' , '') tony/AVRO/ avro-FromFreshI BMSOEGitHub/ lang/py/ build/test/ test_script. py", line 109, in _run [SCRIPT, "cat", self.avro_file] + list(args)) python2. 7/subprocess. py", line 573, in check_output ror(retcode, cmd, output=output) tony/AVRO/ avro-FromFreshI BMSOEGitHub/ lang/py/ build/test/ ../scripts/ avro', 'cat', '/tmp/tmpJJp2gX', '--fields', '']' returned non-zero exit status 2
[py-test] Traceback (most recent call last):
[py-test]
[py-test] File "/home/
[py-test] Schema: ["string", "null", "long"]
[py-test] out = self._run(
[py-test] Datum: None
[py-test] File "/home/
[py-test] Codec: deflate
[py-test] out = check_output(
[py-test] Round Trip Data: [None, None, None, None, None, None, None, None, None, None]
[py-test] File "/usr/lib/
[py-test] Round Trip Data Length: 10
[py-test] raise CalledProcessEr
[py-test] Correct Round Trip: True
[py-test]
[py-test] CalledProcessError: Command '['/home/
The issue in Python is triggered by this Avro test file: py/build/ test/test_ script. py
lang/
class TestCat( unittest. TestCase) : '--fields' , 'first, last')
.....
def test_fields(self):
...
# Field selection (with comma and space)
out = self._run(
assert json.loads(out[0]) == {'first': 'daffy', 'last': 'duck'}
# Empty fields should get all '--fields' , '')
out = self._run(
So, there are 2 issues with OptionParser():
- 'first, last'
- '' (empty field)