Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > I think I found a bug in Python 2.6.4 (in the inspect module)

Reply
Thread Tools

I think I found a bug in Python 2.6.4 (in the inspect module)

 
 
inhahe
Guest
Posts: n/a
 
      12-29-2009
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> def a(b=1): pass

....
>>> inspect.getargvalues(a)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\inspect.py", line 816, in getargvalues
args, varargs, varkw = getargs(frame.f_code)
AttributeError: 'function' object has no attribute 'f_code'
>>> dir(a)

['__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr_
_', '__dict__', '__doc__', '__format__', '__get__', '__getattribute__', '__globa
ls__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__'
, '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subcla
sshook__', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc'
, 'func_globals', 'func_name']
>>>


So i'm guessing that the attribute has been changed from func_code to
f_code but the inspect module wasn't updated to reflect that.
 
Reply With Quote
 
 
 
 
Lie Ryan
Guest
Posts: n/a
 
      12-31-2009
On 12/30/2009 9:10 AM, inhahe wrote:
> Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import inspect
>>>> def a(b=1): pass

> ....
>>>> inspect.getargvalues(a)

> Traceback (most recent call last):
> File "<stdin>", line 1, in<module>
> File "C:\Python26\lib\inspect.py", line 816, in getargvalues
> args, varargs, varkw = getargs(frame.f_code)
> AttributeError: 'function' object has no attribute 'f_code'
>>>> dir(a)

> ['__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr_
> _', '__dict__', '__doc__', '__format__', '__get__', '__getattribute__', '__globa
> ls__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__'
> , '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subcla
> sshook__', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc'
> , 'func_globals', 'func_name']
>>>>

>
> So i'm guessing that the attribute has been changed from func_code to
> f_code but the inspect module wasn't updated to reflect that.


No, that wasn't the case. The argument of inspect.getargvalues() is a
'frame object' not 'function object'.

e.g.:
>>> inspect.getargvalues(inspect.currentframe())


You could argue that the error message is misleading (should be
TypeError instead), do you want a bug report on that?
 
Reply With Quote
 
 
 
 
Ron Croonenberg
Guest
Posts: n/a
 
      12-31-2009
hello,

is there a way, in python, to create a splash window and when the
program has completed disappears by sending a msg to it? (I tried
creating two gtk windows but gtk_main doesn't seem to return unless it
gets closed.)

tia

Ron
 
Reply With Quote
 
Ron Croonenberg
Guest
Posts: n/a
 
      12-31-2009
sorry about posting with the wrong subject...

*****
hello,

is there a way, in python, to create a splash window and when the
program has completed disappears by sending a msg to it? (I tried
creating two gtk windows but gtk_main doesn't seem to return unless it
gets closed.)

tia

Ron
*****
 
Reply With Quote
 
Mike Driscoll
Guest
Posts: n/a
 
      12-31-2009
On Dec 30, 11:31*pm, Ron Croonenberg <(E-Mail Removed)> wrote:
> sorry about posting with the wrong subject...
>
> *****
> hello,
>
> is there a way, in python, to create a splash window and when the
> program has completed disappears by sending a msg to it? (I tried
> creating two gtk windows but gtk_main doesn't seem to return unless it
> gets closed.)
>
> tia
>
> Ron
> *****


wxPython has a splash page "widget" for this sort of thing. Of course,
if all you want to do is display a message to the user for a short
time, any GUI library will allow you to create a window of some sort
that you can use for that purpose. Note that GUI's tend to run in a
loop that may block your calling program, so you may need to mess with
threads, in which case each GUI has their own thread-safe methods.

It's less complicated then it sounds. I tend to use wxPython the most,
so if you have specific questions about that, let me know. Good luck!

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

PyCon 2010 Atlanta Feb 19-21 http://us.pycon.org/
 
Reply With Quote
 
Peter Decker
Guest
Posts: n/a
 
      01-02-2010
On Thu, Dec 31, 2009 at 12:31 AM, Ron Croonenberg <(E-Mail Removed)> wrote:

> is there a way, in python, to create a splash window and when the program
> has completed disappears by sending a msg to it? (I tried creating two gtk
> windows but gtk_main doesn't seem to return unless it gets closed.)


It's really simple to do this in Dabo (which uses wxPython under the
hood, but is _so_ much more elegant!). When you create your app, add
the following two parameters:

app = dabo.dApp(showSplashScreen=True, splashImage="/path/to/splash.png")

That's it!

--

# p.d.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Think I May Have Found a Bug with wc -l KevinSimonson Java 18 03-21-2011 11:49 AM
inspect.stack() or inspect.currentframe() gives "list index out ofrange error" deluxstar Python 5 09-25-2010 05:12 PM
Total newbie, but I think I found a bug in Socket? Patrick Toomey Ruby 0 09-06-2006 03:00 AM
Bug in inspect.py for python 2.3? Fernando Perez Python 2 12-18-2004 12:32 AM
found a bug i think, can anyone confirm Ian ASP .Net 0 05-04-2004 03:39 PM



Advertisments