[Python-bugs-list] [Bug #119860] Exception "TypeError: not enough arguments" without details

noreply@sourceforge.net noreply@sourceforge.net
Tue, 31 Oct 2000 03:50:18 -0800


Bug #119860, was updated on 2000-Oct-31 03:50
Here is a current snapshot of the bug.

Project: Python
Category: Core
Status: Open
Resolution: None
Bug Group: 3rd Party
Priority: 5
Summary: Exception "TypeError: not enough arguments" without details

Details: It is possible to create a TypeError without a stack trace thus creating an exception without any hints what is wrong. You will need a third party module (I'll use PyGTK) to reproduce this:

------- test.py ---------------------
from gtk import *

def test (x, y):
    print x, y
    mainquit ()

timeout_add (1.0, test)

mainloop ()
-------- test.py ----------

Run this and you will get this message:

--- output ------------------------
TypeError: not enough parameters; expected 2, got 0
--- output ------------------------

The problem is of course that when Python has to evaluate the code, there is no "calling" instance (and thus Python has no idea what to print). As I see it, there are only two possible solutions:

- Users who want to use this API (to run Python code) must submit a "position" object (which will make python print "test.py:7 timeout_add..." when an exception happens in the C code which tries to call test()). For this, there must be an API to query the current position in a source script (should already be there because the code which prints stack traces must do something very similar).
- The code which prints the exception is in Python/ceval.c in ceval2(). The first object passed it a CodeObject. If we would pass the function object instead, we could at least print the name of the function. But ceval2() is also used in other circumstances, therefore, this might be impossible.

A quick solution and/or workaround would be most welcome !

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=119860&group_id=5470