Issue 37054: Ignored exceptions in test_memoryio (original) (raw)

Created on 2019-05-26 14:54 by pitrou, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (7)

msg343552 - (view)

Author: Antoine Pitrou (pitrou) * (Python committer)

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._buffer AttributeError: '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._buffer AttributeError: 'StringIO' object has no attribute '_buffer' ok

It seems this could be related to .

msg343652 - (view)

Author: STINNER Victor (vstinner) * (Python committer)

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 "", line 1, in 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) * (Python committer)

Date: 2019-05-27 16:04

Or to add _buffer = None at the class level.

msg343700 - (view)

Author: STINNER Victor (vstinner) * (Python committer)

Date: 2019-05-27 23:08

Antoine:

Or to add _buffer = None at the class level.

Ok, I wrote bpo-13601 to implement this idea and fix test_memoryio warnings.

msg343709 - (view)

Author: STINNER Victor (vstinner) * (Python committer)

Date: 2019-05-27 23:44

New changeset a3568417c49f36860393075b21c93996a5f6799b 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 changeset 0f352d44e7c14c1c93e3999402c85512b9d5a6ca 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) * (Python committer)

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: +

stage: patch review -> resolved

2019-05-28 00:05:55

miss-islington

set

nosy: + miss-islington
messages: +

2019-05-27 23:44:31

miss-islington

set

pull_requests: + <pull%5Frequest13510>

2019-05-27 23:44:24

vstinner

set

messages: +

2019-05-27 23:08:12

vstinner

set

messages: +

2019-05-27 23:07:10

vstinner

set

keywords: + patch
stage: patch review
pull_requests: + <pull%5Frequest13507>

2019-05-27 16:04:33

pitrou

set

messages: +

2019-05-27 16:02:19

vstinner

set

messages: +

2019-05-26 14:54:40

pitrou

create