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

Discussion in 'Python' started by inhahe, Dec 29, 2009.

  1. inhahe

    inhahe Guest

    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.
    inhahe, Dec 29, 2009
    #1
    1. Advertising

  2. inhahe

    Lie Ryan Guest

    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?
    Lie Ryan, Dec 31, 2009
    #2
    1. Advertising

  3. 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
    Ron Croonenberg, Dec 31, 2009
    #3
  4. whoops: create a splash window in python

    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
    *****
    Ron Croonenberg, Dec 31, 2009
    #4
  5. Re: whoops: create a splash window in python

    On Dec 30, 11:31 pm, Ron Croonenberg <> 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/
    Mike Driscoll, Dec 31, 2009
    #5
  6. inhahe

    Peter Decker Guest

    Re: whoops: create a splash window in python

    On Thu, Dec 31, 2009 at 12:31 AM, Ron Croonenberg <> 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.
    Peter Decker, Jan 2, 2010
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ian
    Replies:
    0
    Views:
    280
  2. Tomas Zulberti

    Module inspect Bug

    Tomas Zulberti, Oct 5, 2009, in forum: Python
    Replies:
    2
    Views:
    339
    Tomas Zulberti
    Oct 6, 2009
  3. deluxstar
    Replies:
    5
    Views:
    853
    Terry Reedy
    Sep 25, 2010
  4. KevinSimonson

    Think I May Have Found a Bug with wc -l

    KevinSimonson, Mar 19, 2011, in forum: Java
    Replies:
    18
    Views:
    500
  5. Patrick Toomey
    Replies:
    0
    Views:
    78
    Patrick Toomey
    Sep 6, 2006
Loading...

Share This Page