DocstringParser - support python with optimizations on

This commit is contained in:
Moez Bouhlel 2016-08-04 20:53:13 +01:00
parent 743d2dc327
commit c04adb94b2
No known key found for this signature in database
GPG Key ID: 84D8572173659C9D
2 changed files with 16 additions and 1 deletions

View File

@ -300,6 +300,11 @@ def init_log(args):
log.init_log(args)
log.init.debug("Log initialized.")
def check_optimize_flag():
from qutebrowser.utils import log
if sys.flags.optimize >= 2:
log.init.warning("Running on optimize level higher than 1, "
"unexpected behaviors may occur.")
def earlyinit(args):
"""Do all needed early initialization.
@ -327,3 +332,4 @@ def earlyinit(args):
remove_inputhook()
check_libraries(args)
check_ssl_support()
check_optimize_flag()

View File

@ -26,7 +26,7 @@ import os.path
import collections
import qutebrowser
from qutebrowser.utils import usertypes
from qutebrowser.utils import usertypes, log, utils
def is_git_repo():
@ -98,6 +98,15 @@ class DocstringParser:
self.State.arg_inside: self._parse_arg_inside,
self.State.misc: self._skip,
}
if doc is None:
if sys.flags.optimize < 2:
log.commands.warning(
"Function {}() from {} has no docstring".format(
utils.qualname(func),
inspect.getsourcefile(func)))
self.long_desc = ""
self.short_desc = ""
return
for line in doc.splitlines():
handler = handlers[self._state]
stop = handler(line)