Title: Error in Jython 2.5.2 with os.stat and varargs
Type: behaviour Severity: urgent
Components: Core, Library Versions: 2.5.2rc
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alex.gronholm, offby1, pjenvey
Priority: Keywords: patch

Created on 2011-04-02.21:37:54 by offby1, last changed 2011-04-03.00:59:17 by pjenvey.

File name Uploaded Description Edit Remove
osstat-fix.diff alex.gronholm, 2011-04-02.22:44:28
osstat-fix2.diff alex.gronholm, 2011-04-03.00:27:52
msg6460 (view) Author: Chris R (offby1) Date: 2011-04-02.21:37:54
The following code fails to run in Jython:

$ jython 
Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_24
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
import os
>>> args = ('/Users/offline/projects/PyHamcrest/pytest.ini',)
args = ('/Users/offline/projects/PyHamcrest/pytest.ini',)
>>> os.stat(*args)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'builtin_function_or_method' object is not callable
>>> os.stat('/Users/offline/projects/PyHamcrest/pytest.ini')
(33188, 24017506L, 234881026L, 1, 501, 20, 47L, 1301777760, 1301777759, 1301777759)
msg6461 (view) Author: Alex Grönholm (alex.gronholm) Date: 2011-04-02.21:43:16
This bug seems to be also preventing RPyC from working properly under Jython.
msg6462 (view) Author: Alex Grönholm (alex.gronholm) Date: 2011-04-02.22:44:28
The attached patch fixes the problem. How do I make sure it doesn't break anything elsewhere?
msg6463 (view) Author: Philip Jenvey (pjenvey) Date: 2011-04-03.00:04:54
This fix wouldn't break anything but it actually makes the stat callpath slower (patch would make it go through reflection). stat is actually perf critical in some cases. We need the fix to be on the PyBuiltinFunctions

Probably adding an override that takes PyObject[], String[] would solve the problem. This is an odd bug though because I'm surprised it's not getting to the currently defined __call__ override automatically. We might have an issue on how we are dealing with PyObject.__call__ overrides

But we can go ahead with a local fix in the StatFunction classes for now
msg6464 (view) Author: Philip Jenvey (pjenvey) Date: 2011-04-03.00:15:08
I think I see the problem, PyBuiltinFunctions are made to always override the __call__(PyObject[] String[]) method. Whereas we want to define this is a "narrower" override: so try making the StatFunctions subclass PyBuiltinFunctionNarrow instead of PyBuiltinFunction

also, I suppose this could use a testcase
msg6465 (view) Author: Alex Grönholm (alex.gronholm) Date: 2011-04-03.00:27:52
Attached is a better fix that does not cause performance degradation.
msg6466 (view) Author: Alex Grönholm (alex.gronholm) Date: 2011-04-03.00:32:37
Also, the problem affecting RPyC, although superficially similar, is something else entirely. It is still likely a Jython bug though.
msg6467 (view) Author: Philip Jenvey (pjenvey) Date: 2011-04-03.00:59:17
applied in r7285 & r7286, thanks!
Date User Action Args
2011-04-03 00:59:17pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg6467
2011-04-03 00:32:37alex.gronholmsetmessages: + msg6466
2011-04-03 00:27:52alex.gronholmsetfiles: + osstat-fix2.diff
messages: + msg6465
2011-04-03 00:15:08pjenveysetmessages: + msg6464
2011-04-03 00:04:54pjenveysetnosy: + pjenvey
messages: + msg6463
2011-04-02 22:44:29alex.gronholmsetfiles: + osstat-fix.diff
keywords: + patch
messages: + msg6462
2011-04-02 21:43:17alex.gronholmsetnosy: + alex.gronholm
messages: + msg6461
2011-04-02 21:37:54offby1create