On 4/24/2011 5:21 PM, Ken Seehart wrote:
Good point, Benjamin. I didn't think of testing on Jython before
answering. For practical purposes it's a really good idea to test
obscure features against all potential target platforms.

In this case, I would argue that**Benjamin's test demonstrates a bug in
Jython.

Benjamin's 'test' only tested that he could add a new attribute to a function object, as he did not use the proper 2.x name, func_defaults.

One could counter by pointing out that the documentation does not
specify that the __defaults__ attribute is writable.

The 3.x docs, as another pointed out, does so specify. The same was true in 2.x at least by 2.5

http://docs.python.org/release/2.5.4/ref/types.html
"func_defaults A tuple containing default argument values for those arguments that have defaults, or None if no arguments have a default value Writable"

So if the following does not work in Jython 2.5

def f(a=42) :
   return a
f()
# 42
f.func_defaults = (23,)
f()
# 23

then it *does* have a bug with respect to matching the Python 2.5 spec.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to