Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #33213: close an open file a bit sooner in gap interface.
Browse files Browse the repository at this point in the history
(This is unrelated to the main goal of the ticket.)

After reading the contents of a file using the "with open(...)"
context manager, we now take the opportunity to close that file
immediately by un-indenting the subsequent code to reside outside of
the "with" block.
  • Loading branch information
orlitzky authored and dimpase committed Jun 13, 2022
1 parent ec1a3cf commit 78db2fd
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/sage/interfaces/gap.py
Expand Up @@ -1298,22 +1298,22 @@ def help(self, s, pager=True):
with io.open(self._local_tmpfile(), "r",
encoding=gap_encoding) as fobj:
help = fobj.read()
if pager:
from IPython.core.page import page
page(help, start=sline)
else:
# Find the n-th line and return from there
idx = -1
while sline:
try:
idx = help.find('\n', idx + 1)
sline -= 1
except ValueError:
# We ran out of lines early somehow; this shouldn't
# happen though
break

return help[idx:]
if pager:
from IPython.core.page import page
page(help, start=sline)
else:
# Find the n-th line and return from there
idx = -1
while sline:
try:
idx = help.find('\n', idx + 1)
sline -= 1
except ValueError:
# We ran out of lines early somehow; this shouldn't
# happen though
break

return help[idx:]

def set(self, var, value):
"""
Expand Down

0 comments on commit 78db2fd

Please sign in to comment.