You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Will Duckworth (JIRA)" <ji...@apache.org> on 2012/06/20 14:37:42 UTC

[jira] [Created] (PIG-2762) Command line arguments are not passed to embedded python

Will Duckworth created PIG-2762:
-----------------------------------

             Summary: Command line arguments are not passed to embedded python
                 Key: PIG-2762
                 URL: https://issues.apache.org/jira/browse/PIG-2762
             Project: Pig
          Issue Type: Bug
    Affects Versions: 0.10.0
         Environment: CentOS release 5.6 (Final) Linux 2.6.18-238.5.1.el5 x86_64 with JDK 1.6; both Jython 2.5.0 (version that shipped with the Pig 0.10.0 RC package) and Jython 2.5.2 (standalone build).
            Reporter: Will Duckworth


*Summary*
Using Pig 0.10 and embedded Pig Latin in Python the command line parameters are not passed to python. Attempting to access sys.argv throws "index out of range" from python.

*Steps to Reproduce*
Create a simple Python script that uses embedded python: 

{code}
#!/usr/bin/python
 
import sys
from org.apache.pig.scripting import Pig
 
def main():
  print sys.argv[1]

if __name__ == '__main__':
  main()
{code}

Run:

{code}
$ /path/to/pig pytest.py one_script
2012-06-20 08:19:05,716 [main] INFO  org.apache.pig.Main - Apache Pig version 0.10.0 (r1328203)
[ ... snip ... ]
2012-06-20 08:19:07,204 [main] INFO  org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting UDF: main
2012-06-20 08:19:07,225 [main] ERROR org.apache.pig.Main - ERROR 1121: Python Error. Traceback (most recent call last):
  File "/path/to/pytest.py", line 10, in <module>
    main()
  File "/path/to/pytest.py", line 7, in main
    print sys.argv[1]
IndexError: index out of range: 1
{code}

*Workaround*
Daniel Dai pointed out that the parameters are passed in trunk.  I tested and confirmed.

{code}
$ /path/to/pig-trunk/bin/pig pytest.py one_script
2012-06-20 08:29:02,041 [main] INFO  org.apache.pig.Main - Apache Pig version 0.11.0-SNAPSHOT (r1351859) compiled Jun 19 2012, 17:30
:54
[ ... snip ... ]
2012-06-20 08:29:10,414 [main] INFO  org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting UDF: main
one_script
{code}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira