Mercurial > cgi-bin > hgweb.cgi > curlyq
comparison runes.py @ 14:152f6aa87d62
Plug a memoryview leak.
author | David Barts <n5jrn@me.com> |
---|---|
date | Fri, 27 Dec 2019 13:30:44 -0800 |
parents | 6acda841a690 |
children | 0be0586104b7 |
comparison
equal
deleted
inserted
replaced
13:6acda841a690 | 14:152f6aa87d62 |
---|---|
153 | 153 |
154 def __getitem__(self, key): | 154 def __getitem__(self, key): |
155 view = memoryview(self.buffer) | 155 view = memoryview(self.buffer) |
156 try: | 156 try: |
157 ret = view[key] | 157 ret = view[key] |
158 if isinstance (ret, int): | 158 try: |
159 return chr(ret) | 159 if isinstance (ret, int): |
160 elif isinstance(ret, memoryview): | 160 return chr(ret) |
161 return self.codec.decode(ret, 'replace')[0] | 161 elif isinstance(ret, memoryview): |
162 else: | 162 return self.codec.decode(ret, 'replace')[0] |
163 raise AssertionError("this shouldn't happen") | 163 else: |
164 raise AssertionError("this shouldn't happen") | |
165 finally: | |
166 ret.release() | |
164 except IndexError: | 167 except IndexError: |
165 return "" | 168 return "" |
166 finally: | 169 finally: |
167 view.release() | 170 view.release() |
168 | 171 |