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

2019-11-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: > Also, if some new Python coders saw `[]` or `{}` being used as default > values in the standard library, they might think “I’ll do it too since > the standard library does it”. Great! Having Python coders learn good progamming skills from the standard lib

[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

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

2019-10-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is not needed. There is no bug. Nothing to change. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker __

[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 ___ ___ Python-bugs-li

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

2019-10-31 Thread Steven D'Aprano
Steven D'Aprano added the comment: I agree with Serhiy that using mutable defaults is not automatically a bad idea. This is unnecessary code churn that fixes no bugs and adds no new functionality and doesn't make the code "better". The PR removes one harmless use of a mutable default but add

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

2019-10-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There is nothing wrong with using {} as default value. -- nosy: +serhiy.storchaka ___ Python tracker ___ __

[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: