pypy ctypes.pythonapi has no symbol Py_FileSystemDefaultEncoding

Bug #918893 reported by Wouter van Heyst
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Martin Packman

Bug Description

The check in bzrlib._patch_filesystem_default_encoding does:

    pythonapi = getattr(ctypes, "pythonapi", None)
    if pythonapi is None:
        # Not CPython ctypes implementation
        return

and if that succeeds it tries:

   old_ptr = ctypes.c_void_p.in_dll(pythonapi, "Py_FileSystemDefaultEncoding")

Unfortunately pypy (since 1.6 at least) passes the check but fails the symbol lookup.

This can be triggered for example in bzrlib.tests.blackbox.test_locale.TestLocale.test_log_C

    Traceback (most recent call last):
      File "app_main.py", line 51, in run_toplevel
      File "/home/larstiq/src/bzr/bzr-pypy/bzr", line 74, in <module>
        import bzrlib
      File "/home/larstiq/src/bzr/bzr-pypy/bzrlib/__init__.py", line 171, in <module>
        _fs_enc = _patch_filesystem_default_encoding(sys._bzr_default_fs_enc)
      File "/home/larstiq/src/bzr/bzr-pypy/bzrlib/__init__.py", line 157, in _patch_filesystem_default_encoding
        old_ptr = ctypes.c_void_p.in_dll(pythonapi, "Py_FileSystemDefaultEncoding")
      File "/home/larstiq/src/pypy-1.7/lib_pypy/_ctypes/basics.py", line 85, in in_dll
        return self.from_address(dll._handle.getaddressindll(name))
    ValueError: No symbol Py_FileSystemDefaultEncoding found in library <None>

I'm not sure what the right approach is here. Can we depend on all CPython instances not raising the ValueError?
Check for known non-CPythons?

Tags: pypy

Related branches

Martin Packman (gz)
Changed in bzr:
assignee: nobody → Martin Packman (gz)
status: Confirmed → In Progress
Martin Packman (gz)
Changed in bzr:
milestone: none → 2.5.0
status: In Progress → Fix Released
Vincent Ladeuil (vila)
Changed in bzr:
milestone: 2.5.0 → 2.5b6
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.