473,396 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

f_locals is NULL inside a method

Hi all,

I am developing a new python debugger which is coming on quite nicely
except that f_locals always becomes NULL when entering new functions.
Can anyone help with this? Someone else has posted earlier with a
similar problem but there are no replies. I can't understand why
f_locals would be NULL - it works fine at the module level but as soon
as I "step into" a function, the contents of frame->f_locals when
converted to a string is null. The conversion is as follows:

int tracer(PyObject*, PyFrameObject* frame, int what, PyObject* arg)
{
PyObject* locals = PyObject_Str(frame->f_locals);
std::cout << "LOCALS: " << PyString_AsString(locals) << std::endl;
Py_DECREF(locals);
}

Is there anything wrong with this or can I assume f_locals is actually
NULL?

Note: I have ran the same test module in PDB and it's f_locals is fine!

Nov 29 '05 #1
2 1584

"Paul Drummond" <pa***********@dsl.pipex.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hi all,

I am developing a new python debugger which is coming on quite nicely
except that f_locals always becomes NULL when entering new functions.
You don't provide any declaration for the class which contains this f_locals
variable, or a declaration for what that variable is. Perhaps you're just
encountering some problems with copy constructors?
Can anyone help with this? Someone else has posted earlier with a
similar problem but there are no replies. I can't understand why
f_locals would be NULL - it works fine at the module level but as soon
as I "step into" a function, the contents of frame->f_locals when
converted to a string is null. The conversion is as follows:

int tracer(PyObject*, PyFrameObject* frame, int what, PyObject* arg)
{
PyObject* locals = PyObject_Str(frame->f_locals);
std::cout << "LOCALS: " << PyString_AsString(locals) << std::endl;
Py_DECREF(locals);
}

Is frame->f_locals NULL immediately upon entering this function, or after
executing PyObject_Str (whatever that is)? Or does it just APPEAR to be
NULL when output via that PyString_AsString function?

We have no was of knowing what any of that code is doing, or how the data
was created or passed to this function, so it would be pretty hard to guess.

Note: I have ran the same test module in PDB and it's f_locals is fine!


I take it that's some kind of debugger? When you see the problem you're
describing above, how exactly are you determining that frame->f_locals is
NULL? Are you using another debugger? Perhaps it's a problem with that
debugger? No way for us to know, unfortunately.

-Howard

Nov 29 '05 #2
Hi Howard,

The tracer function is a callback provided by the python interpreter by
PyEval_SetTrace() and all parameters are provided by Python, hence the
problem - python is providing frame->f_locals as a null when it should
be a dictionary to all the current locals.

I have solved the problem anyway for anyone who is interested, a call
PyFrame_FastToLocals(frame) will update f_locals to be correct. As far
as I can tell you also need to call PyFrame_LocalsToFast(frame, 0) when
you are finished with f_locals.

Nov 30 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Vijay Kumar | last post by:
hi, I have written a trace function in C using the Python/C API. I want to find whether the call occured is a function call or method call and if a method call, its self object. int...
9
by: Cheney Stallman | last post by:
I have a class as following: class X { public: static X* Create() { return new X(); }
1
by: Pradeep | last post by:
Hi, I am working with Intrusive pointers in a DLL and I need to set the value of the intrusive pointer to an object to NULL from inside the method of that class. So here's the scenario. I...
2
by: Christoph Nahr | last post by:
Question: Will C# 2.0 offer a way to directly and reliably produce the fastest MSIL null check, i.e. a single opcode? The current C# compiler will emit this opcode automatically when comparing a...
8
by: Pesso | last post by:
I'm having a difficulty compairing null to a class object whose "equal" operator is overridden.. Consider the following: class Foo { // ... public static bool operator==(Foo f1, Foo f2) {...
8
by: nsharma78 | last post by:
Hi, I have a code as follows: class A { public: void print(){cout << "Magic" << endl;} };
7
by: John Layton | last post by:
Hi there, Is it possible to pass null to a function taking an "out" (or "ref") parameter in C#. I'd like to do something like the following (which doesn't compile of course). Thanks in advance....
2
by: artev | last post by:
if I insert a string null in a select, it change position; why? I insert value "" in 2nd 3th select; <style type="text/css"> td {border:2px solid pink;}; </style>
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.