Search code examples
pythonmacospatchpython-idle

How to install patches for python on Mac


IDLE has the contextual menu right-click bug on mac (Tk problem)
There is already a patch issued for this problem: issue 10404
I've downloaded the patch (issue10404-idle_no_context_menus.txt) - where and how do I install it?
Thanks in advance.


Solution

  • Find the EditorWindow.py file in your filesystem (find / -name EditorWindow.py if you're completely in the dark about where it might live); cd into it's containing directory, then run:

    patch --dry-run < ~/path/to/issue10401-idle_no_context_menus.txt
    

    If it succeeds, take off the --dry-run and re-run the command. If it didn't succeed, try adding -P2, -P3 or -P1. (The -P<n> says to ignore the <n> directories named in the patch, and I can never remember exactly how it works, so I just fiddle with --dry-run and the options until it works. :)

    If the patch doesn't cleanly apply because your version doesn't match the 'pre' version in the patch file exactly, you can just edit the file and "apply the diff by hand" -- make the same kinds of changes it does, but accounting for whatever might have changed. Sometimes it is just an indentation level that changed, so it could be easy, sometimes the entire logic is different, and it is pointless to try to make the patch fit.