Skip to content

Add build-python-c-extension-module materials folder - #1006

Open
realpython-bot wants to merge 2 commits into
masterfrom
maintenance/build-python-c-extension-module-20261204
Open

realpython-bot wants to merge 2 commits into
masterfrom
maintenance/build-python-c-extension-module-20261204

Conversation

@realpython-bot

Copy link
Copy Markdown
Collaborator

Adds the sample code for the tutorial Building a Python C Extension Module (post 246), matching the full-update draft.

  • write_file.c: plain C program using fputs()
  • fputsmodule.c: finished extension module (custom StringTooShortError, fopen() NULL check with PyErr_SetFromErrnoWithFilename(), PyModule_AddObjectRef(), FPUTS_FLAG/FPUTS_MACRO constants)
  • setup.py (setuptools), fputs_demo.py (the article's REPL sessions as a script), test_fputs.py, requirements.txt (pytest==9.2.0)

Draft: https://realpython.com/pbjt/blog/post/2517/change/
Card: https://trello.com/c/YU51eoUK

Verified on CPython 3.15.2 (Linux, gcc 13.3) in a clean venv: python -m pip install . builds with setuptools 84.2.1, fputs_demo.py output matches the article, pytest -q 1 passed, write_file.c compiles and writes the file. Also built and ran on 3.14.10. ruff 0.14.1 format/check and dircheck.py pass.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant