This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Incorrect condition test in platform.py
Type: Stage:
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: lemburg Nosy List: akuchling, georg.brandl, lemburg, ysj.ray
Priority: normal Keywords: easy, patch

Created on 2010-04-02 16:48 by akuchling, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue_8292.diff ysj.ray, 2010-04-08 06:55 patch for the py3k
Messages (4)
msg102179 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) 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().
msg102251 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) 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.
msg102595 - (view) 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.
msg112214 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-07-31 21:54
Thanks, committed patch as r83371.
History
Date User Action Args
2022-04-11 14:56:59adminsetgithub: 52539
2010-07-31 21:54:45georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg112214

resolution: accepted
2010-04-08 06:55:46ysj.raysetfiles: + issue_8292.diff

nosy: + ysj.ray
messages: + msg102595

components: + Library (Lib)
keywords: + patch
2010-04-03 12:36:14lemburgsetmessages: + msg102251
2010-04-02 16:48:36akuchlingcreate