Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings in IDLE raise TypeError (such as attempting to import deprecated modules) #48293

Closed
craigh mannequin opened this issue Oct 4, 2008 · 6 comments
Closed

Warnings in IDLE raise TypeError (such as attempting to import deprecated modules) #48293

craigh mannequin opened this issue Oct 4, 2008 · 6 comments
Labels
topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@craigh
Copy link
Mannequin

craigh mannequin commented Oct 4, 2008

BPO 4043
Nosy @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-10-15.21:06:11.145>
created_at = <Date 2008-10-04.22:30:08.827>
labels = ['expert-IDLE', 'type-bug']
title = 'Warnings in IDLE raise TypeError (such as attempting to import deprecated modules)'
updated_at = <Date 2008-10-15.21:06:11.122>
user = 'https://bugs.python.org/craigh'

bugs.python.org fields:

activity = <Date 2008-10-15.21:06:11.122>
actor = 'benjamin.peterson'
assignee = 'none'
closed = True
closed_date = <Date 2008-10-15.21:06:11.145>
closer = 'benjamin.peterson'
components = ['IDLE']
creation = <Date 2008-10-04.22:30:08.827>
creator = 'craigh'
dependencies = []
files = []
hgrepos = []
issue_num = 4043
keywords = []
message_count = 6.0
messages = ['74324', '74325', '74333', '74334', '74806', '74818']
nosy_count = 3.0
nosy_names = ['russblau', 'benjamin.peterson', 'craigh']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue4043'
versions = ['Python 2.6']

@craigh
Copy link
Mannequin Author

craigh mannequin commented Oct 4, 2008

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.

@craigh craigh mannequin added topic-IDLE type-bug An unexpected behavior, bug, or error labels Oct 4, 2008
@craigh
Copy link
Mannequin Author

craigh mannequin commented Oct 4, 2008

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)

@craigh craigh mannequin changed the title Attempting to import deprecated modules in IDLE raises TypeError Warnings in IDLE raise TypeError (such as attempting to import deprecated modules) Oct 4, 2008
@craigh
Copy link
Mannequin Author

craigh mannequin commented Oct 5, 2008

I should have checked this more carefully, but apparently you can still
use the imported module after the exception.

@craigh
Copy link
Mannequin Author

craigh mannequin commented Oct 5, 2008

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.

@russblau
Copy link
Mannequin

russblau mannequin commented Oct 15, 2008

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

@benjaminp
Copy link
Contributor

Fixed in r66905.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-IDLE type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant