From f0fd3619cfe6f343b3c0ac9bff0dc1010905443e Mon Sep 17 00:00:00 2001 From: Ryan Volz Date: Mon, 13 Apr 2020 15:18:09 -0400 Subject: uhd: Make sure generated file is closed Letting garbage collection close the file works when using CPython, but it fails with PyPy which uses a different garbage collection strategy. This makes sure that the file is closed by using a file context manager. --- host/lib/ic_reg_maps/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'host/lib') diff --git a/host/lib/ic_reg_maps/common.py b/host/lib/ic_reg_maps/common.py index 69a4b0b66..7e1eac086 100755 --- a/host/lib/ic_reg_maps/common.py +++ b/host/lib/ic_reg_maps/common.py @@ -178,4 +178,5 @@ def generate(name, regs_tmpl, body_tmpl='', file=__file__, append=False): ) #write the generated code to file specified by argv1 - open(sys.argv[1], 'a' if append else 'w').write(code) + with open(sys.argv[1], 'a' if append else 'w') as f: + f.write(code) -- cgit v1.2.3