On Sunday February 20th Python 3.2 was released. Normally I wouldn’t mention when a new point release of Python, but this one is special to me. It is the first release of Python in which I have played a (very small) part.
A while ago, I was playing around with Python’s multiprocessing module which, at the time, was new to me. All of the simple examples that I found would use the os.getpid() and os.getppid() functions to show that the spawned process was indeed a child of the initial Python process. The problem is that on the Windows platform, os.getppid() was not implemented. I downloaded a zip of the source code and within a hour I had a working implementation of os.getppid() and could run the samples, great. Time goes by, and I start to think about contributing my implementation to the actual Python source code. I had no idea how to go about and do such a thing. Fortunately, the Python developer guide has wonderful documentation on how you can contribute. So, I created an issue for os.getppid() on Windows, stumbled through the process of creating a patch, submitted the patch, and then waited. A core Python developer picked up the issue and told me that I would have to provide a unit test before any check-in would happen. This meant I would have to spelunk through the source tree to find the unit tests and implement a meaningful test for this. Well, you all know how life happens, time goes by, and I actually forgot that I had even created this issue. Eventually I received an email from a core Python developer that moved the issues from the 2.x branch of Python to the 3.x branch. I got back involved, implemented the unit test and the documentation changes, submitted all the patches and before I knew it, the code was checked in and the issue was closed.
About this time Tim Golden posted a call out to Windows developers to help contribute to Python. I looked around for other issues to work on. I ended up being involved on two other issues for Python 3.2 (on Windows). First, I implemented os.getlogin(). It was just another os module function not available on Windows. Then, I fixed a bug in the generation of .pyc files. There was a call to _mkdir to create a directory. The signature of this function on Windows has one less parameter than on *Nix systems. Thus, every time _mkdir was called it would push an extra parameter on the stack that was not used. Being that it is using the C calling convention, the caller cleans the stack, so the extra parameter was actually cleaned up off the stack. Thus, this was a very minor issue that most likely wouldn’t have caused any problems, but I fixed it anyway.
I would like to write a more in-depth entry about my experience contributing to Python. I would also like to get involved again in more issues. Most likely one at a time because: It can be time consuming, no one is going to pay you, and you must work on the issues on your own time. It is also great fun and a learning experience. I think every professional developer should be involved in some open source project. There are many open source projects, even in the Windows and .NET worlds too (NUnit, NHibernate, IronPython, IronRuby, checkout codeplex). Go find an open source project and grab an issue from the issue tracker and go for it!
No comments:
Post a Comment