Remove dead Python 2.6/MSVC 2008 compat code, use METH_NOARGS for version functions#334
Open
devdanzin wants to merge 1 commit intopython-lz4:masterfrom
Open
Conversation
- Remove dead #ifndef PyCapsule_Type guards in _frame.c (2 sites) and _stream.c (1 site) — PyCapsule_Type is not a macro, so #ifndef is always true. The #else branches (Python 2.6 capsulethunk compat) are dead code that casts PyObject* directly to struct pointers. - Remove dead MSVC 2008 stdint.h fallback in _block.c and _stream.c — MSVC 2008 (_MSC_VER < 1600) cannot build Python 3.9+. Replace with unconditional #include <stdint.h>. - Remove dead #ifndef Py_UNUSED guard in _block.c — Py_UNUSED has been defined since Python 3.4, and minimum is 3.9. - Change METH_VARARGS to METH_NOARGS for library_version_number and library_version_string in _version.c — these functions take no arguments but METH_VARARGS silently accepts and ignores any args passed by the caller. Found using cext-review-toolkit (https://github.com/devdanzin/cext-review-toolkit). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#ifndef PyCapsule_Typeguards in_frame.c(2 sites) and_stream.c(1 site) —PyCapsule_Typeis an extern symbol, not a macro, so#ifndefis always true. The#elsebranches (Python 2.6 capsulethunk compat) are dead code that unsafely castsPyObject*directly to struct pointers.stdint.hfallback in_block.cand_stream.c— MSVC 2008 (_MSC_VER < 1600) cannot build Python 3.9+. Replace with unconditional#include <stdint.h>.#ifndef Py_UNUSEDguard in_block.c—Py_UNUSEDhas been defined since Python 3.4, and minimum is 3.9.METH_VARARGStoMETH_NOARGSforlibrary_version_numberandlibrary_version_stringin_version.c— these functions take no arguments butMETH_VARARGSsilently accepts and ignores any arguments passed by the caller.69 lines of dead code removed.
Found using cext-review-toolkit.
Note
This PR was authored and submitted by Claude Code (Anthropic).
It was reviewed by a human before submission.
Test plan
library_version_string()still workslibrary_version_string(1, 2, 3)now raisesTypeErrorinstead of silently succeeding