By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,106 Members | 2,335 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,106 IT Pros & Developers. It's quick & easy.

Komodo IDE: '__file__' is not defined when debugging

P: n/a
This is a question to all of you who use Komodo IDE for development:
when I tried to debug my script which uses __file__ to get the absolute
path to the file, Komodo complained that the variable is not defined.

Anyway to work around this? (without changing the code)

Or if I need to change the code, how do I achieve the same thing I
wanted? Thanks in advance!

Jan 3 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
[fortepianissimo wrote]
This is a question to all of you who use Komodo IDE for development:
when I tried to debug my script which uses __file__ to get the absolute
path to the file, Komodo complained that the variable is not defined.

Anyway to work around this? (without changing the code)

Or if I need to change the code, how do I achieve the same thing I
wanted? Thanks in advance!


The problem is that when you run your script under the debugger (same
thing with pdb.py) __file__ isn't set automatically because running a
Python script with Python's execfile() (which is what Komodo debugger
does) works slightly differently that what Python's main() does to run a
Python script. One of the differences is the setting of __file__.

(Side note: I'm not sure if this should be a Python bug or not. The
intention of under what conditions __file__ should be set are not clear
from the Python docs. From a quick poke I think it may be possible that
__file__ not getting set via execfile() is a bug that was introduced
with pythonrun.c changes when nested scopes were added a while back).

We've started a bug for this on Komodo:
http://bugs.activestate.com/Komodo/s...g.cgi?id=43703

....and Shane just fixed it. I.e. Subsequent releases of Komodo will have
this fixed: __file__ will be set in the main module.

Until that release, workarounds:
1. get the main script path from sys.argv[0]; or
2. apply the patch (to .../dbgp/client.py in your Komodo install) that
Shane attached to that bug to your Komodo installation.

Thanks for mentioning the bug.

Cheers,
Trent

--
Trent Mick
tr****@activestate.com
Jan 3 '06 #2

P: n/a
Thank you very much for the prompt reply and the patch - I applied it
and everything is well now.

Looking forward to the update!

Jan 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.