Wrong path is passed to internal methods

Bug #316691 reported by Marco Ferreira on 2009-01-13
Affects Status Importance Assigned to Milestone

Bug Description


This occurs when trying to run the generated code from within the directory of the generated files:

setas@work:~/dev.testing/Sync&Run$ python SyncRun_RemoteBT.py
Traceback (most recent call last):
  File "SyncRun_RemoteBT.py", line 11, in <module>
  File "/usr/lib/python2.5/py_compile.py", line 115, in compile
    f = open(file, 'U')
IOError: [Errno 2] No such file or directory: '/SyncRun_RemoteBT_callbacks.py'

My suggestion is to check for the value of os.path.split(__file__)[0] (in case is "").


Changed in gladex:
assignee: nobody → francesco-marella
status: New → Fix Committed
assignee: francesco-marella → nobody
sjgcit (sg-euroapps) wrote :

I do not think the proposed fix does not address the problem.

The underlying issue is that __file__ when split has an empty path. This can occur if the application is run from the command line locally.

I think the correct fix is to replace ALL occurrences of os.path.split(__file__) with os.path.split( os.path.abspath( __file__ ) )

This method always returns a valid path and leafname and avoid replicating checking code every time the path is needed.

I'd suggest setting a global ( to hold that path result ) during initialisation. This would avoid making multiple calls to two functions that are going to return what will be a constant during runtime.

Please note this issue ALSO occurs in generated code. Generated code should also use this approach ( because we don't know that the resulting code is not going to be executed locally from a command line ).

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers