Issue 8292: Incorrect condition test in platform.py (original) (raw)
Created on 2010-04-02 16:48 by akuchling, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (4)
Author: A.M. Kuchling (akuchling) * 
Date: 2010-04-02 16:48
While looking at #4440, I grepped for similar problems and found one in platform.py in the following line:
if no_os_uname or not filter(None, (system, node, release, version, machine))
In 3.x, filter() returns an object, not a list, so 'not filter()' will always be false.
One fix is to either convert filter's output by adding list() or tuple(). Another fix could be 'not any ((system, node, release, version, machine))', but I don't know if platform.py is trying to stay compatible with versions of Python that lack any().
Author: Marc-Andre Lemburg (lemburg) * 
Date: 2010-04-03 12:36
A.M. Kuchling wrote:
New submission from A.M. Kuchling <lists@amk.ca>:
While looking at #4440, I grepped for similar problems and found one in platform.py in the following line:
if no_os_uname or not filter(None, (system, node, release, version, machine))
In 3.x, filter() returns an object, not a list, so 'not filter()' will always be false.
One fix is to either convert filter's output by adding list() or tuple(). Another fix could be 'not any ((system, node, release, version, machine))', but I don't know if platform.py is trying to stay compatible with versions of Python that lack any().
I'm trying to keep platform.py compatible with all Python versions since 2.3, so using the list() wrapper appears to be the better solution.
Author: ysj.ray (ysj.ray)
Date: 2010-04-08 06:55
It seems that the "Lib/lib2to3/fixes/fix_filter.py" should have fixed all the "filter" problem in py3k, by adding a "list()" call to "filter()". It's werid this one still exists in standar library.
Also I found other two problems with "filter" in standar library. They make condition tests on filter object, although the result is correct, but I think it's not proper.
So I make a patch to fix these three problems.
Author: Georg Brandl (georg.brandl) * 
Date: 2010-07-31 21:54
Thanks, committed patch as r83371.
History
Date
User
Action
Args
2022-04-11 14:56:59
admin
set
github: 52539
2010-07-31 21:54:45
georg.brandl
set
status: open -> closed
nosy: + georg.brandl
messages: +
resolution: accepted
2010-04-08 06:55:46
ysj.ray
set
files: + issue_8292.diff
nosy: + ysj.ray
messages: +
components: + Library (Lib)
keywords: + patch
2010-04-03 12:36:14
lemburg
set
messages: +
2010-04-02 16:48:36
akuchling
create