[New-bugs-announce] [issue44475] Dataclass Causes Infinite Recursion when using type of bytes

Andrew C report at bugs.python.org
Mon Jun 21 11:06:36 EDT 2021


New submission from Andrew C <andrewonboe at gmail.com>:

Hello,

When given a `Field` on a Dataclass, the `__repr__` throws an infinite recursive error when the data type is bytes.

In the `Field` class, the __repr__ is as follows:

```
    def __repr__(self):
        return (
            'Field('
            f'name={self.name!r},'
            f'type={self.type!r},'
            f'default={self.default!r},'
            f'default_factory={self.default_factory!r},'
            f'init={self.init!r},'
            f'repr={self.repr!r},'
            f'hash={self.hash!r},'
            f'compare={self.compare!r},'
            f'metadata={self.metadata!r},'
            f'_field_type={self._field_type}'
            ')'
        )
```

The issue is the f'type={self.type!r}, part of the code.

----------
components: Windows
messages: 396250
nosy: andrewonboe, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Dataclass Causes Infinite Recursion when using type of bytes
versions: Python 3.7, Python 3.8

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


More information about the New-bugs-announce mailing list