◐ Shell
clean mode source ↗

Message 131415 - Python tracker

Éric Araujo <report@bugs.python.org> writes:

> -            reductor = getattr(x, "__reduce__", None)
> -            if reductor:
> -                rv = reductor()
> -            else:
> -                raise Error("un(shallow)copyable object of type %s" % cls)
> +            raise Error("un(shallow)copyable object of type %s" % cls)
>
> Why change this?

Because it is impossible for this code to be called in Python 3 -
"object" now itself supplies __reduce_ex__, so the fall-through to look
for plain "__reduce__" does not occur here.  This default __reduce_ex__
then calls any user-defined __reduce__, if present.

>>         self.assertTrue(issubclass(copy.Error, Exception))
> You could change that to assertIsInstance.

I will do so on Monday to make a final form of the patch, along with any
other suggestions that come in!

>> -def _test():
> I assume that all cases that were tested in that function are covered
> by unit tests.

Yes!