Skip to content

3.9.25.3: link Windows builds with /OPT:REF,NOICF (bpo-42825) - #116

Merged
icanhasmath merged 2 commits into
3.9.25.xfrom
3.9.25.3-noicf
Oct 29, 2026
Merged

icanhasmath merged 2 commits into
3.9.25.xfrom
3.9.25.3-noicf

Conversation

@icanhasmath

Copy link
Copy Markdown

Summary

Backports upstream bpo-42825 (pythonGH-24098): Windows release builds now link with /OPT:REF,NOICF. The PR also bumps the version to 3.9.25.3.

The bug

On the Platform's Windows build of 3.9.25.2, + with an instance of a subclass of a built-in type returns NotImplemented instead of raising TypeError:

class I(int): pass
I(1) + "s"        # 3.9.25.2 Windows: NotImplemented; expected: TypeError

This also affects subclasses of datetime, date and timedelta, and it makes test_datetime's TestSubclassDateTime_Fast.test_computations fail.

Cause

  • Objects/typeobject.c has two slot wrappers with identical bodies: wrap_binaryfunc and wrap_binaryfunc_l. update_one_slot() tells them apart by their address.
  • The Windows builder now links with Visual Studio 2022 (MSC v.1944; 3.9.25 was built with v.1929). With identical-COMDAT folding on, that linker merges the two functions into one.
  • With them merged, a heap subclass gets nb_add installed as its sq_concat too. PyNumber_Add then calls it as a fallback and returns its NotImplemented to the caller.
  • Upstream fixed this in 3.10 by linking with /OPT:REF,NOICF. The commit message names these same two functions. 3.9 never got that change, while our 3.10 tags have it.

Evidence

  • Platform build: reading wrapperbase.wrapper via ctypes shows int.__add__ and str.__add__ share a wrapper address on 3.9.25.2. On 3.9.25 and on 3.10.22.2 the addresses differ.
  • Local builds on the EC2 Windows box, VS 2022 17.14, toolset v143:
Link options I(1) + "s" test_datetime
/OPT:REF,ICF, without this change NotImplemented —
with this change TypeError 972 tests OK
  • Windows regrtest: compared with 3.9.25, test_datetime was the only CPython regression in 3.9.25.2.

Release

After merge: tag v3.9.25.3, then add language/python 3.9.25.3 to the inventory and rebuild. The Windows QA suite then needs to re-run on the rebuilt runtime.

Austin-Lamb and others added 2 commits October 29, 2026 08:04
We explicitly disable /OPT:ICF as some manual optimisations depend on some functions still having distinct pointers (such as wrap_binary_func and wrap_binary_func_l).

(cherry picked from commit b4af629)
ActiveState release of the end-of-life 3.9 line: the bpo-42825
/OPT:REF,NOICF linker setting, so Windows builds made with Visual
Studio 2022 keep wrap_binaryfunc and wrap_binaryfunc_l distinct.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ezequielp-activestate ezequielp-activestate left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. This is a clean backport and the diagnosis holds up.

  • 38f8e73 is upstream b4af629 (bpo-42825, pythonGH-24098) with the same one-line PCbuild/pyproject.props change, character for character. Upstream's commit message names the same two functions (wrap_binaryfunc / wrap_binaryfunc_l).
  • upstream/3.10 still carries /OPT:REF,NOICF today. Upstream only added /CGTHREADS:1 /PDBTHREADS:1 later for reproducible builds, which isn't needed for this fix.
  • pythoncore.vcxproj imports pyproject.props, so the DLL that contains typeobject.c gets the flag. Nothing else in PCbuild sets EnableCOMDATFolding or another /OPT: value that would override it.
  • The flag applies only to non-Debug builds, which is where ICF is on.
  • The version bump has the same shape as the 3.9.25.2 one: PY_VERSION plus a whatsnew section.

I couldn't build on Windows here, so the behavior check relies on your before/after table. A useful check after the rebuild: class I(int): pass; I(1) + "s" raises TypeError and test_datetime passes.

@icanhasmath
icanhasmath merged commit 15f475f into 3.9.25.x Oct 29, 2026
20 checks passed
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.

3 participants