py3 compat for the recycle bin process

This commit is contained in:
Kovid Goyal 2019-12-04 15:45:13 +05:30
parent 860bcf0088
commit d880ea2a9c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 2 deletions

View File

@ -60,7 +60,8 @@ if iswindows:
raise ValueError('Cannot recycle paths that have newlines in them (%r)' % path)
with rlock:
start_recycler()
eintr_retry_call(print, path.encode('utf-8'), file=recycler.stdin)
recycler.stdin.write(path.encode('utf-8'))
recycler.stdin.write(b'\n')
recycler.stdin.flush()
# Theoretically this could be made non-blocking using a
# thread+queue, however the original implementation was blocking,

View File

@ -206,7 +206,7 @@ winutil_move_to_trash(PyObject *self, PyObject *args) {
CComPtr<IShellItem> delete_item;
if (FAILED(SHCreateItemFromParsingName(path.ptr(), NULL, IID_PPV_ARGS(&delete_item)))) {
PyErr_SetString(PyExc_OSError, "Failed to create shell item");
PyErr_Format(PyExc_OSError, "Failed to create shell item for path: %R", PyTuple_GET_ITEM(args, 0));
return NULL;
}