As I mentioned in my last article, I figured I’d try to find something that I could patch in Python and submit it. While writing the other article, I stumbled on a minor error in the Python devguide in the Windows section. While it’s nowhere near as cool to patch a piece of documentation as I think it would be to patch Python, I think it’s rather appropriate for me as I tend to contribute more documentation than anything else lately. So I am going to explain the process as I found it.

Getting Started

First off, you need to get an account with the Bug Tracker for Python. If you hope to become a core developer, then you’ll need to make sure your username follows their guidelines, which are really simple:



firstname.lastname



Once you’ve got that, you can start looking for something to patch. There’s a link that says “Easy issues” that is a good starting place. You can also do a search for a component that you’re competent in using and see if there are any bugs in there that you think you can fix. Once you find something, you’ll need to make sure you update your local repo and then read the devguide’s patch page.

Creating the Patch

Assuming you have the necessary repository checked out on your local machine, all you need to do is go edit the appropriate file. In my case, I had to check out the devguide (which you can read about here) and edit the setup.rst file. If you’re editing Python code, then you’ll have to conform to PEP8. Once I finished editing the file, I saved my changes and then had to use Mercurial to create the patch. Here’s the command I used per the Python patch instructions.



hg diff > setup.patch



And here is the contents of that patch file:



diff -r b1c1d15271c0 setup.rst

--- a/setup.rst Tue May 22 00:33:42 2012 +0200

+++ b/setup.rst Tue May 22 13:55:09 2012 -0500

@@ -173,7 +173,7 @@

To build from the Visual Studio GUI, open pcbuild.sln to load the project

files and choose the Build Solution option from the Build menu, often

associated with the F7 key. Make sure you have chosen the "Debug" option from

-the build configuration drop-down first.

+the configuration toolbar drop-down first.

Once built you might want to set Python as a startup project. Pressing F5 in

Visual Studio, or choosing Start Debugging from the Debug menu, will launch



Now that we have a patch we need to submit it!

Submitting a Patch

Put your shields up, we’re going in! Submitting a patch is a little daunting. What will people think of you? I suspect if you plan to work on something major, then you better start growing some thick skin. In my case, I’m going to submit a really simple typo fix, so I’m hoping that sort of thing isn’t flame-worthy. Then again, this is my first patch, so I may submit it in a completely erroneous way. Since my patch will be for something (presumably) new, I did a quick search to make sure it hadn’t already been reported. Seeing nothing, I clicked the “Create New” link with some trepidation and choose the “devguide” as my component. I also chose the latest version of Python. I don’t see anything in the devguide that says it applies to just one set of Python versions, so I’m just going to leave it at that. I didn’t really see a “type” that fit a devguide edit, so I left that blank for my betters to fix. Finally, I attached my patch file to the bug ticket. You can see my bug ticket here if you like.

When contributing a patch to Python, you should fill out a contributor agreement form which allows the Python Software Foundation to license your code for use with Python while you get to keep the copyright. Yes, you too can become famous just for writing Python code! Assuming people read the source or those acknowledgement pages.

Wrapping Up

I don’t know what will happen to my rather lame contribution. Maybe it’ll get accepted, maybe not. But I think I’ll spend some time trying to figure out some other bugs and just see if there’s anything I can do to help out the Python community. Feel free to join me on this adventure!