#------------------------------------------------------------------------------

cdef extern from "Python.h":
    object PyOS_FSPath(object)

cdef os_fsencode
from os import fsencode as os_fsencode

cdef object asmpifspath(object path, char *p[]):
    path = PyOS_FSPath(path)
    path = os_fsencode(path)
    PyBytes_AsStringAndSize(path, p, NULL)
    return path

#------------------------------------------------------------------------------

#------------------------------------------------------------------------------

cdef extern from "Python.h":
    object PyOS_FSPath(object)
    object PyUnicode_EncodeFSDefault(object)


cdef object asmpifspath(object path, char *p[]):
    path = PyOS_FSPath(path)
    if PyUnicode_Check(path):
        path = PyUnicode_EncodeFSDefault(path)
    PyBytes_AsStringAndSize(path, p, NULL)
    return path

#------------------------------------------------------------------------------

Use PyUnicode_EncodeFSDefault() to encode unicode paths
File: Use PyUnicode_EncodeFSDefault() to encode unicode paths
