
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2019-05-26 14:54 bypitrou, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 13601 | merged | vstinner,2019-05-27 23:07 | |
| PR 13604 | merged | miss-islington,2019-05-27 23:44 | |
| Messages (7) | |||
|---|---|---|---|
| msg343552 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2019-05-26 14:54 | |
I see the following kind of exceptions when running test_memoryio:Exception ignored in: <function IOBase.__del__ at 0x7f7cd44f49b0>Traceback (most recent call last): File "/home/antoine/cpython/default/Lib/_pyio.py", line 409, in __del__ self.close() File "/home/antoine/cpython/default/Lib/_pyio.py", line 2152, in close if self.buffer is not None and not self.closed: File "/home/antoine/cpython/default/Lib/_pyio.py", line 2093, in buffer return self._bufferAttributeError: 'StringIO' object has no attribute '_buffer'Exception ignored in: <function IOBase.__del__ at 0x7f7cd44f49b0>Traceback (most recent call last): File "/home/antoine/cpython/default/Lib/_pyio.py", line 409, in __del__ self.close() File "/home/antoine/cpython/default/Lib/_pyio.py", line 2152, in close if self.buffer is not None and not self.closed: File "/home/antoine/cpython/default/Lib/_pyio.py", line 2093, in buffer return self._bufferAttributeError: 'StringIO' object has no attribute '_buffer'okIt seems this could be related toissue18748. | |||
| msg343652 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2019-05-27 16:02 | |
Multiple tests log an "Exception ignored", but all of them come from the Python implementation.The problem is that _pyio.BytesIO and _pyio.TextIOWrapper initialize their self._buffer and self._seekable attribute "later" in the constructor, but then expect these attribute to exist in __del__().Example:>>> import _pyio; _pyio.BytesIO(b'data', foo=b'fat')Exception ignored in: <function IOBase.__del__ at 0x7f1874c5c550>Traceback (most recent call last): File "/home/vstinner/prog/python/master/Lib/_pyio.py", line 409, in __del__ self.close() File "/home/vstinner/prog/python/master/Lib/_pyio.py", line 903, in close self._buffer.clear()AttributeError: 'BytesIO' object has no attribute '_buffer'Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: __init__() got an unexpected keyword argument 'foo'BytesIO.__init__() is not even called.An easy fix would be to do nothing in __del__() if hasattr(self, '_buffer') if false. | |||
| msg343653 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2019-05-27 16:04 | |
Or to add `_buffer = None` at the class level. | |||
| msg343700 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2019-05-27 23:08 | |
Antoine:> Or to add `_buffer = None` at the class level.Ok, I wrotebpo-13601 to implement this idea and fix test_memoryio warnings. | |||
| msg343709 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2019-05-27 23:44 | |
New changeseta3568417c49f36860393075b21c93996a5f6799b by Victor Stinner in branch 'master':bpo-37054, _pyio: Fix BytesIO and TextIOWrapper __del__() (GH-13601)https://github.com/python/cpython/commit/a3568417c49f36860393075b21c93996a5f6799b | |||
| msg343718 -(view) | Author: miss-islington (miss-islington) | Date: 2019-05-28 00:05 | |
New changeset0f352d44e7c14c1c93e3999402c85512b9d5a6ca by Miss Islington (bot) in branch '3.7':bpo-37054, _pyio: Fix BytesIO and TextIOWrapper __del__() (GH-13601)https://github.com/python/cpython/commit/0f352d44e7c14c1c93e3999402c85512b9d5a6ca | |||
| msg343720 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2019-05-28 00:19 | |
Thanks for the report Antoine. It is now fixed in 3.7 and master branches. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:15 | admin | set | github: 81235 |
| 2019-05-28 00:19:06 | vstinner | set | status: open -> closed resolution: fixed messages: +msg343720 stage: patch review -> resolved |
| 2019-05-28 00:05:55 | miss-islington | set | nosy: +miss-islington messages: +msg343718 |
| 2019-05-27 23:44:31 | miss-islington | set | pull_requests: +pull_request13510 |
| 2019-05-27 23:44:24 | vstinner | set | messages: +msg343709 |
| 2019-05-27 23:08:12 | vstinner | set | messages: +msg343700 |
| 2019-05-27 23:07:10 | vstinner | set | keywords: +patch stage: patch review pull_requests: +pull_request13507 |
| 2019-05-27 16:04:33 | pitrou | set | messages: +msg343653 |
| 2019-05-27 16:02:19 | vstinner | set | messages: +msg343652 |
| 2019-05-26 14:54:40 | pitrou | create | |