Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web attachment filenames must be passed as a string for Python 3 #2353

Merged
1 commit merged into from
Dec 29, 2016
Merged

Web attachment filenames must be passed as a string for Python 3 #2353

1 commit merged into from
Dec 29, 2016

Conversation

dopefishh
Copy link
Contributor

This PR fixes the following bug in the web interface

When downloading a file the the following error occurs:

[2016-12-29 11:11:07,039] ERROR in app: Exception on /item/10652/file [GET]
Traceback (most recent call last):
  File "/home/mrl/projects/beets/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/mrl/projects/beets/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/mrl/projects/beets/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/mrl/projects/beets/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/mrl/projects/beets/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/mrl/projects/beets/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/mrl/projects/beets/lib/python3.5/site-packages/beets-1.4.3-py3.5.egg/beetsplug/web/__init__.py", line 209, in item_file
    attachment_filename=os.path.basename(item.path),
  File "/home/mrl/projects/beets/lib/python3.5/site-packages/flask/helpers.py", line 522, in send_file
    mimetype = mimetypes.guess_type(attachment_filename)[0] \
  File "/usr/lib/python3.5/mimetypes.py", line 289, in guess_type
    return _db.guess_type(url, strict)
  File "/usr/lib/python3.5/mimetypes.py", line 114, in guess_type
    scheme, url = urllib.parse.splittype(url)
  File "/usr/lib/python3.5/urllib/parse.py", line 862, in splittype
    match = _typeprog.match(url)
TypeError: cannot use a string pattern on a bytes-like object

When downloading a file the the following error occurs on line 209
`TypeError: cannot use a string pattern on a bytes-like object`
@ghost ghost changed the title Fix web interface str/bytes bug Web attachment filenames must be passed as a string for Python 3 Dec 29, 2016
@ghost ghost merged commit 8bb7036 into beetbox:master Dec 29, 2016
@ghost
Copy link

ghost commented Dec 29, 2016

Thanks! Let us know if you run into more Python 3 related bugs.

@sampsyo
Copy link
Member

sampsyo commented Dec 29, 2016

Good catch. Thanks, both of you!

sampsyo added a commit that referenced this pull request Dec 29, 2016
This pull request was closed.
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.

2 participants