These are chat archives for cherrypy/cherrypy

Dec 2017
Andrew Schamp
Dec 28 2017 01:49

hi everyone. I'm looking into the covercp stuff, as described here:

it's not working, when I try to call serve() as described I get:

cherrypy/lib/", line 377, in serve
    if coverage is None:
UnboundLocalError: local variable 'coverage' referenced before assignment

The relevant source snippit is this:

def serve(path=localFile, port=8080, root=None):
    if coverage is None:
        raise ImportError('The coverage module could not be imported.')
    from coverage import coverage
    cov = coverage(data_file=path)

it seems to me like the from coverage import coverage should come before if converage is None. but perhaps not -- am I missing something about how this should work?

Sviatoslav Sydorenko
Dec 28 2017 23:44
@ingoogni I think not, you may use different callables for that, but move common code into another helper function
Sviatoslav Sydorenko
Dec 28 2017 23:52

@schamp Hi, it's an ancient code nobody looked at for decade, so it's probably outdated. PRs are welcome anyway :)

From code I see that there's a try/except importing required module at the top. Also, the docstring there explains that there should be additional requirement from 2001 found and downloaded.

So it's a good field for refactoring/improvements.