You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid errors indexing binary uploads with Python 3.
If you upload a binary file for a FileClass whose content property is
set to be indexed (the default), an error of the form "'utf-8' codec
can't decode byte 0x89 in position 0: invalid start byte" can occur
when the code attempts to index the content of that file. (This error
is after the creation of the file, and any issue etc. created at the
same time, has been committed; the page returned gives the impression
that the creation failed, but that's not the case.)
The indexing itself only happens for text/plain files, but that check
is in the indexers themselves, after this error occurs (and it's
entirely possible that a text/plain upload could actually have some
binary or non-UTF-8 content). bytes objects for the binary contents
get converted to str, with resulting errors when they are not in fact
UTF-8 text. This patch makes the places that might try indexing
binary content do the conversion to strings, for Python 3, with
errors='ignore', so that at least no such exception occurs (and if the
file is not text/plain, the results of the conversion will then get
discarded in the indexers).
0 commit comments