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

assertion error in complex division #66794

Closed
pitrou opened this issue Oct 10, 2014 · 7 comments
Closed

assertion error in complex division #66794

pitrou opened this issue Oct 10, 2014 · 7 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Oct 10, 2014

BPO 22604
Nosy @malemburg, @mdickinson, @pitrou, @vstinner, @ericvsmith, @ezio-melotti, @serhiy-storchaka
Files
  • c_quot_nan.patch
  • 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 = None
    closed_at = <Date 2014-10-10.23:20:21.243>
    created_at = <Date 2014-10-10.15:35:13.117>
    labels = ['interpreter-core', 'type-bug']
    title = 'assertion error in complex division'
    updated_at = <Date 2014-10-10.23:20:21.241>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2014-10-10.23:20:21.241>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-10-10.23:20:21.243>
    closer = 'pitrou'
    components = ['Interpreter Core']
    creation = <Date 2014-10-10.15:35:13.117>
    creator = 'pitrou'
    dependencies = []
    files = ['36869']
    hgrepos = []
    issue_num = 22604
    keywords = ['patch']
    message_count = 7.0
    messages = ['229011', '229016', '229019', '229025', '229041', '229042', '229043']
    nosy_count = 9.0
    nosy_names = ['lemburg', 'mark.dickinson', 'pitrou', 'vstinner', 'eric.smith', 'stutzbach', 'ezio.melotti', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue22604'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @pitrou
    Copy link
    Member Author

    pitrou commented Oct 10, 2014

    This only happens in debug mode:

    >>> complex(0.0, 0.0) / complex(float('nan'), 0.0)
    python: Objects/complexobject.c:98: _Py_c_quot: Assertion `b.imag != 0.0' failed.

    In release mode, this gives:

    >>> complex(0.0, 0.0) / complex(float('nan'), 0.0)
    (nan+nanj)

    (is it the right result?)

    @pitrou pitrou added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Oct 10, 2014
    @serhiy-storchaka
    Copy link
    Member

    I think it is the right result.

    >>> 0.0 / float('nan')
    nan

    @pitrou
    Copy link
    Member Author

    pitrou commented Oct 10, 2014

    Here is a patch.

    @mdickinson
    Copy link
    Member

    Patch LGTM.

    (is it the right result?)

    Difficult to tell :-). Complex arithmetic in general isn't well standardised. Annex G of the C standard is about as close I've seen. But it doesn't look terribly wrong.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 10, 2014

    New changeset 0c8f45caf697 by Antoine Pitrou in branch '3.4':
    Issue bpo-22604: Fix assertion error in debug mode when dividing a complex number by (nan+0j).
    https://hg.python.org/cpython/rev/0c8f45caf697

    New changeset af0104aed5b1 by Antoine Pitrou in branch 'default':
    Issue bpo-22604: Fix assertion error in debug mode when dividing a complex number by (nan+0j).
    https://hg.python.org/cpython/rev/af0104aed5b1

    New changeset cd4ecaf38283 by Antoine Pitrou in branch '2.7':
    Issue bpo-22604: Fix assertion error in debug mode when dividing a complex number by (nan+0j).
    https://hg.python.org/cpython/rev/cd4ecaf38283

    @pitrou
    Copy link
    Member Author

    pitrou commented Oct 10, 2014

    Ok, I've committed the patch. Let's just see if the buildbots behave.

    @pitrou
    Copy link
    Member Author

    pitrou commented Oct 10, 2014

    They seem to have behaved! Congratulations, buildbots!

    @pitrou pitrou closed this as completed Oct 10, 2014
    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants