Skip to content

incorrect handling of igraph warnings if the user turns them into an exception #38

Description

@ntamas

From Stack Overflow. A short code fragment to reproduce:

warnings.simplefilter('error', 'Cannot shuffle graph')
degseq = [1,2,2,3]
try:
    testgraph = igraph.Graph.Degree_Sequence(degseq,method = "vl")
except RuntimeWarning:
    print degseq
else:
    print "go on"

This will print:

MemoryError: Error at src/attributes.c:284: not enough memory to allocate attribute hashes, Out of memory

The problem is that the C core of igraph never anticipates that some warnings are turned into errors, therefore it does not bail out from igraph_degree_sequence_game at the point where the warning was raised.

Activity

  1. ntamas commented on Jan 30, 2020

    @ntamas
    MemberAuthor

    It seems like this cannot be solved without re-writing nearly every function handler in the C core, which I'd rather not attempt before the 0.8 release.

    Basically, what we need to do in the C core is that we need to check PyErr_Occurred() after every igraph function call in case a warning generated by igraph was turned into an error. If this happens, we need to do regular cleanup instead of continuing with the C glue code.

  2. added
    todoTriaged for implementation in some unspecified future version
    on Jan 30, 2020
  3. ntamas commented on Jan 30, 2020

    @ntamas
    MemberAuthor

    Another option would be to change the C core such that warning handlers could return a value indicating that the warning has been converted into an error by the higher level layer, at which point the C core could treat the warning as if it was an exception.

  4. added this to the 0.9.0 milestone on Sep 14, 2020
  5. modified the milestones: 0.9.0, next on Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    todoTriaged for implementation in some unspecified future version

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions