[New-bugs-announce] [issue40084] HTTPStatus has incomplete dir() listing

Raymond Hettinger report at bugs.python.org
Fri Mar 27 03:16:45 EDT 2020


New submission from Raymond Hettinger <raymond.hettinger at gmail.com>:

The dir() listing omits the attributes "description" and "phrase":

>>> import http
>>> from pprint import pp
>>> r = http.HTTPStatus(404)
>>> pp(vars(r))
{'_value_': 404,
 'phrase': 'Not Found',
 'description': 'Nothing matches the given URI',
 '_name_': 'NOT_FOUND',
 '__objclass__': <enum 'HTTPStatus'>}
>>> r.value
404
>>> r.name
'NOT_FOUND'
>>> r.description
'Nothing matches the given URI'
>>> r.phrase
'Not Found'
>>> dir(r)
['__class__', '__doc__', '__module__', 'as_integer_ratio', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'name', 'numerator', 'real', 'to_bytes', 'value']

One fix would be to teach IntEnum.__dir__() to include entries in the instance dict.  Another fix would be to provide a way for a IntEnum subclass to add to the known members list.

----------
components: Library (Lib)
messages: 365138
nosy: ethan.furman, rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: HTTPStatus has incomplete dir() listing
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

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


More information about the New-bugs-announce mailing list