Skip to content

Commit 1c3d3e1

Browse files
Konstantin Molchanovwaylan
Konstantin Molchanov
authored andcommitted
Fix Python 3.7 and PEP 479 incompatibility
With [PEP 479](https://www.python.org/dev/peps/pep-0479/) implemented in Python 3.7, raised `StopIteration` is now translated into `RuntimeError`, which breaks `mkdocs build` command. The recommended way to exit generators is to use `return` instead of raising `StopIteartion`: https://www.python.org/dev/peps/pep-0479/#id39
1 parent 94bc83b commit 1c3d3e1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mkdocs/nav.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def _follow(config_line, url_context, config, header=None, title=None):
334334
header.children.append(page)
335335

336336
yield page
337-
raise StopIteration
337+
return
338338

339339
elif not isinstance(config_line, dict):
340340
msg = ("Line in 'page' config is of type {0}, dict or string "
@@ -347,15 +347,15 @@ def _follow(config_line, url_context, config, header=None, title=None):
347347
"config contains an invalid entry: {0}".format(config_line))
348348
elif len(config_line) == 0:
349349
log.warning("Ignoring empty line in the pages config.")
350-
raise StopIteration
350+
return
351351

352352
next_cat_or_title, subpages_or_path = next(iter(config_line.items()))
353353

354354
if isinstance(subpages_or_path, utils.string_types):
355355
path = subpages_or_path
356356
for sub in _follow(path, url_context, config, header=header, title=next_cat_or_title):
357357
yield sub
358-
raise StopIteration
358+
return
359359

360360
elif not isinstance(subpages_or_path, list):
361361
msg = ("Line in 'page' config is of type {0}, list or string "

0 commit comments

Comments
 (0)