Edgewall Software

Opened 12 years ago

Last modified 7 years ago

#485 reopened defect

Spurious TemplateNotFound errors in App Engine caused by invalid 'rbU' file mode in TemplateLoader.directory

Reported by: Erik Swanson <erik.swanson@…> Owned by: cmlenz
Priority: major Milestone: 0.9
Component: General Version: devel
Keywords: appengine Cc:

Description

In TemplateLoader?.directory, the file mode 'rbU' is specified, which is invalid. ('U' has no effect when a file is opened in binary mode 'b'.)

This is a showstopper In the App Engine environment (I'm using Python 2.7), where attempting to open a file with this mode results in "IOError: invalid mode: rbU" being raised.

This IoError? is then incorrectly handled by TemplateLoader?.load in the 'for loadfunc in search_path:' where there is a blind 'except IOError:' that suppresses it.

The result that 'raise TemplateNotFound?(filename, search_path)' is reached even when the template exists.

Attachments (2)

TemplateLoader-use-valid-file-mode.patch (502 bytes) - added by Erik Swanson <erik.swanson@…> 12 years ago.
Use the original file mode 'rU' instead of the invalid 'rbU'.
template-encoding-bugfix.diff (6.1 KB) - added by hodgestar 12 years ago.
Invasive patch that opens files loaded via the template loader as unicode. Undecided whether this is a good approach.

Download all attachments as: .zip

Change History (5)

Changed 12 years ago by Erik Swanson <erik.swanson@…>

Use the original file mode 'rU' instead of the invalid 'rbU'.

comment:1 Changed 12 years ago by hodgestar

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

Fix committed to trunk in r1180 (it didn't appear to affect 0.6.x where both the 'r' and 'b' where not present). Thanks for our bug report and patch.

comment:2 Changed 12 years ago by hodgestar

  • Resolution fixed deleted
  • Status changed from closed to reopened

It looks like the 'b' was important. Without it the file is automatically decoded under Python 3.2 and reading the file fails if the wrong encoding is guessed. Maybe a better idea is to drop the 'U'? An alternative is to pass the encoding to codecs.open but that is a more invasive change.

Changed 12 years ago by hodgestar

Invasive patch that opens files loaded via the template loader as unicode. Undecided whether this is a good approach.

comment:3 Changed 7 years ago by hodgestar

  • Milestone changed from 0.7 to 0.9

Moved to milestone 0.9.

Note: See TracTickets for help on using tickets.