#83 pywin32 for PyPy


I've just managed to make pywin32 compile and work on top of PyPy.
I open this ticket to keep track of the various changes that I made to the pywin32 source code.
I'm currently preparing patches; for the moment, changes are of two kinds:

- In some .cpp files you can find "if PyString_Check(xxx)" without surrounding parentheses. This works on CPython because PyString_Check is actually a macro which adds parentheses to its expression; with PyPy PyString_Check is a function.

- With PyPy it's not allowed to change ob_type after object creation. This is used a lot by all PyIBase subclasses. The solution I found is to pass the TypeObject to the base constructor, and ensure that ob_type is set just before calling _Py_NewReference(). Of course these two lines can be replaced by "PyObject_Init(this, type);"


  • Mark Hammond
    Mark Hammond

    Sounds great to me. Use of PyObject_Init sounds good too so long as it also works in earlier Python version (I seem to recall that function was added in later versions).

  • PyObject_Init is already present in Python2.2

  • Thibault Hild
    Thibault Hild

    What is the current status of pypy compatibility ?
    Is the work done by Amaury on https://bitbucket.org/amauryfa/pywin32-pypy going to be merged back in the pywin32 project ?

  • Matti Picus
    Matti Picus

    How can I help get this merged into default pywin32 ?

  • Mark Hammond
    Mark Hammond

    I guess you could contact Amaury and see if he needs any help to get patches together for review - from my POV, I'm just waiting for those patches.

  • mabel

    Can you please share how to install pywin32 for pypy? Here is the screen shot of error message.
    I appreciate your help

    • Hi,
      Sorry I don't have any Windows machine anymore. But from the messages it seems that you did not install the Microsoft Windows SDK.