Skip to main content
This guide covers the typical workflow for contributing code to CPython, from creating a branch to submitting a pull request.

Overview

The CPython development workflow follows standard GitHub practices:
  1. Create an issue (for non-trivial changes)
  2. Create a feature branch
  3. Make your changes
  4. Test your changes
  5. Commit your changes
  6. Push and create a pull request
  7. Address review feedback
  8. Merge when approved

Before You Start

Ensure you have:

Creating an Issue

For most changes, create an issue first:
1

Check for existing issues

Search github.com/python/cpython/issues to avoid duplicates.
2

Create a new issue

If none exists, create a new issue describing:
  • The problem or feature request
  • Expected behavior
  • Current behavior (for bugs)
  • Python version
  • Platform information
3

Discuss the approach

For significant changes, discuss the implementation approach before writing code.
Trivial changes like fixing typos don’t require an issue.

Creating a Branch

Create a feature branch for your work:
Branch naming convention:
  • Use gh-NNNNN prefix (where NNNNN is the issue number)
  • Add a descriptive name
  • Use hyphens, not underscores
Examples:
  • gh-12345-fix-dict-memory-leak
  • gh-67890-add-frozenset-optimization

Making Changes

Edit Code

Make your changes following the code style guide:

Build and Test

After making changes, build and test:

Add Tests

Always add tests for new features or bug fixes:

Update Documentation

Update documentation for new features:
See Contributing to Documentation for details.

Committing Changes

Commit Message Format

Follow the commit message format:

Making the Commit

Example commit message:

Commit Guidelines

  • Make atomic commits (one logical change per commit)
  • Write clear, concise commit messages
  • Reference the issue number (gh-NNNNN)
  • Explain why, not just what
  • Sign your commits if required

Pushing and Creating a Pull Request

1

Push your branch

2

Create pull request

Visit GitHub and click “Create pull request” or use the GitHub CLI:
3

Fill out PR template

Your PR description should include:
  • Summary of changes
  • Link to the issue (“Fixes #12345”)
  • Testing done
  • Any breaking changes

Pull Request Title Format

For backport PRs to maintenance branches:
Where:
  • [3.13] is the branch name
  • gh-NNNNN is the issue number
  • GH-MMMMM is the original PR number from main

Code Review Process

Responding to Reviews

1

Read feedback carefully

Review all comments from maintainers and other contributors.
2

Make requested changes

3

Reply to comments

Respond to review comments, especially if you disagree or need clarification.
4

Request re-review

After addressing feedback, request a re-review from the reviewer.

CI/CD Checks

Your PR must pass all CI checks:
  • GitHub Actions: Linux, macOS, Windows builds
  • Azure Pipelines: Additional platform coverage
  • Tests: All test suites must pass
  • Documentation: Doc builds must succeed
Check CI results and fix any failures:

Keeping Your Branch Updated

Rebasing on Main

Keep your branch up to date with main:
Never use --force without --with-lease. It’s safer and prevents accidentally overwriting others’ work.

After Your PR is Merged

1

Update your local repository

2

Delete your feature branch

3

Close related issues

If not automatically closed, manually close the issue with a comment linking to the merged PR.

Backporting Changes

For bug fixes that need to be backported to maintenance branches:
  1. Wait for the PR to be merged to main
  2. A core developer will typically handle backports
  3. If asked to backport yourself:

Working with Multiple PRs

If you’re working on multiple issues:

Troubleshooting

When rebasing causes conflicts:
Common CI failures:
  • Test failures: Run tests locally and fix
  • Linting errors: Follow code style guide
  • Doc build failures: Check .rst syntax
  • Platform-specific: May need maintainer help
If your PR has been open for a while:
Edit the PR description on GitHub to:
  • Update status
  • Add more context
  • Link related issues

Best Practices

  • Small PRs: Keep changes focused and reviewable
  • Test thoroughly: Don’t rely only on CI
  • Be patient: Reviews can take time
  • Be responsive: Address feedback promptly
  • Be respectful: Follow the Code of Conduct
  • Communicate: Ask questions if unclear

Next Steps

Additional Resources