Skip to content

fix bug with pathlib - #3360

Merged
jtpavlock merged 3 commits into
beetbox:masterfrom
eljojo:patch-1
Jul 16, 2020
Merged

fix bug with pathlib#3360
jtpavlock merged 3 commits into
beetbox:masterfrom
eljojo:patch-1

Conversation

@eljojo

@eljojo eljojo commented Sep 7, 2019

Copy link
Copy Markdown
Contributor

Hi,

The thumbnails plugin was failing for me. The following patch fixed it.

$ python --version
Python 3.5.7
jojo at jojo-mini in ~/code/beets (master●)
$ beet thumbnails
Traceback (most recent call last):
  File "/Users/jojo/.asdf/installs/python/3.5.7/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
  File "/Users/jojo/.asdf/installs/python/3.5.7/lib/python3.5/site-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/Users/jojo/.asdf/installs/python/3.5.7/lib/python3.5/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/Users/jojo/.asdf/installs/python/3.5.7/lib/python3.5/site-packages/beetsplug/thumbnails.py", line 78, in process_query
    self.process_album(album)
  File "/Users/jojo/.asdf/installs/python/3.5.7/lib/python3.5/site-packages/beetsplug/thumbnails.py", line 133, in process_album
    wrote &= self.make_cover_thumbnail(album, 128, NORMAL_DIR)
  File "/Users/jojo/.asdf/installs/python/3.5.7/lib/python3.5/site-packages/beetsplug/thumbnails.py", line 144, in make_cover_thumbnail
    target = os.path.join(target_dir, self.thumbnail_file_name(album.path))
  File "/Users/jojo/.asdf/installs/python/3.5.7/lib/python3.5/site-packages/beetsplug/thumbnails.py", line 165, in thumbnail_file_name
    uri = self.get_uri(path)
  File "/Users/jojo/.asdf/installs/python/3.5.7/lib/python3.5/site-packages/beetsplug/thumbnails.py", line 227, in uri
    return PurePosixPath(path).as_uri()
  File "/Users/jojo/.asdf/installs/python/3.5.7/lib/python3.5/pathlib.py", line 622, in __new__
    return cls._from_parts(args)
  File "/Users/jojo/.asdf/installs/python/3.5.7/lib/python3.5/pathlib.py", line 651, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/Users/jojo/.asdf/installs/python/3.5.7/lib/python3.5/pathlib.py", line 643, in _parse_args
    % type(a))
TypeError: argument should be a path or str object, not <class 'bytes'>

@sampsyo

sampsyo commented Sep 7, 2019

Copy link
Copy Markdown
Member

Thanks for finding this! Instead of hard-coding a string encoding, however, can you please use our py3_path utility, which represents paths (which beets always represents as bytes internally) as strings for APIs that demand them, as pathlib apparently does?

@eljojo

eljojo commented Sep 8, 2019

Copy link
Copy Markdown
Contributor Author

very interesting! I just updated my PR, but haven't been able to test my changes.

@sampsyo

sampsyo commented Sep 8, 2019

Copy link
Copy Markdown
Member

Awesome; thanks! If you get a chance to try it out and it fixes the problem you were seeing, we can merge this.

@jtpavlock

Copy link
Copy Markdown
Contributor

@eljojo any follow-up to this?

@eljojo

eljojo commented Jul 11, 2020

Copy link
Copy Markdown
Contributor Author

@jtpavlock I don't really remember what ended up happening to this, I think the changes worked?
@sampsyo would either of you be interested in taking over?

@sampsyo

sampsyo commented Jul 11, 2020

Copy link
Copy Markdown
Member

It looks like the right thing to me—let's merge it with a changelog entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants