This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Graphviz output for 2to3 fixer patterns
Type: enhancement Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.3
process
Status: closed Resolution: wont fix
Dependencies: Superseder: Close 2to3 issues and list them here
View: 45544
Assigned To: Nosy List: akuchling, belopolsky, benjamin.peterson, eric.araujo, facundobatista, gmattbond, loewis
Priority: normal Keywords: patch

Created on 2010-08-16 15:39 by gmattbond, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
2to3-graph.diff gmattbond, 2010-08-16 15:39
fix_buf_pytree_1.png gmattbond, 2010-09-22 22:08 fix_buffer generated graph
Messages (10)
msg114049 - (view) Author: Matt Bond (gmattbond) Date: 2010-08-16 15:39
As part of my GSoC project working on 2to3, I've created a script which will allow compiled fixer patterns to be visualized using graphviz. This would be useful for debugging and understanding exactly how patterns are matched. I've written using the 2to3 sandbox as my base.

The script is named pat2dot and is found in the scripts directory. The script currently relies on an external graphviz library (I provided bindings for the GvGen library with this patch), they are separated enough from the rest of the code that it would be trivial to create a class that would work using a different graphviz library. Additionally, since the code is never called within 2to3 proper, this dependency will only appear if you wish to use pat2dot, and will not affect any other usages of lib2to3.

Usage of the script is `python pat2dot.py fixername` where fixername is any fixer provided in 2to3, as named by 2to3's -l option.
msg116976 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-20 21:24
Can you port your diff to 3.2?  It’s where new features land.

I think the implicit relative import (“import gvgraph” with the Tools/scripts dir is not on sys.path) won’t work.
msg117059 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-09-21 15:04
Matt,

Can you post a sample graph in a common image format, say PNG?  I am curious to see it, but not curious enough to install graphviz.
msg117095 - (view) Author: Matt Bond (gmattbond) Date: 2010-09-21 19:15
Éric,

When I was working with 2to3 this summer I was running it via python3, so I think the patch should work - however, if I've submitted it to the wrong place or the wrong branch, where should I be looking at to ensure my code does work on 3.2 and is submitted to the right place?

In regard to the import gvgraph, I wasn't sure what to do with it - for my distribution gvgraph wasn't available as a package, and it was only one file so I just dumped it in the same directory as the script. I'm open to suggestions as to how that import should be handled better.

Alexander - I'll attach a sample image as soon as I get back to my development machine, which should be later this week.
msg117157 - (view) Author: Matt Bond (gmattbond) Date: 2010-09-22 22:08
As requested, attached is the output for the fix_buffer fixer, as an example of the kind of output this patch can produce.
msg117160 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-22 23:28
> When I was working with 2to3 this summer I was running it via python3,
> so I think the patch should work
Code in the patch uses print as a keyword (2.x), not a function (3.x).  How does that work?

> however, if I've submitted it to the wrong place or the wrong branch,
> where should I be looking at to ensure my code does work on 3.2 and
> is submitted to the right place?
This tracker is the right place for bugs relevant to any CPython version.  To ensure your code works on 3.2, just apply the diff on a 3.2 checkout.  More info on http://www.python.org/dev/ (especially http://www.python.org/dev/patches/).

> In regard to the import gvgraph, I wasn't sure what to do with it
If the implicit relative import doesn’t work, as I suspect, sys.path.append(os.path.dirname(__file__)) should be enough.

(Cheers from a fellow GSoCer, by the way :)
msg117625 - (view) Author: Matt Bond (gmattbond) Date: 2010-09-29 16:00
Huh. I must have diffed the wrong version of my code - how embarrassing!

I'll update the attached patch later this week. Thanks for catching that.
msg122610 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-28 03:04
Hey Matt, can you give us a status update?
msg123096 - (view) Author: Matt Bond (gmattbond) Date: 2010-12-02 18:30
Sorry for the delay in responding, and for getting this patch cleaned up and submitted.

While I was going through my code to submit it, I found a couple of additional issues with it. Then I ended up becoming very busy with my grad courses. As a result, I haven't had a chance to do anything with it. Currently, my plan is to rework it over the winter break to fix the issues, make it work correctly with python 3, and remove the dependence on the external graphviz package (which should resolve the import issue as well).
msg280174 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2016-11-06 21:14
Matt, do you just want to drop the issue or provide a new patch?  Your code might well still be useful, but it's been 6 years, so you may not even have the code any longer.
History
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53830
2021-10-20 22:47:43iritkatrielsetstatus: open -> closed
superseder: Close 2to3 issues and list them here
resolution: wont fix
stage: patch review -> resolved
2016-11-06 21:14:53akuchlingsetnosy: + akuchling
messages: + msg280174
2010-12-02 20:28:22eric.araujosetversions: + Python 3.3, - Python 3.2
2010-12-02 18:30:29gmattbondsetmessages: + msg123096
2010-11-28 03:04:43eric.araujosetmessages: + msg122610
2010-09-29 16:00:24gmattbondsetmessages: + msg117625
2010-09-22 23:28:44eric.araujosetmessages: + msg117160
2010-09-22 22:08:59gmattbondsetfiles: + fix_buf_pytree_1.png

messages: + msg117157
2010-09-21 19:15:51gmattbondsetmessages: + msg117095
2010-09-21 15:04:40belopolskysetnosy: + belopolsky
messages: + msg117059
2010-09-20 21:24:24eric.araujosetversions: + Python 3.2, - Python 2.6
nosy: + eric.araujo, benjamin.peterson

messages: + msg116976

type: enhancement
stage: patch review
2010-08-16 15:39:57gmattbondcreate