Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect condition test in platform.py #52539

Closed
akuchling opened this issue Apr 2, 2010 · 4 comments
Closed

Incorrect condition test in platform.py #52539

akuchling opened this issue Apr 2, 2010 · 4 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir

Comments

@akuchling
Copy link
Member

BPO 8292
Nosy @malemburg, @akuchling, @birkenfeld
Files
  • issue_8292.diff: patch for the py3k
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/malemburg'
    closed_at = <Date 2010-07-31.21:54:45.186>
    created_at = <Date 2010-04-02.16:48:36.305>
    labels = ['easy', 'library']
    title = 'Incorrect condition test in platform.py'
    updated_at = <Date 2010-07-31.21:54:45.184>
    user = 'https://github.com/akuchling'

    bugs.python.org fields:

    activity = <Date 2010-07-31.21:54:45.184>
    actor = 'georg.brandl'
    assignee = 'lemburg'
    closed = True
    closed_date = <Date 2010-07-31.21:54:45.186>
    closer = 'georg.brandl'
    components = ['Library (Lib)']
    creation = <Date 2010-04-02.16:48:36.305>
    creator = 'akuchling'
    dependencies = []
    files = ['16814']
    hgrepos = []
    issue_num = 8292
    keywords = ['patch', 'easy']
    message_count = 4.0
    messages = ['102179', '102251', '102595', '112214']
    nosy_count = 4.0
    nosy_names = ['lemburg', 'akuchling', 'georg.brandl', 'ysj.ray']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue8292'
    versions = ['Python 3.2']

    @akuchling
    Copy link
    Member Author

    While looking at bpo-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().

    @malemburg
    Copy link
    Member

    A.M. Kuchling wrote:

    New submission from A.M. Kuchling <lists@amk.ca>:

    While looking at bpo-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.

    @ysjray
    Copy link
    Mannequin

    ysjray mannequin commented Apr 8, 2010

    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.

    @ysjray ysjray mannequin added the stdlib Python modules in the Lib dir label Apr 8, 2010
    @birkenfeld
    Copy link
    Member

    Thanks, committed patch as r83371.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants