Wrong path is passed to internal methods
Bug #316691 reported by
Marco Ferreira
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Gladex |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
Hello!
This occurs when trying to run the generated code from within the directory of the generated files:
setas@work:
Traceback (most recent call last):
File "SyncRun_
compile(
File "/usr/lib/
f = open(file, 'U')
IOError: [Errno 2] No such file or directory: '/SyncRun_
My suggestion is to check for the value of os.path.
Cheers
Changed in gladex: | |
assignee: | nobody → francesco-marella |
status: | New → Fix Committed |
assignee: | francesco-marella → nobody |
To post a comment you must log in.
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 ).