aboutsummaryrefslogtreecommitdiffstats
path: root/beetsplug/extras.py
diff options
context:
space:
mode:
authorWolfgang Müller2022-02-28 20:11:36 +0100
committerWolfgang Müller2022-02-28 20:11:36 +0100
commit0b5d33ba3b0664f298b175cb0a2efd99ed54c942 (patch)
tree93bd79f8a8aecb40b26b8ebc7d400863545e56f3 /beetsplug/extras.py
parentdc021d5e05145c2e25bf0334032ff1c2054cf2ce (diff)
downloadbeets-oriole-0b5d33ba3b0664f298b175cb0a2efd99ed54c942.tar.gz
extras: Decode paths before handing them to shutil.move0.1.0
Even though the python 3.9 documentation for shutil.move [1] states that "[..] a path-like object for both src and dst" is accepted, it does not in fact support bytes as arguments. This is because shutil.move calls _dstinsrc [2] which tries to compare bytes with str via str.endswith. Python seems to be aware of this [3], but has not yet fixed any of these problems. For now just decode both bytes objects so shutil.move works. [1] https://docs.python.org/3.9/library/shutil.html?highlight=shutil%20move#shutil.move [2] https://github.com/python/cpython/blob/a58ebcc701dd6c43630df941481475ff0f615a81/Lib/shutil.py#L829-L836 [3] https://bugs.python.org/issue46727
Diffstat (limited to 'beetsplug/extras.py')
-rw-r--r--beetsplug/extras.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/beetsplug/extras.py b/beetsplug/extras.py
index e731b6e..8227064 100644
--- a/beetsplug/extras.py
+++ b/beetsplug/extras.py
@@ -11,7 +11,9 @@ class ExtrasPlugin(beets.plugins.BeetsPlugin):
def on_item_moved(self, item, source, destination):
for (sourcepath, destpath) in self.gather(source, destination):
- shutil.move(sourcepath, destpath)
+ # need to decode to str here as shutil.move (still) breaks on bytes
+ # arguments because of _destinsrc using str.endswith
+ shutil.move(sourcepath.decode(), destpath.decode())
def on_item_copied(self, item, source, destination):
for (sourcepath, destpath) in self.gather(source, destination):