Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle IndexError from embedded interpreter #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ender8282
Copy link

In my environment we are using a Jython Interpreter embedded in a larger application. After upgrading from a much older version to 2.7.2 we started getting an IndexError that hosed things. The comment below the modified line notes that sys.argv isn't handled properly in embedded interpreters I suspect that there was a change alsewhere that changed sys.argv from being undefined to being an empty list but that is just speculation. Regardless this change gets things working in our embedded environment.

In my environment we are using a Jython Interpreter embedded in a larger application.  After upgrading from a much older version to 2.7.2 we started getting an IndexError that hosed things.  The comment below the modified line notes that sys.argv isn't handled properly in embedded interpreters I suspect that there was a change alsewhere that changed sys.argv from being undefined to being an empty list but that is just speculation.  Regardless this change gets things working in our embedded environment.
@jeff5
Copy link
Member

jeff5 commented Jul 27, 2020

https://bugs.python.org/issue32573 and PEP-587 refer to this problem and favours setting sys.argv = [''] in an embedded context. Of course, that's Python 3.8+.

For 2.7 we have https://docs.python.org/2/c-api/init.html#c.Py_SetProgramName as a clue to what maybe ought to happen. However, this PR is closest to preserving existing behaviour which seems the best for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants