This repository has been archived by the owner on Sep 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 346
Hard crash with copy.copy()
copying proxy object
#1192
Comments
A workaround for this problem is creating a custom import copy
class Proxy(object):
def __init__(self, obj):
self.obj = obj
def __getattr__(self, attr):
return getattr(self.obj, attr)
def __copy__(self):
return Proxy(copy.copy(self.obj))
class Object(object):
attr = 1
copy.copy(Proxy(Object())) |
pekkaklarck
added a commit
to robotframework/robotframework
that referenced
this issue
Apr 10, 2015
Creating custom __copy__ required small changes to how embedded args objects are created. Also made all attributes needed only by embedded args private to avoid masking attributes by proxied handler objects. This is related to #1818 and the IronPython bug is IronLanguages/main#1192
The underlying issue is that a call to CPython has identical behaviour, but somehow stops recursion without crashing after a nesting level of 331 (in my case). In any case, the current implementation of the Proxy class seems to be suboptimal at least with regard to the copy module. Test code: o = Proxy(Object())
reductor = getattr(o, "__reduce_ex__", None)
print "reductor =", reductor
info = reductor(2)
print "info =", info
callable, args = info[:2]
print "callable, args =", callable, args
y = callable(*args)
print "inst =", y
hasattr(y, '__setstate__') Output:
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The following example crashes IronPython 2.7.5 for good. I first get a dialog telling "IronPython Console has stopped working" and after closing it "Process is terminated due to StackOverflowException." is printed to the command prompt.
The text was updated successfully, but these errors were encountered: