This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE call tips emitting future warnings about ElementTree objects
Type: behavior Stage: needs patch
Components: IDLE Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, r.david.murray, rhettinger, terry.reedy
Priority: normal Keywords: easy

Created on 2014-06-04 01:31 by rhettinger, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_calltips.py rhettinger, 2014-06-04 06:52 Use none check instead of a truth test
Messages (9)
msg219739 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) Date: 2014-06-04 06:51
Line 1.20 in the correct link.
msg219746 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) 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) (Python triager) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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.
History
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65853
2014-06-05 20:20:49terry.reedysetmessages: + msg219843
2014-06-05 19:22:34r.david.murraysetnosy: + r.david.murray
messages: + msg219838
2014-06-04 08:25:05rhettingersetstatus: open -> closed
resolution: fixed
2014-06-04 07:18:23terry.reedysetmessages: + msg219750
2014-06-04 07:10:18python-devsetnosy: + python-dev
messages: + msg219749
2014-06-04 06:55:41rhettingersetmessages: + msg219746
2014-06-04 06:52:26rhettingersetfiles: + fix_calltips.py
2014-06-04 06:51:12terry.reedysetmessages: + msg219745
2014-06-04 06:49:42terry.reedysetmessages: + msg219744
2014-06-04 06:47:56terry.reedysetmessages: + msg219743
2014-06-04 05:29:15serhiy.storchakasetkeywords: + easy
nosy: + terry.reedy

stage: needs patch
2014-06-04 01:31:00rhettingercreate