Mercurial > p > roundup > code
comparison roundup/cgi/engine_zopetal.py @ 7999:310e19beba3e
fix: report filename if template file is invalid
A file name like .#issue.search.html causes a crash because _find
returns None not a tuple and unpacking fails.
Trap the TypeError and raise ValueError with message that includes the
basename of the file.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 26 May 2024 11:14:10 -0400 |
| parents | b8e63e65d9a8 |
| children | dff6d2edc52f |
comparison
equal
deleted
inserted
replaced
| 7998:851ddd72f9ce | 7999:310e19beba3e |
|---|---|
| 20 def __init__(self, template_dir): | 20 def __init__(self, template_dir): |
| 21 self.template_dir = template_dir | 21 self.template_dir = template_dir |
| 22 | 22 |
| 23 def load(self, tplname): | 23 def load(self, tplname): |
| 24 # find the source | 24 # find the source |
| 25 src, filename = self._find(tplname) | 25 try: |
| 26 src, filename = self._find(tplname) | |
| 27 except TypeError as e: | |
| 28 raise ValueError("Unable to load template file basename: %s: %s" % ( | |
| 29 tplname, e)) | |
| 26 | 30 |
| 27 # has it changed? | 31 # has it changed? |
| 28 try: | 32 try: |
| 29 stime = os.stat(src)[os.path.stat.ST_MTIME] | 33 stime = os.stat(src)[os.path.stat.ST_MTIME] |
| 30 except os.error as error: | 34 except os.error as error: |
