From: Daniele Varrazzo Date: Tue, 29 Jun 2021 12:00:33 +0000 (+0100) Subject: Work around getpid on Windows X-Git-Tag: 3.0.dev0~4^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f5425e36b494a79ca0db805c5565dea3a3489488;p=thirdparty%2Fpsycopg.git Work around getpid on Windows --- diff --git a/psycopg_c/psycopg_c/pq.pxd b/psycopg_c/psycopg_c/pq.pxd index 990d4532b..82c4e5000 100644 --- a/psycopg_c/psycopg_c/pq.pxd +++ b/psycopg_c/psycopg_c/pq.pxd @@ -1,4 +1,8 @@ -from posix.fcntl cimport pid_t +IF UNAME_SYSNAME != "Windows": + from posix.fcntl cimport pid_t +ELSE: + ctypedef int pid_t + from psycopg_c.pq cimport libpq ctypedef char *(*conn_bytes_f) (const libpq.PGconn *) diff --git a/psycopg_c/psycopg_c/pq/pgconn.pyx b/psycopg_c/psycopg_c/pq/pgconn.pyx index a0eecb429..72f239c34 100644 --- a/psycopg_c/psycopg_c/pq/pgconn.pyx +++ b/psycopg_c/psycopg_c/pq/pgconn.pyx @@ -4,7 +4,14 @@ psycopg_c.pq.PGconn object implementation. # Copyright (C) 2020-2021 The Psycopg Team -from posix.unistd cimport getpid +IF UNAME_SYSNAME != "Windows": + from posix.unistd cimport getpid +ELSE: + # We don't need a real definition for this because Windows is not affected + # by the issue caused by closing the fds after fork. + cdef int getpid(): + return 0 + from cpython.mem cimport PyMem_Malloc, PyMem_Free from cpython.bytes cimport PyBytes_AsString, PyBytes_AsStringAndSize from cpython.memoryview cimport PyMemoryView_FromObject