den-run-ai / yapgvb

Automatically exported from code.google.com/p/yapgvb
0 stars 0 forks source link

Recursive error handling blows stack if you try to display a Graph at the REPL #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open a Python prompt
2. Call yapgvb.Digraph("G")

What is the expected output? What do you see instead?
I'd expect to see some textual representation of a graph. Instead I see a
vast strack trace that repeats until the stack is blown.

What version of the product are you using? On what operating system?
1.2.0

Please provide any additional information below.
The problem is caused by the error handling code in _yapgvb_py.debug()
trying to print a representation of the arguments. Since doing that is what
causes the problem in the first place it recurses.

Original issue reported on code.google.com by ben.butl...@gmail.com on 26 Mar 2009 at 10:42

GoogleCodeExporter commented 9 years ago
I think it might have something to do with getting edges.

The following:

    import yapgvb
    g = yapgvb.Digraph("foobar")
    foo = g.add_node(label = "foo")
    bar = g.add_node(label = "bar")
    edge = g.add_edge(foo, bar)
    edge.label = "baz"
    print foo.label
    print bar.label
    print edge.label
    print foo
    print bar
    print edge # <-- this will create recursive error

Creates a recursive error.

********************************************************************************
Function:  __get_head__ at 
C:\Python26\lib\site-packages\yapgvb\_yapgvb_py.py:345
Calling:   Edge.head = property(lambda e: e.__get_head__(), doc="The edge's head
(source) node")
           ('C:\\Python26\\lib\\site-packages\\yapgvb\\__init__.py', 134, '<lambda>')
NotImplementedError:
    Args:
********************************************************************************
Function:  __get_head__ at 
C:\Python26\lib\site-packages\yapgvb\_yapgvb_py.py:345
Calling:   Edge.head = property(lambda e: e.__get_head__(), doc="The edge's head
(source) node")
           ('C:\\Python26\\lib\\site-packages\\yapgvb\\__init__.py', 134, '<lambda>')
NotImplementedError:
    Args:
********************************************************************************
Function:  __get_head__ at 
C:\Python26\lib\site-packages\yapgvb\_yapgvb_py.py:345
Calling:   Edge.head = property(lambda e: e.__get_head__(), doc="The edge's head
(source) node")
           ('C:\\Python26\\lib\\site-packages\\yapgvb\\__init__.py', 134, '<lambda>')
NotImplementedError:
    Args:
********************************************************************************
Function:  __get_head__ at 
C:\Python26\lib\site-packages\yapgvb\_yapgvb_py.py:345
Calling:   Edge.head = property(lambda e: e.__get_head__(), doc="The edge's head
(source) node")
           ('C:\\Python26\\lib\\site-packages\\yapgvb\\__init__.py', 134, '<lambda>')
NotImplementedError:
    Args:
********************************************************************************
Function:  __get_head__ at 
C:\Python26\lib\site-packages\yapgvb\_yapgvb_py.py:345
Calling:   Edge.head = property(lambda e: e.__get_head__(), doc="The edge's head
(source) node")
           ('C:\\Python26\\lib\\site-packages\\yapgvb\\__init__.py', 134, '<lambda>')
NotImplementedError:
    Args:
********************************************************************************

etc.

/Per

Original comment by per9...@gmail.com on 7 Apr 2009 at 6:47

GoogleCodeExporter commented 9 years ago
Quick and Dirty fix that solves it for me. It also solves initial posters 
problem.

In C:\Python26\lib\site-packages\yapgvb\_yapgvb_py.py I modified two methods:

    @debug
    def __get_head__(self,*a, **b):
        return self._source
        #raise NotImplementedError

    @debug
    def __get_tail__(self,*a, **b):
        return self._dest
        #raise NotImplementedError

/Per

Original comment by per9...@gmail.com on 7 Apr 2009 at 6:54

Attachments:

GoogleCodeExporter commented 9 years ago
But I guess there is still some work to be done.

/Per

>grep -n "NotImplementedErro" *.py
_yapgvb_py.py:59:            raise NotImplementedError("You are using the 
pure-Python
experimental backend.  A lot of th ings are not implemented yet.")
_yapgvb_py.py:139:        raise NotImplementedError
_yapgvb_py.py:143:        raise NotImplementedError
_yapgvb_py.py:147:        raise NotImplementedError
_yapgvb_py.py:151:        raise NotImplementedError
_yapgvb_py.py:164:        raise NotImplementedError
_yapgvb_py.py:177:        raise NotImplementedError
_yapgvb_py.py:197:        raise NotImplementedError
_yapgvb_py.py:201:        raise NotImplementedError
_yapgvb_py.py:205:        raise NotImplementedError
_yapgvb_py.py:209:        raise NotImplementedError
_yapgvb_py.py:213:        raise NotImplementedError
_yapgvb_py.py:217:        raise NotImplementedError
_yapgvb_py.py:221:        raise NotImplementedError
_yapgvb_py.py:225:        raise NotImplementedError
_yapgvb_py.py:229:        raise NotImplementedError
_yapgvb_py.py:298:        raise NotImplementedError
_yapgvb_py.py:302:        raise NotImplementedError
_yapgvb_py.py:306:        raise NotImplementedError
_yapgvb_py.py:311:        raise NotImplementedError
_yapgvb_py.py:315:        raise NotImplementedError
_yapgvb_py.py:319:        raise NotImplementedError
_yapgvb_py.py:348:        #raise NotImplementedError
_yapgvb_py.py:353:        #raise NotImplementedError

Original comment by per9...@gmail.com on 7 Apr 2009 at 6:55

GoogleCodeExporter commented 9 years ago
Fixed, as of version 1.2.1, by special-casing NotImplementedError in the @debug
decorator.  NotImplementedError will propagate normally; all other exceptions 
will be
trapped by the decorator.

Original comment by lonnie.p...@gmail.com on 13 Apr 2009 at 2:53