pypy3.6: `os.replace(..., pathlike)`: TypeError: 'PosixPath' does not support the buffer interface

Create issue
Issue #2985 resolved
Anthony Sottile created an issue

sample script

import os
import pathlib

open('a', 'a+').close()
os.replace('a', pathlib.Path('b'))

pypy output

$ ./pypy3.6-v7.1.0-linux64/bin/pypy3 --version
Python 3.6.1 (de061d87e39c, Mar 24 2019, 22:18:07)
[PyPy 7.1.0-beta0 with GCC 6.2.0 20160901]
$ ./pypy3.6-v7.1.0-linux64/bin/pypy3 x.py 
Traceback (most recent call last):
  File "x.py", line 5, in <module>
    os.replace('a', pathlib.Path('b'))
TypeError: 'PosixPath' does not support the buffer interface

cpython output

$ python3.6 --version --version
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0]
$ python3.6 x.py 
$

misc

this was noticed while attempting to use https://github.com/ambv/black using pypy3.6

guess

my guess is this hasn't been updated from the changes in python3.6 as the error message matches exactly what is happening on pypy3.5:

$ pypy3 --version
Python 3.5.3 (fdd60ed87e94, Apr 24 2018, 06:10:04)
[PyPy 6.0.0 with GCC 6.2.0 20160901]
$ pypy3 x.py 
Traceback (most recent call last):
  File "x.py", line 5, in <module>
    os.replace('a', pathlib.Path('b'))
TypeError: 'PosixPath' does not support the buffer interface

$ python3.5 --version --version
Python 3.5.7
$ python3.5 x.py 
Traceback (most recent call last):
  File "x.py", line 5, in <module>
    os.replace('a', pathlib.Path('b'))
TypeError: replace: illegal type for dst parameter

Comments (10)

  1. John Hagen

    Can confirm this exists on the macOS release as well.

    $ pypy3 --version
    Python 3.6.1 (de061d87e39c, Mar 24 2019, 22:18:21)
    [PyPy 7.1.0-beta0 with GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)]
    

    The important lines:

    media_root = Path(__file__).parent.resolve(strict=True)
    shutil.rmtree(media_folder)
    
    $ pypy3 main.py
    Traceback (most recent call last):
      File "main.py", line 70, in <module>
        main()
      File "main.py", line 59, in main
        shutil.rmtree(media_folder)
      File "/Users/user/install/pypy3.6-v7.1.0-osx64/lib-python/3/shutil.py", line 476, in rmtree
        onerror(os.lstat, path, sys.exc_info())
      File "/Users/user/install/pypy3.6-v7.1.0-osx64/lib-python/3/shutil.py", line 474, in rmtree
        fd = os.open(path, os.O_RDONLY)
    TypeError: 'PosixPath' does not support the buffer interface
    
  2. John Hagen

    EDIT: I was mistaken, the shutil.rmtree(media_folder) where a Path is passed in is not fixed as of 7.1.1.

    _______________________________________________

    The instance I reported has been fixed in:

    $ pypy3 --version
    Python 3.6.1 (784b254d6699, Apr 14 2019, 10:22:55)
    [PyPy 7.1.1-beta0 with GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)]
    
  3. John Hagen

    @mattip Any ETA on a release with this fix?

    I’ve seen this crop up and affect several packages that are Python 3.6+ only for which I’m trying to add PyPy3 CI support in.

    For example, black cannot run under PyPy3 because of this issue. In fact, a good test for this would be to run black from pypy3.6 and try to format a large project to see if TypeError: 'PosixPath' does not support the buffer interface error pops up.

  4. Carl Friedrich Bolz-Tereick

    This is fixed in the nightlies. The fix should be in the 7.2 release. We just started the release process today.

  5. Log in to comment