From fe853d02618076577b617f7ec4ce75dcf40b7c24 Mon Sep 17 00:00:00 2001
From: James Henstridge <james@jamesh.id.au>
Date: Mon, 21 Jan 2008 21:41:17 +0000
Subject: [PATCH] 	* psycopg/typecast.c (typecast_pydatetime): make array
 static. 	(typecast_mxdatetime): same here.

	* psycopg/typecast_builtins.c (typecast_builtins): make array
	static.

	* psycopg/psycopgmodule.c: add hidden visibility to a bunch of
	global variables here.

	* psycopg/psycopg.h: add set QueryCanceledError and
	TransactionRollbackError to hidden visibility.
---
 ChangeLog                   | 12 ++++++++++++
 psycopg/psycopg.h           |  2 +-
 psycopg/psycopgmodule.c     | 22 +++++++++++-----------
 psycopg/typecast.c          |  4 ++--
 psycopg/typecast_builtins.c |  2 +-
 5 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bb7014df..2f14e67c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2008-01-22  James Henstridge  <james@jamesh.id.au>
 
+	* psycopg/typecast.c (typecast_pydatetime): make array static.
+	(typecast_mxdatetime): same here.
+
+	* psycopg/typecast_builtins.c (typecast_builtins): make array
+	static.
+
+	* psycopg/psycopgmodule.c: add hidden visibility to a bunch of
+	global variables here.
+
+	* psycopg/psycopg.h: add set QueryCanceledError and
+	TransactionRollbackError to hidden visibility.
+
 	* psycopg/*.[ch]: add const qualifier to various string arguments
 	to functions (typecast functions and conn_switch_isolation_level).
 
diff --git a/psycopg/psycopg.h b/psycopg/psycopg.h
index 6e166219..7d79cfb8 100644
--- a/psycopg/psycopg.h
+++ b/psycopg/psycopg.h
@@ -89,7 +89,7 @@ extern HIDDEN PyObject *Error, *Warning, *InterfaceError, *DatabaseError,
     *InternalError, *OperationalError, *ProgrammingError,
     *IntegrityError, *DataError, *NotSupportedError;
 #ifdef PSYCOPG_EXTENSIONS
-extern PyObject *QueryCanceledError, *TransactionRollbackError;
+extern HIDDEN PyObject *QueryCanceledError, *TransactionRollbackError;
 #endif
 
 /* python versions and compatibility stuff */
diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c
index b74abdce..957c45fb 100644
--- a/psycopg/psycopgmodule.c
+++ b/psycopg/psycopgmodule.c
@@ -42,29 +42,29 @@
 #ifdef HAVE_MXDATETIME
 #include <mxDateTime.h>
 #include "psycopg/adapter_mxdatetime.h"
-mxDateTimeModule_APIObject *mxDateTimeP = NULL;
+HIDDEN mxDateTimeModule_APIObject *mxDateTimeP = NULL;
 #endif
 
 /* some module-level variables, like the datetime module */
 #ifdef HAVE_PYDATETIME
 #include <datetime.h>
 #include "psycopg/adapter_datetime.h"
-PyObject *pyDateTimeModuleP = NULL;
-PyObject *pyDateTypeP = NULL;
-PyObject *pyTimeTypeP = NULL;
-PyObject *pyDateTimeTypeP = NULL;
-PyObject *pyDeltaTypeP = NULL;
+HIDDEN PyObject *pyDateTimeModuleP = NULL;
+HIDDEN PyObject *pyDateTypeP = NULL;
+HIDDEN PyObject *pyTimeTypeP = NULL;
+HIDDEN PyObject *pyDateTimeTypeP = NULL;
+HIDDEN PyObject *pyDeltaTypeP = NULL;
 #endif
 
 /* pointers to the psycopg.tz classes */
-PyObject *pyPsycopgTzModule = NULL;
-PyObject *pyPsycopgTzLOCAL = NULL;
-PyObject *pyPsycopgTzFixedOffsetTimezone = NULL;
+HIDDEN PyObject *pyPsycopgTzModule = NULL;
+HIDDEN PyObject *pyPsycopgTzLOCAL = NULL;
+HIDDEN PyObject *pyPsycopgTzFixedOffsetTimezone = NULL;
 
-PyObject *psycoEncodings = NULL;
+HIDDEN PyObject *psycoEncodings = NULL;
 
 #ifdef PSYCOPG_DEBUG
-int psycopg_debug_enabled = 0;
+HIDDEN int psycopg_debug_enabled = 0;
 #endif
 
 /** connect module-level function **/
diff --git a/psycopg/typecast.c b/psycopg/typecast.c
index 75ab293a..6ed90a82 100644
--- a/psycopg/typecast.c
+++ b/psycopg/typecast.c
@@ -180,7 +180,7 @@ typecast_parse_time(const char* s, const char** t, Py_ssize_t* len,
 
 /* a list of initializers, used to make the typecasters accessible anyway */
 #ifdef HAVE_PYDATETIME
-typecastObject_initlist typecast_pydatetime[] = {
+static typecastObject_initlist typecast_pydatetime[] = {
     {"PYDATETIME", typecast_DATETIME_types, typecast_PYDATETIME_cast},
     {"PYTIME", typecast_TIME_types, typecast_PYTIME_cast},
     {"PYDATE", typecast_DATE_types, typecast_PYDATE_cast},
@@ -191,7 +191,7 @@ typecastObject_initlist typecast_pydatetime[] = {
 
 /* a list of initializers, used to make the typecasters accessible anyway */
 #ifdef HAVE_MXDATETIME
-typecastObject_initlist typecast_mxdatetime[] = {
+static typecastObject_initlist typecast_mxdatetime[] = {
     {"MXDATETIME", typecast_DATETIME_types, typecast_MXDATE_cast},
     {"MXTIME", typecast_TIME_types, typecast_MXTIME_cast},
     {"MXDATE", typecast_DATE_types, typecast_MXDATE_cast},
diff --git a/psycopg/typecast_builtins.c b/psycopg/typecast_builtins.c
index 0fc109d8..e8e5a1a2 100644
--- a/psycopg/typecast_builtins.c
+++ b/psycopg/typecast_builtins.c
@@ -27,7 +27,7 @@ static long int typecast_BINARYARRAY_types[] = {1001, 0};
 static long int typecast_ROWIDARRAY_types[] = {1028, 1013, 0};
 
 
-typecastObject_initlist typecast_builtins[] = {
+static typecastObject_initlist typecast_builtins[] = {
   {"NUMBER", typecast_NUMBER_types, typecast_NUMBER_cast, NULL},
   {"LONGINTEGER", typecast_LONGINTEGER_types, typecast_LONGINTEGER_cast, NULL},
   {"INTEGER", typecast_INTEGER_types, typecast_INTEGER_cast, NULL},