[reportlab-users] format error? Boy is that confusing!
Glenn Linderman
v+python at g.nevcal.com
Tue May 5 17:44:58 EDT 2015
I changed some code that was generating URLs to feed to <a> tags in a
Paragraph flowable. I goofed... I left the URL relative instead of
making it absolute. This resulted in a nearly unintelligible error,
although because I knew the code I had changed, I didn't spend too long
battling with the bizarre symptom before I went back to see what was
different about what I was producing now, versus what I had been
producing before, and then quickly figured out the problem.
What makes this stack trace so unintelligible, is that it says "format
not resolved" and then shows a relative URL. It makes it seem like it
is trying to interpret the URL as a format code (of some unknown sort),
and my thoughts immediately went to the possibility of having omitted
the format code parameter, and supplied the URL as the wrong parameter,
somewhere along the line, and of course doc.build has so many deferred
operations that there is little clue as to where in the document this
actually takes place.
It would be extremely more useful to for the message to say something
like "URL scheme missing" or "unknown scheme" using the terminology for
URLs. If, at the point of error generation, it truly is not known, and
cannot easily be known, whether this is a "format" (whatever that means)
or a URL (which is missing its scheme), then having the message say
"format unresolved or URL scheme missing" would certain be an
improvement in clarity at little expense of reworking the code (just
changing a message).
Personally, I have no clue what other cases would cause the message,
that would make "format not resolved" a useful message, but I'm making
the assumption that such a case exists.
Here's an abbreviated stack trace:
doc.build( self.elements )
File
"C:\Python34\lib\site-packages\reportlab\platypus\doctemplate.py", line
916, in build
self._endBuild()
File
"C:\Python34\lib\site-packages\reportlab\platypus\doctemplate.py", line
858, in _endBuild
if getattr(self,'_doSave',1): self.canv.save()
File "C:\Python34\lib\site-packages\reportlab\pdfgen\canvas.py", line
1209, in save
self._doc.SaveToFile(self._filename, self)
File "C:\Python34\lib\site-packages\reportlab\pdfbase\pdfdoc.py",
line 217, in SaveToFile
data = self.GetPDFData(canvas)
File "C:\Python34\lib\site-packages\reportlab\pdfbase\pdfdoc.py",
line 242, in GetPDFData
return self.format()
File "C:\Python34\lib\site-packages\reportlab\pdfbase\pdfdoc.py",
line 421, in format
IOf = IO.format(self)
File "C:\Python34\lib\site-packages\reportlab\pdfbase\pdfdoc.py",
line 864, in format
fcontent = format(self.content, document, toplevel=1) # yes this
is at top level
File "C:\Python34\lib\site-packages\reportlab\pdfbase\pdfdoc.py",
line 78, in format
f = element.format(document)
File "C:\Python34\lib\site-packages\reportlab\pdfbase\pdfdoc.py",
line 1595, in format
return D.format(document)
File "C:\Python34\lib\site-packages\reportlab\pdfbase\pdfdoc.py",
line 671, in format
L = [(format(PDFName(k),document)+b" "+format(dict[k],document))
for k in keys]
File "C:\Python34\lib\site-packages\reportlab\pdfbase\pdfdoc.py",
line 671, in <listcomp>
L = [(format(PDFName(k),document)+b" "+format(dict[k],document))
for k in keys]
File "C:\Python34\lib\site-packages\reportlab\pdfbase\pdfdoc.py",
line 78, in format
f = element.format(document)
File "C:\Python34\lib\site-packages\reportlab\pdfbase\pdfdoc.py",
line 1771, in format
if f is None: raise ValueError("format not resolved %s" % self.name)
ValueError: format not resolved ../../hc/foo.png
Errorlevel 1 from bixutls.py. Exiting.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20150505/9e6fcfc3/attachment.html>
More information about the reportlab-users
mailing list