diff options
author | Ryan Volz <rvolz@mit.edu> | 2020-04-13 15:18:09 -0400 |
---|---|---|
committer | michael-west <michael.west@ettus.com> | 2020-07-09 09:33:05 -0700 |
commit | f0fd3619cfe6f343b3c0ac9bff0dc1010905443e (patch) | |
tree | 10dfb2e97aa2839df38e1a314f08fb2a7c15576a | |
parent | 74c381f5e4c28bc794720ed2a46e2ec62d0fa2f7 (diff) | |
download | uhd-f0fd3619cfe6f343b3c0ac9bff0dc1010905443e.tar.gz uhd-f0fd3619cfe6f343b3c0ac9bff0dc1010905443e.tar.bz2 uhd-f0fd3619cfe6f343b3c0ac9bff0dc1010905443e.zip |
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.
-rwxr-xr-x | host/lib/ic_reg_maps/common.py | 3 |
1 files changed, 2 insertions, 1 deletions
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) |