mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-18 10:00:31 +03:00
Avoid quoting the string in the psycopg version macro
Use a macro trick to add the quotes. This seems more portable than passing the quotes to the command line (see #658). https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
This commit is contained in:
parent
750ececf08
commit
32f5a9fc1d
|
@ -72,6 +72,10 @@ HIDDEN PyObject *psyco_null = NULL;
|
||||||
/* The type of the cursor.description items */
|
/* The type of the cursor.description items */
|
||||||
HIDDEN PyObject *psyco_DescriptionType = NULL;
|
HIDDEN PyObject *psyco_DescriptionType = NULL;
|
||||||
|
|
||||||
|
/* macro trick to stringify a macro expansion */
|
||||||
|
#define xstr(s) str(s)
|
||||||
|
#define str(s) #s
|
||||||
|
|
||||||
/** connect module-level function **/
|
/** connect module-level function **/
|
||||||
#define psyco_connect_doc \
|
#define psyco_connect_doc \
|
||||||
"_connect(dsn, [connection_factory], [async]) -- New database connection.\n\n"
|
"_connect(dsn, [connection_factory], [async]) -- New database connection.\n\n"
|
||||||
|
@ -885,7 +889,7 @@ INIT_MODULE(_psycopg)(void)
|
||||||
psycopg_debug_enabled = 1;
|
psycopg_debug_enabled = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Dprintf("initpsycopg: initializing psycopg %s", PSYCOPG_VERSION);
|
Dprintf("initpsycopg: initializing psycopg %s", xstr(PSYCOPG_VERSION));
|
||||||
|
|
||||||
/* initialize all the new types and then the module */
|
/* initialize all the new types and then the module */
|
||||||
Py_TYPE(&connectionType) = &PyType_Type;
|
Py_TYPE(&connectionType) = &PyType_Type;
|
||||||
|
@ -1017,7 +1021,7 @@ INIT_MODULE(_psycopg)(void)
|
||||||
if (!(psyco_DescriptionType = psyco_make_description_type())) { goto exit; }
|
if (!(psyco_DescriptionType = psyco_make_description_type())) { goto exit; }
|
||||||
|
|
||||||
/* set some module's parameters */
|
/* set some module's parameters */
|
||||||
PyModule_AddStringConstant(module, "__version__", PSYCOPG_VERSION);
|
PyModule_AddStringConstant(module, "__version__", xstr(PSYCOPG_VERSION));
|
||||||
PyModule_AddStringConstant(module, "__doc__", "psycopg PostgreSQL driver");
|
PyModule_AddStringConstant(module, "__doc__", "psycopg PostgreSQL driver");
|
||||||
PyModule_AddIntConstant(module, "__libpq_version__", PG_VERSION_NUM);
|
PyModule_AddIntConstant(module, "__libpq_version__", PG_VERSION_NUM);
|
||||||
PyModule_AddIntMacro(module, REPLICATION_PHYSICAL);
|
PyModule_AddIntMacro(module, REPLICATION_PHYSICAL);
|
||||||
|
|
5
setup.py
5
setup.py
|
@ -596,10 +596,7 @@ if version_flags:
|
||||||
else:
|
else:
|
||||||
PSYCOPG_VERSION_EX = PSYCOPG_VERSION
|
PSYCOPG_VERSION_EX = PSYCOPG_VERSION
|
||||||
|
|
||||||
if not PLATFORM_IS_WINDOWS:
|
define_macros.append(('PSYCOPG_VERSION', PSYCOPG_VERSION_EX))
|
||||||
define_macros.append(('PSYCOPG_VERSION', '"' + PSYCOPG_VERSION_EX + '"'))
|
|
||||||
else:
|
|
||||||
define_macros.append(('PSYCOPG_VERSION', '\\"' + PSYCOPG_VERSION_EX + '\\"'))
|
|
||||||
|
|
||||||
if parser.has_option('build_ext', 'have_ssl'):
|
if parser.has_option('build_ext', 'have_ssl'):
|
||||||
have_ssl = int(parser.get('build_ext', 'have_ssl'))
|
have_ssl = int(parser.get('build_ext', 'have_ssl'))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user