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

Graphviz output for 2to3 fixer patterns #53830

Closed
gmattbond mannequin opened this issue Aug 16, 2010 · 10 comments
Closed

Graphviz output for 2to3 fixer patterns #53830

gmattbond mannequin opened this issue Aug 16, 2010 · 10 comments
Labels
topic-2to3 type-feature A feature request or enhancement

Comments

@gmattbond
Copy link
Mannequin

gmattbond mannequin commented Aug 16, 2010

BPO 9621
Nosy @loewis, @akuchling, @facundobatista, @abalkin, @benjaminp, @merwok
Superseder
  • bpo-45544: Close 2to3 issues and list them here
  • Files
  • 2to3-graph.diff
  • fix_buf_pytree_1.png: fix_buffer generated graph
  • 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 2021-10-20.22:47:43.026>
    created_at = <Date 2010-08-16.15:39:57.145>
    labels = ['type-feature', 'expert-2to3']
    title = 'Graphviz output for 2to3 fixer patterns'
    updated_at = <Date 2021-10-20.22:47:43.026>
    user = 'https://bugs.python.org/gmattbond'

    bugs.python.org fields:

    activity = <Date 2021-10-20.22:47:43.026>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-20.22:47:43.026>
    closer = 'iritkatriel'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2010-08-16.15:39:57.145>
    creator = 'gmattbond'
    dependencies = []
    files = ['18544', '18968']
    hgrepos = []
    issue_num = 9621
    keywords = ['patch']
    message_count = 10.0
    messages = ['114049', '116976', '117059', '117095', '117157', '117160', '117625', '122610', '123096', '280174']
    nosy_count = 7.0
    nosy_names = ['loewis', 'akuchling', 'facundobatista', 'belopolsky', 'benjamin.peterson', 'eric.araujo', 'gmattbond']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = '45544'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue9621'
    versions = ['Python 3.3']

    @gmattbond
    Copy link
    Mannequin Author

    gmattbond mannequin commented Aug 16, 2010

    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.

    @gmattbond gmattbond mannequin added the topic-2to3 label Aug 16, 2010
    @merwok
    Copy link
    Member

    merwok commented Sep 20, 2010

    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.

    @merwok merwok added the type-feature A feature request or enhancement label Sep 20, 2010
    @abalkin
    Copy link
    Member

    abalkin commented Sep 21, 2010

    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.

    @gmattbond
    Copy link
    Mannequin Author

    gmattbond mannequin commented Sep 21, 2010

    É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.

    @gmattbond
    Copy link
    Mannequin Author

    gmattbond mannequin commented Sep 22, 2010

    As requested, attached is the output for the fix_buffer fixer, as an example of the kind of output this patch can produce.

    @merwok
    Copy link
    Member

    merwok commented Sep 22, 2010

    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 :)

    @gmattbond
    Copy link
    Mannequin Author

    gmattbond mannequin commented Sep 29, 2010

    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.

    @merwok
    Copy link
    Member

    merwok commented Nov 28, 2010

    Hey Matt, can you give us a status update?

    @gmattbond
    Copy link
    Mannequin Author

    gmattbond mannequin commented Dec 2, 2010

    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).

    @akuchling
    Copy link
    Member

    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.

    @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
    topic-2to3 type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants