{"action":"opened","issue":{"url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/2295","repository_url":"https://api.github.com/repos/sphinx-doc/sphinx","labels_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/2295/labels{/name}","comments_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/2295/comments","events_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/2295/events","html_url":"https://github.com/sphinx-doc/sphinx/issues/2295","id":131423600,"number":2295,"title":"RuntimeError: dictionary changed size during iteration while building with autodoc.py","user":{"login":"NucleaPeon","id":1475151,"avatar_url":"https://avatars.githubusercontent.com/u/1475151?v=3","gravatar_id":"","url":"https://api.github.com/users/NucleaPeon","html_url":"https://github.com/NucleaPeon","followers_url":"https://api.github.com/users/NucleaPeon/followers","following_url":"https://api.github.com/users/NucleaPeon/following{/other_user}","gists_url":"https://api.github.com/users/NucleaPeon/gists{/gist_id}","starred_url":"https://api.github.com/users/NucleaPeon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NucleaPeon/subscriptions","organizations_url":"https://api.github.com/users/NucleaPeon/orgs","repos_url":"https://api.github.com/users/NucleaPeon/repos","events_url":"https://api.github.com/users/NucleaPeon/events{/privacy}","received_events_url":"https://api.github.com/users/NucleaPeon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-04T17:51:26Z","updated_at":"2016-02-04T17:51:26Z","closed_at":null,"body":"I encountered a RuntimeError while building python documentation due to the directory size changing while I built the files.\r\n\r\nTraceback:\r\n\r\n    # Sphinx version: 1.3.5\r\n    # Python version: 3.4.3 (CPython)\r\n    # Docutils version: 0.12 release\r\n    # Jinja2 version: 2.8\r\n    # Last messages:\r\n    ... \r\n    # Loaded extensions:\r\n    #   sphinx.ext.autodoc (1.3.5) from /media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/autodoc.py\r\n    #   sphinx.ext.todo (1.3.5) from /media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/todo.py\r\n    #   sphinx.ext.intersphinx (1.3.5) from /media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/intersphinx.py\r\n    #   alabaster (0.7.7) from /media/dann/external/app.docs/venv/lib/python3.4/site-packages/alabaster/__init__.py\r\n    Traceback (most recent call last):\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/cmdline.py\", line 244, in main\r\n        app.build(opts.force_all, filenames)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/application.py\", line 266, in build\r\n        self.builder.build_update()\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/builders/__init__.py\", line 251, in build_update\r\n        'out of date' % len(to_build))\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/builders/__init__.py\", line 265, in build\r\n        self.doctreedir, self.app))\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/environment.py\", line 618, in update\r\n        self._read_serial(docnames, app)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/environment.py\", line 638, in _read_serial\r\n        self.read_doc(docname, app)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/environment.py\", line 791, in read_doc\r\n        pub.publish()\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/core.py\", line 217, in publish\r\n        self.settings)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/environment.py\", line 128, in read\r\n        self.parse()\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/readers/__init__.py\", line 78, in parse\r\n        self.parser.parse(self.input, document)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/__init__.py\", line 172, in parse\r\n        self.statemachine.run(inputlines, document, inliner=self.inliner)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/states.py\", line 170, in run\r\n        input_source=document['source'])\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/statemachine.py\", line 239, in run\r\n        context, state, transitions)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/statemachine.py\", line 460, in check_line\r\n        return method(match, context, next_state)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/states.py\", line 2726, in underline\r\n        self.section(title, source, style, lineno - 1, messages)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/states.py\", line 327, in section\r\n        self.new_subsection(title, lineno, messages)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/states.py\", line 395, in new_subsection\r\n        node=section_node, match_titles=True)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/states.py\", line 282, in nested_parse\r\n        node=node, match_titles=match_titles)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/states.py\", line 195, in run\r\n        results = StateMachineWS.run(self, input_lines, input_offset)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/statemachine.py\", line 239, in run\r\n        context, state, transitions)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/statemachine.py\", line 460, in check_line\r\n        return method(match, context, next_state)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/states.py\", line 2299, in explicit_markup\r\n        nodelist, blank_finish = self.explicit_construct(match)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/states.py\", line 2311, in explicit_construct\r\n        return method(self, expmatch)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/states.py\", line 2054, in directive\r\n        directive_class, match, type_name, option_presets)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/docutils/parsers/rst/states.py\", line 2103, in run_directive\r\n        result = directive_instance.run()\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/autodoc.py\", line 1469, in run\r\n        documenter.generate(more_content=self.content)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/autodoc.py\", line 828, in generate\r\n        self.document_members(all_members)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/autodoc.py\", line 750, in document_members\r\n        check_module=members_check_module and not isattr)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/autodoc.py\", line 828, in generate\r\n        self.document_members(all_members)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/autodoc.py\", line 1194, in document_members\r\n        ModuleLevelDocumenter.document_members(self, all_members)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/autodoc.py\", line 709, in document_members\r\n        members_check_module, members = self.get_object_members(want_all)\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/autodoc.py\", line 609, in get_object_members\r\n        for mname in obj_dict.keys()]\r\n      File \"/media/dann/external/app.docs/venv/lib/python3.4/site-packages/sphinx/ext/autodoc.py\", line 608, in <listcomp>\r\n        members = [(mname, self.get_attr(self.object, mname, None))\r\n    RuntimeError: dictionary changed size during iteration\r\n\r\n\r\nThe command I was using to generate the documentation was this:\r\n\r\n    sphinx-apidoc -T -e -P -o db app.db/mymodule/\r\n\r\nThe fix was to modify line `609` in `venv/lib/python3.4/site-packages/sphinx/ext/autodoc.py`:\r\n\r\n    members = [(mname, self.get_attr(self.object, mname, None))\r\n        for mname in obj_dict.keys()]\r\n\r\n**became:**\r\n\r\n    members = [(mname, self.get_attr(self.object, mname, None))\r\n        for mname in list(obj_dict.keys())]\r\n\r\nI got the idea for the fix from here:\r\nhttps://bitbucket.org/birkenfeld/sphinx/pull-requests/311/fix-sphinx-quickstart-does-not-work-on/diff"}}