Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#7727 closed (fixed)

Obscure failure if PIL is not there

Reported by: fijal Owned by: nobody
Component: Forms Version: master
Severity: Keywords:
Cc: fijall@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


model_forms tests fail with obscure doctest errors when PIL is not there. Instead of saying "PIL not here" it will happily explode
on you with "expected True got False". I'm not sure what's the way to skip doctests, but this is troublesome even for someone who does not run tests.

Change History (6)

comment:1 Changed 7 years ago by fijal

  • Cc fijall@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by russellm

  • Triage Stage changed from Unreviewed to Accepted

The way to skip doctests is to break the sensitive doctest string into a separate string, and only concatenate the extra string onto the actual test string if PIL is available. The fixtures modeltest gives an example for a doctest that doesn't run under MySQL; an analogous approach should work for PIL.

comment:3 Changed 7 years ago by russellm

  • milestone set to 1.0 beta
  • Resolution set to worksforme
  • Status changed from new to closed

When I disable PIL, I don't get any failures. Looking at the code, if PIL is missing, the test should revert to a simple FileField test. Can you clarify (1) which test is failing, and (2) what other test conditions could be causing the failure.

comment:4 Changed 7 years ago by fijal

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Wrong specification. If PIL is there, but _imaging is not there. This is the case ie. on top of pypy, where pure python module can be imported, but C extension cannot. It raises ImportError, but newforms/ catches all exceptions and raises ValidationErrors instead of reporting correctly that PIL is broken.

comment:5 Changed 7 years ago by russellm

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [8016]) Fixed #7727 -- Improved the checks for import failure when using PIL. Under PyPy, you can import the PIL module, but when you try to use it, the underlying _imaging module will not be available. Thanks to Maciej Fijalkowski (fijal) for the report and suggested fix.

comment:6 Changed 4 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

Note: See TracTickets for help on using tickets.
Back to Top