Skip to content

oschmod does not work with pathlib.Path in Windows #111

@zapplecat

Description

@zapplecat

Describe the bug

The pathlib works with oschmod on OSX and Linux pathlib.Path, but on Windows, we get TypeError: Objects of type 'WindowsPath' can not be converted to Unicode.

Your configuration

Windows 8.1, Python 3.9.6

Steps to reproduce

Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import oschmod
>>> import pathlib
>>> p = pathlib.Path('E:/Projects/test.txt')
>>> oschmod.get_mode(p)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\Projects\oschmod_venv\lib\site-packages\oschmod\__init__.py", line 163, in get_mode
    return win_get_permissions(path)
  File "E:\Projects\oschmod_venv\lib\site-packages\oschmod\__init__.py", line 364, in win_get_permissions
    return _win_get_permissions(path, get_object_type(path))
  File "E:\Projects\oschmod_venv\lib\site-packages\oschmod\__init__.py", line 376, in _win_get_permissions
    sec_des = win32security.GetNamedSecurityInfo(
TypeError: Objects of type 'WindowsPath' can not be converted to Unicode.
>>> oschmod.get_mode('E:/Projects/test.txt')
7

Expected behavior
pathlib.Path works with oschmod operations

What happened instead
pathlib.Path with oschmod operations fails with TypeError

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions