Issue406193

classification
Title: stack overflow when delegating
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bckfnn Nosy List: bckfnn, bzimmer, nobody
Priority: normal Keywords: test failure causes

Created on 2001-03-06.04:16:05 by bzimmer, last changed 2001-03-22.20:52:18 by bckfnn.

Files
File name Uploaded Description Edit Remove
example.jar bzimmer, 2001-03-06.04:16:06 A jar containing the source to reproduce the bug.
Messages
msg287 (view) Author: Brian Zimmer (bzimmer) Date: 2001-03-06.04:16:05
There appears to be a problem with PyReflectedFunction
when a Python class is an implementation of a Java
interface and delegates to a Java implementation of
that interface.

The primary problem is overloaded methods on the
interface, such as the ISimple.get() methods.

Look at classes t and u.  Both do as expected.  t is
not the interface, so it's marginally useful.  u
implements the interface but needs to handle the get()
methods in order for it to work properly.  v is what I
want, but it ends up blowing the stack.  Should this
work?  I think yes, but can't figure out how to patch it.


Run the code to get the full affect:

import Simple, ISimple

class t:
	def __init__(self, s):
		self.s = s

	def __getattr__(self, name):
		return getattr(self.s, name)

class u(ISimple):
	def __init__(self, s):
		self.s = s

	def get(self, i=None):
		if i:
			return self.s.get(i)
		else:
			return self.s.get()

class v(ISimple):
	def __init__(self, s):
		self.s = s

	def __getattr__(self, name):
		return getattr(self.s, name)

def main():
	print "using Simple"

	y = Simple()
	print y
	print y.get()
	print y.get(2)
	print y.get()
	print y.get(0)

	print "using t"

	y = t(Simple())
	print y
	print y.get()
	print y.get(2)
	print y.get()
	print y.get(0)

	print "using u"

	y = u(Simple())
	print y
	print y.get()
	print y.get(2)
	print y.get()
	print y.get(0)

	print "using v"

	y = v(Simple())
	print y
	print y.get()
	print y.get(2)
	print y.get()
	print y.get(0)

if __name__ == '__main__':
	main()
msg288 (view) Author: Nobody/Anonymous (nobody) Date: 2001-03-06.18:38:31
Logged In: NO 

Please look at the attached jar for all the source.
msg289 (view) Author: Finn Bock (bckfnn) Date: 2001-03-22.20:52:18
Logged In: YES 
user_id=4201

Fixed in:

PyClass.java: 2.23;
ProxyMaker.java: 2.12;
JavaMaker.java: 2.10;
ObjectFactory.py: 2.7;
compile.py: 2.17;
proxies.py: 2.10;
History
Date User Action Args
2001-03-06 04:16:05bzimmercreate