Simplify things with a context manager.

Declined
#1 · Created  · Last updated

Declined pull request

Closed by: ·2014-02-25

Description

Previously, this code would raise the following exception if file it was trying to read did not exist. The datafile variable would never be set.

File ".virtualenvs/taskotron/bin/runtask", line 9, in <module> load_entry_point('libtaskotron==0.0.3', 'console_scripts', 'runtask')() File "devel/libtaskotron/libtaskotron/runner.py", line 131, in main task_data = taskyaml.parse_yaml_from_file(arg_data['taskfile']) File "devel/libtaskotron/libtaskotron/taskyaml.py", line 9, in parse_yaml_from_file datafile.close() UnboundLocalError: local variable 'datafile' referenced before assignment

0 attachments

0 comments

Loading commits...