Yesterday I opened my first issue against Python, and enhancement for mailbox, an old part of the standard library, to support Path-like objects, a very new part of the standard library.

On the issue I was invited to submit a pull request. Python like their pull requests to follow a set process, so here is what I did (pulling together the steps from the various pages on their website).

Dependencies

I am doing this inside a WSL environment. I discovered that the environment does not come with any source repositories configured, so the first thing to do is to add the corresponding deb-src lines to /etc/apt/sources.list. I did this for all repositories in there.

As the sources have changed, it is necessary to update apt’s cache:

apt-get update

Then install the build dependencies for Python (this approach is taken straight from Python’s own documentation):

apt-get install build-essential
apt-get build-dep python3.7

Build python

First, I created a fork of Python’s GitHub repository then cloned my fork:

git clone https://github.com/myuser/cpython.git

I then created an upstream remote for the cpython repository, as per their suggestion:

cd cpython
git remote add upstream https://github.com/python/cpython.git

Before doing anything, I created my own branch:

git checkout -b path-like-mailboxes upstream/masters

And configure it (N.B. ./configure fails to find g++ unless explicitly told where it is):

./configure --with-pydebug CXX="/usr/bin/g++"

I then built it with make (my laptop has 4 physical cores, so I used classical “number of cores + 1” for the number of parallel steps):

make -s -j5

It took around 45s to build.

Once build we should have a working python:

$ ./python.exe --version
Python 3.10.0a0

Patching the code

I made the changes required.

I then added my name to Misc/ACKS.

Python uses the blurb tool to manage news. This is not available in any Debian stable package (as checked today), but is installable through pip so I created and installed it in a virtualenv:

virtualenv -ppython3 /tmp/tempvenv
source /tmp/tempvenv/bin/activate
pip install blurb

Using it is simply a case of running blurb with no arguments, it will create an appropriate new NEWS entry in Misc/NEWS.d/next. I looked at some existing ones in the Misc/NEWS.d/next/Library directory for style and formatting.

Finally, I edited the documentation (Doc/library/mailbox.rst in this case).

Run make patchcheck to see if there is anything missed (it will check that MICS/ACKS, Docs, MISC/NEWS.d have been updated).

Run the test suite with ./python.exe -m test. On my system there’s quite a few test fails, even with the unmodified master but I am not sure if that is because its WSL (so not a real Linux kernel) or the Windows Firewall (which was kept popping up while the test suite was trying to run).

The process then follows the familiar add, push, pull request process. The CI tests showed one failure on macOS but that is unrelated to the change I have made, so I presume was a pre-existing issue.