Issue 19321: memoryview should be a context manager (original) (raw)
Issue19321
Created on 2013-10-20 21:00 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (5) | ||
---|---|---|
msg200633 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2013-10-20 21:00 |
memoryview() acquires resource but it rarely released explicitly. I propose to made memoryview a context manager which calls the release() method in the __exit__() method. Perhaps it worth also add resource warning in the __del__() method if a memoryview was not released. | ||
msg200635 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2013-10-20 21:02 |
Already proposed in . | ||
msg200664 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2013-10-21 00:12 |
> Already proposed in . Well, it was not only proposed, but it was also implemented (by Antoine). Python 3.4.0a3+ (default:84a8b797c5c5+, Oct 20 2013, 16:02:32) [GCC 4.8.1 20130603 (Red Hat 4.8.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> x=memoryview(b'abc') >>> with x: pass ... >>> bytes(x) Traceback (most recent call last): File "", line 1, in ValueError: operation forbidden on released memoryview object | ||
msg200709 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2013-10-21 07:53 |
> Well, it was not only proposed, but it was also implemented (by Antoine). Oh, sorry for the noise. | ||
msg200710 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2013-10-21 07:53 |
And thank you Antoine for this. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:52 | admin | set | github: 63520 |
2013-10-21 07:53:33 | serhiy.storchaka | set | messages: + |
2013-10-21 07:53:12 | serhiy.storchaka | set | status: open -> closedresolution: out of datemessages: + stage: needs patch -> resolved |
2013-10-21 00:13:00 | vstinner | set | messages: + |
2013-10-21 00:11:09 | vstinner | set | nosy: + vstinner |
2013-10-20 21:02:42 | pitrou | set | messages: + |
2013-10-20 21:01:31 | serhiy.storchaka | set | nosy: + pitrou, skrah |
2013-10-20 21:00:32 | serhiy.storchaka | create |