Skip to content
Myr

Do not error for unknown files if send_file sends an actual file

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent c54c538 · Browse files · 2 files+3 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+3 added−4 removed

  • tests:+1 added−3 removed
  • other:+2 added−1 removed

2 files+3 added−4 removed

modified:flask/helpers.py+2 added-1 removed
511 unmodified lines
512 filename = None513514 if mimetype is None:515 if attachment_filename is not None:516 mimetype = mimetypes.guess_type(attachment_filename)[0]516 mimetype = mimetypes.guess_type(attachment_filename)[0] \517 or 'application/octet-stream'518519 if mimetype is None:520 if attachment_filename is not None:521 raise ValueError(
426 unmodified lines
modified:tests/test_helpers.py+1 added-3 removed
400 unmodified lines
401 assert 'Unable to infer MIME-type' in str(excinfo)402 assert 'no filename is available' in str(excinfo)403404 with app.test_request_context():405 with pytest.raises(ValueError) as excinfo:406 flask.send_file(StringIO("LOL"), attachment_filename='filename')405 flask.send_file(StringIO("LOL"), attachment_filename='filename')407 assert "Unable to infer MIME-type from filename 'filename'" in str(excinfo)406407 def test_send_file_object(self):408 app = flask.Flask(__name__)409
411 unmodified lines