Cleanup: replace StringIO seek() & read() with a call to getvalue()

This commit is contained in:
Campbell Barton 2022-12-18 14:18:01 +11:00
parent 8709a51fa9
commit 5a761a47e1
3 changed files with 4 additions and 10 deletions

View File

@ -59,10 +59,8 @@ def url_prefill_from_blender(*, addon_info=None):
"\n" "\n"
) )
fh.seek(0)
form_number = 2 if addon_info else 1 form_number = 2 if addon_info else 1
return ( return (
"https://developer.blender.org/maniphest/task/edit/form/%i?description=" % form_number + "https://developer.blender.org/maniphest/task/edit/form/%i?description=" % form_number +
urllib.parse.quote(fh.read()) urllib.parse.quote(fh.getvalue())
) )

View File

@ -156,11 +156,8 @@ def execute(context, is_interactive):
if _BPY_MAIN_OWN: if _BPY_MAIN_OWN:
sys.modules["__main__"] = main_mod_back sys.modules["__main__"] = main_mod_back
stdout.seek(0) output = stdout.getvalue()
stderr.seek(0) output_err = stderr.getvalue()
output = stdout.read()
output_err = stderr.read()
# cleanup # cleanup
sys.last_traceback = None sys.last_traceback = None

View File

@ -65,8 +65,7 @@ def expect_output_or_abort(*, fn, match_stderr=None, match_stdout=None):
for (handle, match) in ((stdout, match_stdout), (stderr, match_stderr)): for (handle, match) in ((stdout, match_stdout), (stderr, match_stderr)):
if not match: if not match:
continue continue
handle.seek(0) output = handle.getvalue()
output = handle.read()
if not re.match(match, output): if not re.match(match, output):
print_fail_msg_and_exit("%r not found in %r" % (match, output)) print_fail_msg_and_exit("%r not found in %r" % (match, output))