ironpython2: Pytest doesn't work with IronPython

Apologies if this is something stupid, I don’t have much experience with ctypes. I’m trying to figure out why pytest doesn’t work with a new install of IronPython 2.7.7 and it seems like ctypes.pythonapi is missing some of its API functions. The following is adapted from here:

>>> import ctypes
>>> ctypes.pythonapi.PyString_FromStringAndSize
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files (x86)\IronPython 2.7\Lib\ctypes\__init__.py", line 375, in __getattr__
  File "C:\Program Files (x86)\IronPython 2.7\Lib\ctypes\__init__.py", line 380, in __getitem__
AttributeError: function PyString_FromStringAndSize is not defined

Windows 10, IronPython 2.7.7 (2.7.7.0) on .NET 4.0.30319.42000 (32-bit)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

@EmmanuelTramoy Did a bit of digging and it looks like the issue is essentially the same as https://github.com/IronLanguages/ironpython2/issues/92. The whole file descriptor handling of IronPython is unfortunately somewhat problematic… Was able to get around it by removing the with f: in _pytest\capture.py:

f = TemporaryFile()
with f: # remove this line!
    tmpfile = ...

It then failed with TypeError: data must be str, not bytes somewhere which is likely because str == unicode with IronPython 2.7 (instead of the str == bytes of CPython 2.7).

Perhaps the pytest-ironpython branch you linked above works around some of these issues?

@EmmanuelTramoy Thanks for the feedback.

The RawConfigParser issue is likely the same as https://github.com/IronLanguages/ironpython3/issues/546. I believe you could bypass this by getting rid of the comments in the regex strings of backports\configparser\__init__.py.

Not sure about the I/O operation on closed file issue.