[issue38654] `urllib.request.Request` uses mutable value as default value

2019-10-31 Thread Efanzh
New submission from Efanzh : The `headers` argument of the `__init__` method of `urllib.request.Request` class uses `{}` as default value, which is mutable. It is not a good idea. -- components: Library (Lib) messages: 355750 nosy: EFanZh priority: normal pull_requests: 16537 severity

[issue38654] `urllib.request.Request` uses mutable value as default value

2019-10-31 Thread Efanzh
Efanzh added the comment: How about changing `if headers` to `if headers is not None`? -- ___ Python tracker <https://bugs.python.org/issue38654> ___ ___ Pytho

[issue38654] `urllib.request.Request` uses mutable value as default value

2019-10-31 Thread Efanzh
Efanzh added the comment: I agree that this doesn’t fix any bug. But is is easy to make mistakes by using mutable default values (See https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments). Both PyCharm and pylint show warnings about mutable default arguments even there is