Slight reversion to earlier code - checking up on codecs.open(), it turns out that it returns a file object with __enter__ and __exit__ methods, so can be used in a 'with codecs.open(path) as file:' pattern.
- Legacy-Id: 8317
This commit is contained in:
parent
2ff2d79a7e
commit
c276ecac4a
|
@ -3,7 +3,6 @@
|
|||
import codecs
|
||||
import datetime
|
||||
from collections import OrderedDict
|
||||
from contextlib import closing
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import Http404
|
||||
|
@ -141,7 +140,7 @@ def fill_in_agenda_administrivia(date, sections):
|
|||
|
||||
for s, key, filename in extra_info_files:
|
||||
try:
|
||||
with closing(codecs.open(filename, 'r', 'utf-8', 'replace')) as f:
|
||||
with codecs.open(filename, 'r', 'utf-8', 'replace') as f:
|
||||
t = f.read().strip()
|
||||
except IOError:
|
||||
t = u"(Error reading %s)" % filename
|
||||
|
|
Loading…
Reference in a new issue