Skip to content

Commit 6d7916c

Browse files
committed
Internal imports simplified.
.c files only need to import psycopg.h: it will in turn import dependencies from Python and libpq and configure.h. psycopg.h should be the first to be imported, so the basic imports are not required in the .h's As a guideline I'm trying to import from the most specific to the most generic to detect missing imports in the .h's.
1 parent 9fa1eac commit 6d7916c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+110
-257
lines changed

psycopg/adapter_asis.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,18 @@
2222
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
2323
* License for more details.
2424
*/
25-
26-
#define PY_SSIZE_T_CLEAN
27-
#include <Python.h>
28-
#include <structmember.h>
29-
#include <stringobject.h>
30-
#include <string.h>
3125

3226
#define PSYCOPG_MODULE
33-
#include "psycopg/config.h"
34-
#include "psycopg/python.h"
3527
#include "psycopg/psycopg.h"
28+
3629
#include "psycopg/adapter_asis.h"
3730
#include "psycopg/microprotocols_proto.h"
3831

32+
#include <structmember.h>
33+
#include <stringobject.h>
34+
#include <string.h>
35+
36+
3937
/** the AsIs object **/
4038

4139
static PyObject *

psycopg/adapter_asis.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
#ifndef PSYCOPG_ASIS_H
2727
#define PSYCOPG_ASIS_H 1
2828

29-
#define PY_SSIZE_T_CLEAN
30-
#include <Python.h>
31-
32-
#include "psycopg/config.h"
33-
3429
#ifdef __cplusplus
3530
extern "C" {
3631
#endif

psycopg/adapter_binary.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,17 @@
2323
* License for more details.
2424
*/
2525

26-
#define PY_SSIZE_T_CLEAN
27-
#include <Python.h>
28-
#include <structmember.h>
29-
#include <stringobject.h>
30-
31-
#include <libpq-fe.h>
32-
#include <string.h>
33-
3426
#define PSYCOPG_MODULE
35-
#include "psycopg/config.h"
36-
#include "psycopg/python.h"
3727
#include "psycopg/psycopg.h"
38-
#include "psycopg/connection.h"
28+
3929
#include "psycopg/adapter_binary.h"
4030
#include "psycopg/microprotocols_proto.h"
31+
#include "psycopg/connection.h"
32+
33+
#include <structmember.h>
34+
#include <stringobject.h>
35+
#include <string.h>
36+
4137

4238
/** the quoting code */
4339

psycopg/adapter_binary.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
#ifndef PSYCOPG_BINARY_H
2727
#define PSYCOPG_BINARY_H 1
2828

29-
#define PY_SSIZE_T_CLEAN
30-
#include <Python.h>
31-
#include <libpq-fe.h>
32-
33-
#include "psycopg/config.h"
34-
3529
#ifdef __cplusplus
3630
extern "C" {
3731
#endif

psycopg/adapter_datetime.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,19 @@
2323
* License for more details.
2424
*/
2525

26-
#define PY_SSIZE_T_CLEAN
27-
#include <Python.h>
26+
#define PSYCOPG_MODULE
27+
#include "psycopg/psycopg.h"
28+
29+
#include "psycopg/adapter_datetime.h"
30+
#include "psycopg/microprotocols_proto.h"
31+
2832
#include <structmember.h>
2933
#include <stringobject.h>
3034
#include <datetime.h>
3135

3236
#include <time.h>
3337
#include <string.h>
3438

35-
#define PSYCOPG_MODULE
36-
#include "psycopg/config.h"
37-
#include "psycopg/python.h"
38-
#include "psycopg/psycopg.h"
39-
#include "psycopg/adapter_datetime.h"
40-
#include "psycopg/microprotocols_proto.h"
4139

4240
extern HIDDEN PyObject *pyPsycopgTzModule;
4341
extern HIDDEN PyObject *pyPsycopgTzLOCAL;

psycopg/adapter_datetime.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
#ifndef PSYCOPG_DATETIME_H
2727
#define PSYCOPG_DATETIME_H 1
2828

29-
#define PY_SSIZE_T_CLEAN
30-
#include <Python.h>
31-
32-
#include "psycopg/config.h"
33-
3429
#ifdef __cplusplus
3530
extern "C" {
3631
#endif

psycopg/adapter_list.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,16 @@
2323
* License for more details.
2424
*/
2525

26-
#define PY_SSIZE_T_CLEAN
27-
#include <Python.h>
28-
#include <structmember.h>
29-
#include <stringobject.h>
30-
3126
#define PSYCOPG_MODULE
32-
#include "psycopg/config.h"
33-
#include "psycopg/python.h"
3427
#include "psycopg/psycopg.h"
28+
3529
#include "psycopg/adapter_list.h"
3630
#include "psycopg/microprotocols.h"
3731
#include "psycopg/microprotocols_proto.h"
3832

33+
#include <structmember.h>
34+
#include <stringobject.h>
35+
3936

4037
/* list_str, list_getquoted - return result of quoting */
4138

psycopg/adapter_list.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
#ifndef PSYCOPG_LIST_H
2727
#define PSYCOPG_LIST_H 1
2828

29-
#define PY_SSIZE_T_CLEAN
30-
#include <Python.h>
31-
32-
#include "psycopg/config.h"
33-
3429
#ifdef __cplusplus
3530
extern "C" {
3631
#endif

psycopg/adapter_mxdatetime.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,18 @@
2323
* License for more details.
2424
*/
2525

26-
#define PY_SSIZE_T_CLEAN
27-
#include <Python.h>
26+
#define PSYCOPG_MODULE
27+
#include "psycopg/psycopg.h"
28+
29+
/* TODO: check if still compiles ok: I have no mx on this box */
30+
#include "psycopg/adapter_mxdatetime.h"
31+
#include "psycopg/microprotocols_proto.h"
32+
2833
#include <structmember.h>
2934
#include <stringobject.h>
3035
#include <mxDateTime.h>
3136
#include <string.h>
3237

33-
#define PSYCOPG_MODULE
34-
#include "psycopg/config.h"
35-
#include "psycopg/python.h"
36-
#include "psycopg/psycopg.h"
37-
#include "psycopg/adapter_mxdatetime.h"
38-
#include "psycopg/microprotocols_proto.h"
3938

4039
int
4140
psyco_adapter_mxdatetime_init(void)

psycopg/adapter_mxdatetime.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
#ifndef PSYCOPG_MXDATETIME_H
2727
#define PSYCOPG_MXDATETIME_H 1
2828

29-
#define PY_SSIZE_T_CLEAN
30-
#include <Python.h>
31-
32-
#include "psycopg/config.h"
33-
3429
#ifdef __cplusplus
3530
extern "C" {
3631
#endif

0 commit comments

Comments
 (0)