I was editing some Perspective views and scripts and one of the code paths started throwing this exception:
Traceback (most recent call last):
File "<function:onMessageReceived>", line 16, in onMessageReceived
File "<module:shared.alarm_groups>", line 243, in get_multiple_alarm_group_tables
ImportError: Error loading module subgroups: Traceback (most recent call last):
File "<module:shared.subgroups>", line 88, in <module> NameError: name '_[88_29]' is not defined
I'm assuming that _[88_29] is some sort of dynamic variable reference, presumably from line 88 column 29? Well, this is line 88:
RESTRICTED_GROUP_IDS = set([ shared.userdb.get_group_id_from_shortname(x) for x in RESTRICTED_GROUP_NAMES ])
Column 29 is that space between the [ and shared.
What the heck is going on here? Is this just Jython badly expressing some sort of syntax error? I wasn't changing anything in this particular file, so that feels unlikely to me, but I can't figure out what else could be happening.
The exception isn't complaining about a value, it's complaining about a variable name. Somewhere, a variable has a name of _88_29
Example:
print(b)
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevconsole.py", line 364, in runcode
coro = func()
^^^^^^
File "<input>", line 1, in <module>
NameError: name 'b' is not defined
I can promise you with total certainty that there is no variable named _88_29 anywhere in any of our projects. I am assuming it is an un-named short-term variable that the Jython interpreter auto-generated a name for based on the line/column location. But even that doesn't explain what is failing ....
I did start looking down at get_group_id_from_shortname but it looks clean and I also haven't changed that file in a few days and it's been working fine from everywhere else. A stronger clue is that just today I was changing the shared.alarm_groups script file which happens to be the thing just above this in the stack trace. I haven't found any syntax errors in there yet, but I'm more suspicious of that file...
This a rare jython bug that has been around forever. Too elusive for me to figure out, but definitely a jython bug. Make a tiny, inconsequential edit to the affected file and save the project.