From: <pj...@us...> - 2008-11-23 06:28:46
|
Revision: 5611 http://jython.svn.sourceforge.net/jython/?rev=5611&view=rev Author: pjenvey Date: 2008-11-23 06:28:45 +0000 (Sun, 23 Nov 2008) Log Message: ----------- fix the Carlo Verre hack because open builtin classes are only cool in Ruby and JavaScript, or something like that fixes #1058 and test_descr.carloverre Modified Paths: -------------- trunk/jython/Lib/test/test_descr.py trunk/jython/src/org/python/core/PyObject.java Modified: trunk/jython/Lib/test/test_descr.py =================================================================== --- trunk/jython/Lib/test/test_descr.py 2008-11-23 04:35:59 UTC (rev 5610) +++ trunk/jython/Lib/test/test_descr.py 2008-11-23 06:28:45 UTC (rev 5611) @@ -4424,9 +4424,6 @@ # Lack __basicsize__: http://bugs.jython.org/issue1017 slotmultipleinheritance, - # Carlo hacked us: http://bugs.jython.org/issue1058 - carloverre, - # Jython lacks CPython method-wrappers (though maybe this # should pass anyway?) methodwrapper, Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2008-11-23 04:35:59 UTC (rev 5610) +++ trunk/jython/src/org/python/core/PyObject.java 2008-11-23 06:28:45 UTC (rev 5611) @@ -3591,6 +3591,7 @@ @ExposedMethod final void object___setattr__(PyObject name, PyObject value) { + hackCheck("__setattr__"); object___setattr__(asName(name), value); } @@ -3626,6 +3627,7 @@ @ExposedMethod final void object___delattr__(PyObject name) { + hackCheck("__delattr__"); object___delattr__(asName(name)); } @@ -3675,6 +3677,19 @@ } /** + * Helper to check for object.__setattr__ or __delattr__ applied to a type (The Carlo + * Verre hack). + * + * @param what String method name to check for + */ + private void hackCheck(String what) { + if (this instanceof PyType && ((PyType)this).builtin) { + throw Py.TypeError(String.format("can't apply this %s to %s object", what, + objtype.fastGetName())); + } + } + + /** * Used for pickling. Default implementation calls object___reduce__. * * @return a tuple of (class, tuple) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |