Skip to content

Regenerate pywin32_swig.patch without Python 2 concerns#2694

Merged
Avasam merged 4 commits intomhammond:mainfrom
Avasam:Regenerate-`pywin32_swig.patch`-without-Python-2-concerns
Jan 27, 2026
Merged

Regenerate pywin32_swig.patch without Python 2 concerns#2694
Avasam merged 4 commits intomhammond:mainfrom
Avasam:Regenerate-`pywin32_swig.patch`-without-Python-2-concerns

Conversation

@Avasam
Copy link
Collaborator

@Avasam Avasam commented Dec 11, 2025

  • Replaced MODINIT_ERROR_RETURN macro usages with NULL
  • Fixed patch (trailing spaces are necessary otherwise git considers it "corrupted")
  • Reapplied the patch to swig1.1p5
  • Removed Python 2 codepaths (including the MODINIT_ERROR_RETURN macro) and minimal fix to makefiles for modern MSVC
  • Regenerated the patch file using git bas/MINGW64's diff tool.
  • Mention --ignore-space-change to avoind git thinking "this patch doesn't apply" due to line ending differences

Will reduce changes in #2686

@Avasam Avasam requested a review from mhammond December 11, 2025 05:01
@Avasam Avasam force-pushed the Regenerate-`pywin32_swig.patch`-without-Python-2-concerns branch from addf014 to 1bc88b3 Compare December 11, 2025 05:06
@mhammond
Copy link
Owner

This seems fine, but I guess we are going to want a new executable too? ie, I'm not sure it makes sense to land this if it means the exe and this patch are inconsistent?

@Avasam Avasam force-pushed the Regenerate-`pywin32_swig.patch`-without-Python-2-concerns branch from 1bc88b3 to a4ee61a Compare December 11, 2025 05:17
@mhammond
Copy link
Owner

mhammond commented Dec 11, 2025

right, I see #2686 also wants to modify this. I guess this seems fine if it helps keep that ball rolling (although I wonder how far that ball will actually roll!)

@Avasam
Copy link
Collaborator Author

Avasam commented Dec 11, 2025

We can have a new executable yeah, I see your point. Even though it should work the same.

If you don't wanna bother building a new one now, I could split up this PR into just fixing the patch and tool configs so git stops rejecting it.

Btw I noticed my patch generation had quite a different style, idk if it's because whoever wrote the original patch maybe did it with a different tool than git diff

@mhammond
Copy link
Owner

I suspect that patch predates git? But if you can verify locally the patch applies and makes a new executable which works I'm happy to have this merged

@Avasam
Copy link
Collaborator Author

Avasam commented Dec 11, 2025

Alright, I'll try to build SWIG locally and ensure that it still results in a valid pywin32 build.
I'm off to bed for tonight though.

@Avasam
Copy link
Collaborator Author

Avasam commented Dec 11, 2025

(although I wonder how far that ball will actually roll!)

Me too. There's definitely some good changes from clin's attempt (like the new stable ABI functions for objects type and refcount). So I'll help take it piecemeal.

@Avasam
Copy link
Collaborator Author

Avasam commented Dec 14, 2025

I've had to fix include paths. I quickly did so by replacing INCLUDE with INCFLAGS and remove all STD_INC from make files.

But it did build a new swig.exe which I then used to successfully build pywin32.
I can even confirm that pywin32 fails to build if I build swig without the patch (because of Python 2 code).

Do you want me to include the minimal makefile changes as well ?

Should I include the new swig executable in this PR or did you simply want me to make sure the patch was truly still valid ?

@mhammond
Copy link
Owner

Do you want me to include the minimal makefile changes as well ?

Should I include the new swig executable in this PR or did you simply want me to make sure the patch was truly still valid ?

I think you should include both if you don't mind. I'm not currently in a position to be able to regenerate the executables and you've been here long enough that I trust you to do that :) Thanks!

@Avasam
Copy link
Collaborator Author

Avasam commented Jan 26, 2026

@mhammond Full patches and updated executable included.

Copy link
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

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

Thanks!

@Avasam Avasam merged commit c4f9d25 into mhammond:main Jan 27, 2026
28 checks passed
@Avasam Avasam deleted the Regenerate-`pywin32_swig.patch`-without-Python-2-concerns branch January 27, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants