Issue2816

classification
Title: Python Interpreter which uses Python and Redis script gives an error
Type: behaviour Severity: normal
Components: Jythonc compiler Versions: Jython 2.5
Milestone:
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: Divakar, rkanumola
Priority: normal Keywords:

Created on 2019-10-24.08:05:11 by rkanumola, last changed 2021-05-03.15:48:09 by Divakar.

Messages
msg12714 (view) Author: RK (rkanumola) Date: 2019-10-24.08:05:11
Hi Team,

We are trying to use Jython with Redis script within confluence using a Jython macro.
We are able to execute the action using Jython from the command line and able to read the variable from redis database and get the result, but when we try to use the PythonInterpreter class from within Java application we get the below error. It would be great can suggest ,how to handle this error.

Traceback (most recent call last):
line 4, in
File “/opt/jython/Lib/site-packages/redis/ init .py”, line 1, in
from redis.client import Redis, StrictRedis
SyntaxError: (“no viable alternative at input ‘’’‘“, (‘/opt/jython/Lib/site-packages/redis/client.py’, 28, 13, ‘’))

Please let us know if any thing is not clear or need more information to give a solution to this problem.
msg12716 (view) Author: Adam Burke (adamburke) Date: 2019-10-26.09:05:09
Hi this is unlikely to be a Jython bug (you'd certainly need rather more evidence) - so the Jython bug tracker isn't the best place. jython-users@ or stackoverflow would be better.

However, just to help you along, check the Jython versions being used in the different contexts - Java, confluence macro, and Jython from the command line. The specific error is a parsing error from the antlr library saying a particular syntax isn't supported. There is an example on SO of it happening when running a dictionary comprehension (supported on 2.7.x) under 2.5, where it wasn't supported:

https://stackoverflow.com/questions/25200629/error-no-viable-alternative-at-input-for-python
msg12724 (view) Author: RK (rkanumola) Date: 2019-10-29.12:06:56
Hi Adam,

Thanks for the response. We tried using 2.7 but that did not help. As we are using PythonInterpreter is this something related to Python software configuration ?

Thanks
RK
msg12726 (view) Author: Adam Burke (adamburke) Date: 2019-10-29.12:49:40
Hi RK, it's hard to say with the detail provided here. If exactly the same scripts runs ok in one context, with a particular Jython executable, but gives this error in another, it would usually point to inconsistent versions of the interpreter. Because it is complaining a particular piece of syntax isn't available. It is also possible with whitespace problems - but you said the literal same script runs fine from the command line.

You may know this already, but to print the version of the Python interpreter (including for Jython) from within a script:

import sys
print(sys.version)

Example output from my local machine:
2.7.2a1+ (, May 20 2019, 14:18:30)
[OpenJDK 64-Bit Server VM (Oracle Corporation)]
msg12864 (view) Author: Jeff Allen (jeff.allen) Date: 2019-12-21.17:09:45
Hi RK. Line 28 of redis/client.py recently looks like this:

SYM_EMPTY = b''

This is a syntax error in Python 2.5. The b-prefix comes in with Python 2.6, and it definitely works in Jython 2.7.1. See https://docs.python.org/release/2.6/whatsnew/2.6.html#pep-3112-byte-literals

If you "tried using 2.7 but that did not help", it must at least have failed in a different way.
msg13154 (view) Author: Divakar (Divakar) Date: 2021-05-03.15:48:09
Hi RK,
is the issue resolved? I'm also facing the same issue, but no luck
History
Date User Action Args
2021-05-03 15:48:09Divakarsetnosy: + Divakar, - jeff.allen, adamburke
messages: + msg13154
2020-02-01 09:18:32jeff.allensetpriority: normal
status: pending -> closed
2019-12-21 17:09:45jeff.allensetstatus: open -> pending
resolution: invalid
messages: + msg12864
nosy: + jeff.allen
2019-10-29 12:49:41adamburkesetmessages: + msg12726
2019-10-29 12:06:56rkanumolasetmessages: + msg12724
2019-10-26 09:05:09adamburkesetnosy: + adamburke
messages: + msg12716
2019-10-24 08:05:11rkanumolacreate