alfonsodg / demo-web2py

Apache License 2.0
0 stars 0 forks source link

when Web2py bootstraps, an assertion failure always occurs #58

Closed alfonsodg closed 10 years ago

alfonsodg commented 10 years ago

From haima...@gmail.com on October 26, 2009 05:11:20

Just start Web2py and place a breakpoint in gluon/contenttype.py in the function contenttype.

Since the exception is handled, there is no visible effect if you are not debugging. It is harmless but somewhat annoying, particularly while debugging.

It occurs in version 1307 of the svn trunk, but has been there for quite some time. I am working in Ubuntu 9.4 inside VirtualBox under Windows 7.

Original issue: http://code.google.com/p/web2py/issues/detail?id=59

alfonsodg commented 10 years ago

From massimod...@gmail.com on October 26, 2009 06:21:32

Can you say more? Which assertion fails for you?

alfonsodg commented 10 years ago

From haima...@gmail.com on October 26, 2009 06:51:23

the function in question is attached below. it is called from main.py line 403:
response.headers['Content-Type'] = contenttype('.'+request.extension) which passes '.html' to contenttype. If you are not using a debugger you may not notice the exception, because it is handled. May be the code simply uses exceptions where simple logic would do the same thing. If this is the case, I can live with that (WingIDE, the IDE I am using, lets you ignore a particular exception).

def contenttype(filename, default='text/plain'): """ Returns the Content-Type string matching extension of the given filename. """

i = filename.rfind('.')
j = filename.rfind('.', 0, i)
try:
    assert i != -1
    try:
        assert j != -1   ############THIS ASSERTION MUST FAIL################
        return CONTENT_TYPE[filename[j:].lower()]
    except:
        return CONTENT_TYPE[filename[i:].lower()]
except:
    return default
alfonsodg commented 10 years ago

From massimod...@gmail.com on November 28, 2009 20:51:50

This code does not exist any more.

Status: Invalid