[New-bugs-announce] [issue31325] req_rate is a namedtuple type rather than instance

Robin report at bugs.python.org
Fri Sep 1 11:15:22 EDT 2017


New submission from Robin:

> Finally, urllib/robotparser.py appears to contain a bug in the
> following:
>
>   req_rate = collections.namedtuple('req_rate',
>                                    'requests seconds')
>   entry.req_rate = req_rate
>   entry.req_rate.requests = int(numbers[0])
>   entry.req_rate.seconds = int(numbers[1])
> 
> As I read it, this should fail as the req_rate is immutable.

Ref: https://news.ycombinator.com/item?id=15136961

They are mistaken in the nature of the bug, which is that req_rate is
a namedtuple type, rather than an instance. As such, it is actually
mutable, causing the assignments to not fail. Every entry creates a
separate req_rate type, so it all works, but not in the way it should.

----------
components: Library (Lib)
messages: 301127
nosy: gvx
priority: normal
pull_requests: 3307
severity: normal
status: open
title: req_rate is a namedtuple type rather than instance
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31325>
_______________________________________


More information about the New-bugs-announce mailing list