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

pyparsing 3.0.2 broke pydot #319

Closed
MarcCote opened this issue Oct 27, 2021 · 7 comments
Closed

pyparsing 3.0.2 broke pydot #319

MarcCote opened this issue Oct 27, 2021 · 7 comments

Comments

@MarcCote
Copy link

MarcCote commented Oct 27, 2021

Hi,

I just stumbled on this issue with pyparsing 3.0.2 (I can confirm 2.4.7, 3.0.0, and 3.0.1 were fine).

In [2]: import pydot

In [3]: pydot.graph_from_dot_data("""
   ...: graph G {
   ...:     b1 [label=<
   ...:          We are the knights who say <BR/># Ni
   ...:     >];
   ...: }
   ...: """)
graph G {
      ^
Expected '{', found 'G'  (at char 7), (line:2, col:7)

Note the leading whitespaces in the string.
Here's a simpler minimal example:

import pydot
pydot.graph_from_dot_data("graph G { b1 [label=<Hello World>]; }")
graph G { b1 [label=<Hello World>]; }
      ^
Expected '{', found 'G'  (at char 6), (line:1, col:7)
@ptmcg
Copy link
Member

ptmcg commented Oct 27, 2021

I'm looking at this now - can you post the expected output for both of these, so that if I resolve one part of the issue, I'll know if there is more to do, or the expected results were returned?

Thanks for checking this out so quickly!

@MarcCote
Copy link
Author

Might not be super useful but here are the expected outputs:

In [1]: import pydot

In [2]: pydot.graph_from_dot_data("graph G { b1 [label=<Hello World>]; }")
Out[2]: [<pydot.Dot at 0x7f8c19cf8430>]

In [3]: pydot.graph_from_dot_data("""
   ...: graph G {
   ...:     b1 [label=<
   ...:          We are the knights who say <BR/># Ni
   ...:     >];
   ...: }
   ...: """)
Out[3]: [<pydot.Dot at 0x7f8c19d0fe80>]

pydot has some dependencies on graphviz, I've installed it through conda.
conda install graphviz

I'm running this version of graphviz.

$ dot -V
dot - graphviz version 2.40.1 (20161225.0304)

@ptmcg
Copy link
Member

ptmcg commented Oct 27, 2021

Yes, the pydot.Dot reprs aren't helping me much.

Testing the parser in isolation (with some changes in pyparsing), I get these outputs:

[['graph'], 'G', ['b1', 'label', '=', '<\n         We are the knights who say <BR/>\n    >']]
[['graph'], 'G', ['b1', 'label', '=', '<Hello World>']]

I can guess that the second one looks right, but the first one omits "# Ni" - is that the expected behavior?

Unfortunately, my pyparsing changes perturb some other behavior, so I'm not totally out of the woods. But it looks like I'm in the right place.

@ptmcg
Copy link
Member

ptmcg commented Oct 27, 2021

It looks like I have to undo a small performance optimization, but otherwise, all regression tests pass (plus the new ones added from this week to reference parsers that use pyparsing).

@MarcCote
Copy link
Author

@ptmcg you are right about the "# Ni" it is expected at the moment (see open issue pydot/pydot#235). I shouldn't have used that example, my bad.

@ptmcg
Copy link
Member

ptmcg commented Oct 27, 2021

Fixed in 3.0.3, just pushed to pypi.

@MarcCote
Copy link
Author

I can confirm 3.0.3 is working great for my use cases. Feel free to close this issue.

@ptmcg ptmcg closed this as completed Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants