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.

Author jneb
Recipients jneb, r.david.murray
Date 2014-03-17.08:38:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1395045531.52.0.441825607404.issue20853@psf.upfronthosting.co.za>
In-reply-to
Content
I did figure it out.
It almost works, except when a argument lost its value, and the same name exists in the global context.
To be more specific: I simplified do_args to the following code
(that obviously ugly by explicitly evaluating repr in context, but
that is not the point)
    def do_args(self, arg):
        """a(rgs)
        Print the argument list of the current function.
        Modified by Jurjen
        """
        co = self.curframe.f_code
        n = co.co_argcount
        if co.co_flags & 4: n = n+1
        if co.co_flags & 8: n = n+1
        for i in range(n):
            name = co.co_varnames[i]
            expr = 'repr(%s)' % (name,)
            self.message('%s = %s' % (name, self._getval_except(expr)))

At it works perfectly, except for this little surprise:
>>> bar = "BAR"
>>> def foo(bar):
...    del bar
...    return 5
>>> pdb.runcall(f, 10)
> <stdin>(2)f()
->    del bar
(Pdb) a
bar = 5
(Pdb) n
> <stdin>(3)f()
-> return 5
(Pdb) a
bar = 'BAR'      ##### Huh? Expected undefined

I'll leave it to the experts to patch this in proper Python coding style.
So, the conclusion is we need a way to safely evaluate the call to repr() in context, with self.curframe_locals[co.co_varnames[i]] as argument.

I did not find a good supporting routine for that elsewhere in pdb.
History
Date User Action Args
2014-03-17 08:38:51jnebsetrecipients: + jneb, r.david.murray
2014-03-17 08:38:51jnebsetmessageid: <1395045531.52.0.441825607404.issue20853@psf.upfronthosting.co.za>
2014-03-17 08:38:51jneblinkissue20853 messages
2014-03-17 08:38:51jnebcreate