Skip to content

Commit

Permalink
grass.script.db: Close opened file in db_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed Nov 17, 2024
1 parent 3742561 commit b7b2d2e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions python/grass/script/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ def db_connection(force=False, env=None):
:return: parsed output of db.connect
""" # noqa: E501
try:
nuldev = open(os.devnull, "w")
conn = parse_command("db.connect", flags="g", stderr=nuldev, env=env)
nuldev.close()
with open(os.devnull, "w") as nuldev:
conn = parse_command("db.connect", flags="g", stderr=nuldev, env=env)
except CalledModuleError:
conn = None

Expand Down

0 comments on commit b7b2d2e

Please sign in to comment.