[New-bugs-announce] [issue35082] Mock.__dir__ lists deleted attributes

Mario Corchero report at bugs.python.org
Sat Oct 27 06:45:10 EDT 2018


New submission from Mario Corchero <mariocj89 at gmail.com>:

Calling dir on unittest.mock.Mock will return deleted attributes.

This is a result of the way del is implemented in Mock, which just sets a sentinel in the child mocks, so an AttributeError is raised if the attribute is later accessed.

We can just check for such sentinel in the __dir__ method and not return those.

----------
components: Library (Lib)
messages: 328647
nosy: mariocj89
priority: low
severity: normal
status: open
title: Mock.__dir__ lists deleted attributes
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35082>
_______________________________________


More information about the New-bugs-announce mailing list