diff --git a/modules/send2trash_osx.c b/modules/send2trash_osx.c index c995f2c..197c5d3 100644 --- a/modules/send2trash_osx.c +++ b/modules/send2trash_osx.c @@ -34,12 +34,25 @@ static PyMethodDef TrashMethods[] = { {NULL, NULL, 0, NULL} }; -PyMODINIT_FUNC -init_send2trash_osx(void) +static struct PyModuleDef TrashDef = { + PyModuleDef_HEAD_INIT, + "send2trash_osx", + NULL, + -1, + TrashMethods, + NULL, + NULL, + NULL, + NULL +}; + +PyObject * +PyInit_send2trash_osx(void) { - PyObject *m = Py_InitModule("_send2trash_osx", TrashMethods); + PyObject *m = PyModule_Create(&TrashDef); if (m == NULL) { - return; + return NULL; } + return m; } diff --git a/modules/send2trash_win.c b/modules/send2trash_win.c index e3ca11a..c9e8a31 100644 --- a/modules/send2trash_win.c +++ b/modules/send2trash_win.c @@ -58,11 +58,24 @@ static PyMethodDef TrashMethods[] = { {NULL, NULL, 0, NULL} }; -PyMODINIT_FUNC -init_send2trash_win(void) +static struct PyModuleDef TrashDef = { + PyModuleDef_HEAD_INIT, + "send2trash_win", + NULL, + -1, + TrashMethods, + NULL, + NULL, + NULL, + NULL +}; + +PyObject * +PyInit_send2trash_win(void) { - PyObject *m = Py_InitModule("_send2trash_win", TrashMethods); + PyObject *m = PyModule_Create(&TrashDef); if (m == NULL) { - return; + return NULL; } + return m; } \ No newline at end of file diff --git a/send2trash/__init__.py b/send2trash/__init__.py index 9457f4a..d6fa7f0 100644 --- a/send2trash/__init__.py +++ b/send2trash/__init__.py @@ -7,8 +7,8 @@ import sys if sys.platform == 'darwin': - from plat_osx import send2trash + from .plat_osx import send2trash elif sys.platform == 'win32': - from plat_win import send2trash + from .plat_win import send2trash else: - from plat_other import send2trash + from .plat_other import send2trash diff --git a/send2trash/plat_osx.py b/send2trash/plat_osx.py index 3b99f4f..aed6667 100644 --- a/send2trash/plat_osx.py +++ b/send2trash/plat_osx.py @@ -4,9 +4,9 @@ # which should be included with this package. The terms are also available at # http://www.hardcoded.net/licenses/bsd_license -import _send2trash_osx +import send2trash_osx def send2trash(path): - if not isinstance(path, unicode): - path = unicode(path, 'utf-8') - _send2trash_osx.send(path) + if not isinstance(path, str): + path = str(path, 'utf-8') + send2trash_osx.send(path) diff --git a/send2trash/plat_other.py b/send2trash/plat_other.py index d9375a6..70959a5 100644 --- a/send2trash/plat_other.py +++ b/send2trash/plat_other.py @@ -4,7 +4,7 @@ # which should be included with this package. The terms are also available at # http://www.hardcoded.net/licenses/bsd_license -from __future__ import unicode_literals + import sys import os import os.path as op @@ -60,8 +60,8 @@ def move_without_conflict(src, dst): os.rename(src, destpath) def send2trash(path): - if not isinstance(path, unicode): - path = unicode(path, sys.getfilesystemencoding()) + if not isinstance(path, str): + path = str(path, sys.getfilesystemencoding()) try: move_without_conflict(path, TRASH_PATH) except OSError: diff --git a/send2trash/plat_win.py b/send2trash/plat_win.py index 3aada5f..5f1a4d6 100644 --- a/send2trash/plat_win.py +++ b/send2trash/plat_win.py @@ -5,11 +5,11 @@ # http://www.hardcoded.net/licenses/bsd_license import os.path as op -import _send2trash_win +import send2trash_win def send2trash(path): - if not isinstance(path, unicode): - path = unicode(path, 'mbcs') + if not isinstance(path, str): + path = str(path, 'mbcs') if not op.isabs(path): path = op.abspath(path) - _send2trash_win.send(path) + send2trash_win.send(path) diff --git a/setup.py b/setup.py index 18740b8..e992080 100644 --- a/setup.py +++ b/setup.py @@ -8,13 +8,13 @@ exts = [] if sys.platform == 'darwin': exts.append(Extension( - '_send2trash_osx', + 'send2trash_osx', [op.join('modules', 'send2trash_osx.c')], extra_link_args=['-framework', 'CoreServices'], )) if sys.platform == 'win32': exts.append(Extension( - '_send2trash_win', + 'send2trash_win', [op.join('modules', 'send2trash_win.c')], extra_link_args = ['shell32.lib'], )) @@ -26,14 +26,14 @@ CLASSIFIERS = [ 'Operating System :: MacOS :: MacOS X', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', - 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', 'Programming Language :: Objective C', 'Programming Language :: C', 'Topic :: Desktop Environment :: File Managers', ] setup( - name='Send2Trash', + name='Send2Trash3k', version='1.0.1', author='Hardcoded Software', author_email='hsoft@hardcoded.net',