mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00

- IMPORT_NAME takes an extra argument from the stack: the relativeness of the import. Only passed to __import__ when it's not -1. - __import__() takes an optional 5th argument for the same thing; it __defaults to -1 (old semantics: try relative, then absolute) - 'from . import name' imports name (be it module or regular attribute) from the current module's *package*. Likewise, 'from .module import name' will import name from a sibling to the current module. - Importing from outside a package is not allowed; 'from . import sys' in a toplevel module will not work, nor will 'from .. import sys' in a (single-level) package. - 'from __future__ import absolute_import' will turn on the new semantics for import and from-import: imports will be absolute, except for from-import with dots. Includes tests for regular imports and importhooks, parser changes and a NEWS item, but no compiler-package changes or documentation changes.
38 lines
1 KiB
C
38 lines
1 KiB
C
#ifndef Py_CODE_H
|
|
#include "code.h"
|
|
#endif
|
|
|
|
#ifndef Py_COMPILE_H
|
|
#define Py_COMPILE_H
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Public interface */
|
|
struct _node; /* Declare the existence of this type */
|
|
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
|
|
|
|
/* Future feature support */
|
|
|
|
typedef struct {
|
|
int ff_features; /* flags set by future statements */
|
|
int ff_lineno; /* line number of last future statement */
|
|
} PyFutureFeatures;
|
|
|
|
#define FUTURE_NESTED_SCOPES "nested_scopes"
|
|
#define FUTURE_GENERATORS "generators"
|
|
#define FUTURE_DIVISION "division"
|
|
#define FUTURE_ABSIMPORT "absolute_import"
|
|
|
|
struct _mod; /* Declare the existence of this type */
|
|
PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *,
|
|
PyCompilerFlags *, PyArena *);
|
|
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);
|
|
|
|
#define ERR_LATE_FUTURE \
|
|
"from __future__ imports must occur at the beginning of the file"
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif /* !Py_COMPILE_H */
|