← Back to team overview

openshot.developers team mailing list archive

Working around Python bug with __file__

 

A fix for the problem I discovered using Python debugger Pdb.

In some circumstances Python will not define __file__ to be an absolute
path of the script currently executing, including when the debugger is
responsible for starting the application.

E.g. it should be "/usr/share/openshot/openshot.py" but reports
"openshot/openshot.py"

If it is a relative path it will cause operations such as:

os.path.dirname(__file__)

to return an empty string or an incorrect result.

The solution is to wrap __file__ to get the absolute path first:

os.path.dirname(os.path.abspath(__file_))





Follow ups