From d880ea2a9cf43a8098ebf3e4db3e1aeeceb46837 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 4 Dec 2019 15:45:13 +0530 Subject: [PATCH] py3 compat for the recycle bin process --- src/calibre/utils/recycle_bin.py | 3 ++- src/calibre/utils/windows/winutilpp.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/recycle_bin.py b/src/calibre/utils/recycle_bin.py index 923a51920f..7f505b49d9 100644 --- a/src/calibre/utils/recycle_bin.py +++ b/src/calibre/utils/recycle_bin.py @@ -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, diff --git a/src/calibre/utils/windows/winutilpp.cpp b/src/calibre/utils/windows/winutilpp.cpp index ed24d642ee..13ee781da2 100644 --- a/src/calibre/utils/windows/winutilpp.cpp +++ b/src/calibre/utils/windows/winutilpp.cpp @@ -206,7 +206,7 @@ winutil_move_to_trash(PyObject *self, PyObject *args) { CComPtr 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; }