This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2018-11-06.14:08:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1541513321.28.0.788709270274.issue35177@psf.upfronthosting.co.za>
In-reply-to
Content
Currently, there are *implicit* dependencies between AST/parser header files. For example, ast.h uses node and mod_ty types but don't include node.h nor Python-ast.h. And parsetok.h uses node and grammer but don't include nor grammar.h.

Because of that, C files have to include header files in the "correct order" and need to include header files even if they don't use directly.

At the end, we get something like pythonrun.c:

#include "Python-ast.h"
#include "pycore_state.h"
#include "grammar.h"
#include "node.h"
#include "token.h"
#include "parsetok.h"
#include "errcode.h"
#include "code.h"
#include "symtable.h"
#include "ast.h"
#include "marshal.h"
#include "osdefs.h"
#include <locale.h>

whereas most header files are useless, pythonrun.c still compiles with:

#include "pycore_state.h"
#include "token.h"      /* INDENT in err_input() */
#include "parsetok.h"   /* PyParser_ParseFileObject() */
#include "errcode.h"    /* E_EOF */
#include "symtable.h"   /* PySymtable_BuildObject() */
#include "ast.h"        /* PyAST_FromNodeObject() */
#include "marshal.h"    /* PyMarshal_ReadLongFromFile */
#include <locale.h>

I propose to add explicit dependencies in header files directly, rather than using black magic in C files.

Attached PR fix this issue.
History
Date User Action Args
2018-11-06 14:08:41vstinnersetrecipients: + vstinner
2018-11-06 14:08:41vstinnersetmessageid: <1541513321.28.0.788709270274.issue35177@psf.upfronthosting.co.za>
2018-11-06 14:08:41vstinnerlinkissue35177 messages
2018-11-06 14:08:41vstinnercreate