Terry J. Reedy added the comment:

Attached is the 3.4 code I plan to commit after a trivial 2.7 backport. 

In the existing htest, 'global previous_tcl_fcn' is unnecessary because of 
Python's late binding of function locals. No forward definitions are needed. 
Already deleted in the first patch.

Adding this test:
    def test_unregister_no_attribute(self):
        del self.text.insert
        self.assertEqual(self.redir.unregister('insert'), self.func)
revealed that this code in .unregister
            if hasattr(self.widget, operation):
                delattr(self.widget, operation)
is buggy because hasattr looks up the class tree for an attribute whereas 
delattr does not. Hence the former can be true, and will be after text.insert 
in deleted to unmask Text.insert, while delattr raises AttributeError. The if 
check is useless, and replaced by 'try...' in the new patch.

I modified a few tests and added a few more. Coverage is now 100%.

----------
assignee:  -> terry.reedy
stage:  -> commit review
type:  -> enhancement
Added file: http://bugs.python.org/file35919/test-redir-21940-34.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21940>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to