#3063: Invalid environment verifier code when wrong environment path is used
---------------------+------------------------------------------------------
Reporter: eblot | Owner: jonas
Type: defect | Status: new
Priority: lowest | Milestone:
Component: general | Version: devel
Severity: trivial | Keywords:
---------------------+------------------------------------------------------
The following piece of code [source:/trunk/trac/env.py?rev=3213#L166
env.py] is in trouble
{{{
#!python
def verify(self):
try:
fd = open(os.path.join(self.path, 'VERSION'), 'r')
assert fd.read(26) == 'Trac Environment Version 1'
finally:
fd.close()
}}}
if the path (environment path set by the user) is incorrect, `open` method
fail, `fd` never gets initialized, and `fd.close()` fails with the
following exception:
{{{
Failed to open environment. local variable 'fd' referenced before
assignment
Traceback (most recent call last):
File
"/Users/eblot/Sources/Svn/edgewall.com/trunk/trac/scripts/admin.py", line
132, in env_open
self.__env = Environment(self.envname)
File "/Users/eblot/Sources/Svn/edgewall.com/trunk/trac/env.py", line
121, in __init__
self.verify()
File "/Users/eblot/Sources/Svn/edgewall.com/trunk/trac/env.py", line
173, in verify
fd.close()
UnboundLocalError: local variable 'fd' referenced before assignment
}}}
--
Ticket URL: <http://projects.edgewall.com/trac/ticket/3063>
The Trac Project <http://trac.edgewall.com/>
_______________________________________________
Trac-Tickets mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-tickets