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: Warnings in IDLE raise TypeError (such as attempting to import deprecated modules)
Type: behavior Stage:
Components: IDLE Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, craigh, russblau
Priority: normal Keywords:

Created on 2008-10-04 22:30 by craigh, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg74324 - (view) Author: Craig Holmquist (craigh) Date: 2008-10-04 22:30
In Python 2.6, attempting to import depecated modules in IDLE raises a
TypeError exception.  I verified this with sets, mimify, and MimeWriter.
 Here's the output for sets:

>>> import sets

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import sets
  File "C:\Python26\Lib\sets.py", line 85, in <module>
    stacklevel=2)
  File "C:\Python26\Lib\warnings.py", line 29, in _show_warning
    file.write(formatwarning(message, category, filename, lineno, line))
TypeError: idle_formatwarning_subproc() takes exactly 4 arguments (5 given)

The other modules give a similar trace.

Normally, I wouldn't consider this a serious issue, but there are some
major packages out there that still use deprecated modules such as
these.  For example, MySQLdb 1.2.2 and SQLAlchemy 4.7p1 import the sets
module so they can't be used at all in IDLE.
msg74325 - (view) Author: Craig Holmquist (craigh) Date: 2008-10-04 22:45
Actually, it looks like ANY warning will raise this error in IDLE.  For
example:

>>> import warnings
>>> warnings.warn('blah blah')

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    warnings.warn('blah blah')
  File "C:\Python26\Lib\warnings.py", line 29, in _show_warning
    file.write(formatwarning(message, category, filename, lineno, line))
TypeError: idle_formatwarning_subproc() takes exactly 4 arguments (5 given)
msg74333 - (view) Author: Craig Holmquist (craigh) Date: 2008-10-05 01:38
I should have checked this more carefully, but apparently you can still
use the imported module after the exception.
msg74334 - (view) Author: Craig Holmquist (craigh) Date: 2008-10-05 02:38
Okay, I think I've got it now:

1. If you import sets, it raises TypeError.  However, if you import it a
second time, it seems to work properly.

2. Trying to import a module that relies on the deprecated module (ie,
sqlalchemy) fails no matter how many times it's imported.
msg74806 - (view) Author: Russell Blau (russblau) Date: 2008-10-15 16:54
This error is caused by line 27 in run.py:

    def idle_formatwarning_subproc(message, category, filename, lineno):

needs to be changed to --

    def idle_formatwarning_subproc(message, category, filename, lineno, 
line=None):

so that the function signature matches that of warnings.formatwarning
msg74818 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-10-15 21:06
Fixed in r66905.
History
Date User Action Args
2022-04-11 14:56:40adminsetgithub: 48293
2008-10-15 21:06:11benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg74818
nosy: + benjamin.peterson
2008-10-15 16:54:22russblausetnosy: + russblau
messages: + msg74806
2008-10-05 02:38:29craighsetmessages: + msg74334
2008-10-05 01:38:31craighsetmessages: + msg74333
2008-10-04 22:45:13craighsetmessages: + msg74325
title: Attempting to import deprecated modules in IDLE raises TypeError -> Warnings in IDLE raise TypeError (such as attempting to import deprecated modules)
2008-10-04 22:30:08craighcreate