Issue1793995

classification
Title: PATCH: [ 1784950 ] fpdef grammar bug
Type: Severity: minor
Components: Core Versions: 2.2.2
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, pjenvey, thomasglee
Priority: low Keywords: patch

Created on 2007-09-13.15:38:19 by thomasglee, last changed 2009-06-21.22:03:42 by pjenvey.

Files
File name Uploaded Description Edit Remove
1784950-r1.patch thomasglee, 2007-09-13.15:38:19 Revision 1 of the patch for 1784950
test.py thomasglee, 2007-09-13.15:39:27 Test script used in the bug description. NOT an official unit test.
Messages
msg2882 (view) Author: Tom Lee (thomasglee) Date: 2007-09-13.15:38:19
Attached is a patch fixing 1784950. Effectively, for the following code:

def foo((x)):
  pass

Jython was treating (x) as though it were a tuple due to a small bug in the grammar (as you're probably aware, a single-element tuple in python must end with a comma e.g. (x,). This patch modifies the grammar slightly to handle this weird syntax.

I have a feeling that Jython is still treating tuples somewhat weirdly based on the following output vs. Python 2.4:

---

tom@local:~/src/personal/jython-trunk/jython$ java -jar dist/jython.jar test.py 
foo(5) - without fplist
{'x': 5}

foofp(5) - with fplist
{'x': 5}

lambda_foo(5) - without fplist
{'x': 5}

lambda_foofp(5) - with fplist
{'x': 5}

multi((5, 6)) - with fplist
{'(x, y)': (5, 6), 'x': 5, 'y': 6}

tom@local:~/src/personal/jython-trunk/jython$ python test.py
foo(5) - without fplist
{'x': 5}

foofp(5) - with fplist
{'x': 5}

lambda_foo(5) - without fplist
{'x': 5}

lambda_foofp(5) - with fplist
{'x': 5}

multi((5, 6)) - with fplist
{'y': 6, 'x': 5, '.0': (5, 6)}

---

Note that it behaves just like ordinary python, with the exception of multi() - which creates a local named '.0' in Py2.4 and '(x, y)' in Jy2.3a0. Weird.

Please note this is my first patch and the first time I've touched JavaCC - my changes to fpdef and fplist make the grammar a little less elegant, but hopefully somebody who knows Jython a little better than I can help make this patch worthwhile.
msg2883 (view) Author: Tom Lee (thomasglee) Date: 2007-09-13.15:39:27
File Added: test.py
msg3921 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2008-12-15.15:40:02
I marked this for 2.2.2 which still uses javacc -- fplist works pretty
well in 2.5 (though the '.0' behavior remains, we may want to log a
separate issue on that.
msg4839 (view) Author: Philip Jenvey (pjenvey) Date: 2009-06-21.22:03:42
#1784950 was fixed a while ago, it's in 2.5
History
Date User Action Args
2009-06-21 22:03:42pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg4839
nosy: + pjenvey
2009-03-30 16:28:16fwierzbickisetassignee: fwierzbicki ->
2009-03-14 02:54:03fwierzbickisetassignee: fwierzbicki
2008-12-15 15:40:03fwierzbickisetseverity: normal -> minor
versions: + 2.2.2
nosy: + fwierzbicki
messages: + msg3921
priority: normal -> low
components: + Core, - None
2007-09-13 15:38:19thomasgleecreate