Merge lp:~sinzui/launchpad/field-errors-0 into lp:launchpad
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Graham Binns | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 12345 | ||||
Proposed branch: | lp:~sinzui/launchpad/field-errors-0 | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
543 lines (+128/-228) 3 files modified
lib/lp/app/widgets/doc/image-widget.txt (+95/-227) lib/lp/services/fields/__init__.py (+1/-1) lib/lp/services/fields/tests/test_fields.py (+32/-0) |
||||
To merge this branch: | bzr merge lp:~sinzui/launchpad/field-errors-0 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Graham Binns (community) | code | Approve | |
Review via email: mp+48800@code.launchpad.net |
Description of the change
Catch the ValueError while validating image file
Launchpad bug: https:/
Pre-
Test command: ./bin/test -vv \
-t test_fields -t image-widget
Usually when the PIL can't identify an image type, it raises a IOError, but
it might raise a "ValueError: cannot read this XPM file" when uploading a
broken XPM file. The existing LaunchpadValida
but it is not being raised because ValueError was not expected.
-------
RULES
* Reproduce an XPM fragment that raises the ValueError.
* Add ValueError to the except clause.
QA
* Upload the abcardwindow.xpm file attached to the bug.
* Verify the form explain that the image was not recognised.
LINT
lib/
lib/
lib/
./lib/lp/
1: narrative uses a moin header.
36: narrative uses a moin header.
77: source exceeds 78 characters.
233: narrative exceeds 78 characters.
250: narrative uses a moin header.
314: narrative exceeds 78 characters.
317: narrative exceeds 78 characters.
358: narrative uses a moin header.
421: narrative exceeds 78 characters.
476: narrative uses a moin header.
./lib/lp/
350: E302 expected 2 blank lines, found 1
^ I will fix this before I land the branch. I do not want to clutter the
diff.
IMPLEMENTATION
Converted the existing BaseImageUpload IOError doctest into a unittest.
lib/
lib/
Reproduced the ValueError using a corrupt XPM and added the ValueError to
the exception.
lib/
lib/