bpo-36635: Change pyport.h for Py_BUILD_CORE_MODULE define (GH-12853)

Change PyAPI_FUNC(type), PyAPI_DATA(type) and PyMODINIT_FUNC macros
of pyport.h when Py_BUILD_CORE_MODULE is defined.

The Py_BUILD_CORE_MODULE define must be now be used to build a C
extension as a dynamic library accessing Python internals: export the
PyInit_xxx() function in DLL exports on Windows.

Changes:

* Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE now imply
  Py_BUILD_CORE directy in pyport.h.
* ceval.c compilation now fails with an error if Py_BUILD_CORE is not
  defined, just to ensure that Python is build with the correct
  defines.
* setup.py now compiles _pickle.c with Py_BUILD_CORE_MODULE define.
* setup.py compiles _json.c with Py_BUILD_CORE_MODULE define, rather
  than Py_BUILD_CORE_BUILTIN define
* PCbuild/pythoncore.vcxproj: Add Py_BUILD_CORE_BUILTIN define.
This commit is contained in:
Victor Stinner 2019-04-17 23:02:26 +02:00 committed by GitHub
parent 3092d6b263
commit 5c75f37d47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 96 additions and 55 deletions

View file

@ -9,8 +9,8 @@ extern "C" {
*** Its definition may be changed or removed at any moment.
***/
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
/*

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#include "dynamic_annotations.h"

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#include "pycore_atomic.h"

View file

@ -1,8 +1,8 @@
#ifndef Py_INTERNAL_CONDVAR_H
#define Py_INTERNAL_CONDVAR_H
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#ifndef _POSIX_THREADS

View file

@ -1,8 +1,8 @@
#ifndef Py_INTERNAL_CONTEXT_H
#define Py_INTERNAL_CONTEXT_H
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#include "pycore_hamt.h"

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif

View file

@ -1,8 +1,8 @@
#ifndef Py_INTERNAL_PYGETOPT_H
#define Py_INTERNAL_PYGETOPT_H
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
extern int _PyOS_opterr;

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#include "pycore_condvar.h"

View file

@ -1,8 +1,8 @@
#ifndef Py_INTERNAL_HAMT_H
#define Py_INTERNAL_HAMT_H
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#define _Py_HAMT_MAX_TREE_DEPTH 7

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#include "pycore_pystate.h" /* _PyRuntime */

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
typedef struct _PyPathConfig {

View file

@ -1,8 +1,8 @@
#ifndef Py_INTERNAL_HASH_H
#define Py_INTERNAL_HASH_H
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
uint64_t _Py_KeyedHash(uint64_t, const char *, Py_ssize_t);

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
/* True if the main interpreter thread exited due to an unhandled

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#include "objimpl.h"

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#include "cpython/coreconfig.h"

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#include "tupleobject.h"

View file

@ -4,8 +4,8 @@
extern "C" {
#endif
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif
#include "object.h"