msg219739 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2014-06-04 01:30 |
While editing code that uses ElementTree, the call tips code is working in the background and emits warnings to the console: Warning (from warnings module): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/idlelib/CallTips.py", line 170 if ob.im_self: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. This appears to be an unfortunate interaction between the call tips code and the objects being call-tipped. The behavior appears to be new (I had not encountered it prior to 2.7.7). If possible the call-tip code should test for len(ob.im_self) or somesuch. |
|
|
msg219743 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2014-06-04 06:47 |
According to my local copy of the repository, rev88617 2014 Jan 21 removed what I believe was the only line with 'if ob.im_self'. The change may have been in 2.7.5, certainly 2.7.6. I cannot find it in the current code. Please recheck your version; this may have been fixed already. |
|
|
msg219744 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2014-06-04 06:49 |
I guess rev #s are different on different systems. Try d55d1cbf5f9a or revd55d1cbf5f9a |
|
|
msg219745 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2014-06-04 06:51 |
Line 1.20 in the correct link. |
|
|
msg219746 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2014-06-04 06:55 |
I've checked both the recently released 2.7.7 and the current 27 head on the hg repo. They both have the error. A suggested patch is attached. |
|
|
msg219749 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2014-06-04 07:10 |
New changeset 09b33fc96a50 by Terry Jan Reedy in branch '2.7': Issue #21654: Fix interaction with warnings. Patch by Raymond Hettinger. http://hg.python.org/cpython/rev/09b33fc96a50 |
|
|
msg219750 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2014-06-04 07:18 |
This is 2.7 only. Warnings may have been expanded a bit in 2.7.7. I know there are plans to widen net further in 2.7.8. We can leave this open until you are convinced it works or discover otherwise. |
|
|
msg219838 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2014-06-05 19:22 |
Do either of you know what that warning is about? I'm getting it in some code that I'm running successfully in both python2.7 and python3.4, and python3.4 doesn't give me a warning. |
|
|
msg219843 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2014-06-05 20:20 |
I verified that <type 'instancemethod'> is used in 2.7 for both unbound and bound methods of both old- and new-style classes. In 3.0, old-style classes and unbound methods were removed. 2.x types seem not to have __bool__, so I suspect that the condition code special cases numbers and then checks for len() or == None. I am guessing that instancemethod is specially flagged. But grepping 'furture versions' in 2.7/*.c and *.h got not hits, so I cannot confirm anything. I have no idea where the if/elif/while check are coded. The important question to me is whether the fix works for you also. |
|
|