Various compilation fixed for windows extensions on python3

This commit is contained in:
Kovid Goyal 2019-11-28 17:20:54 +05:30
parent 89f0d92d2e
commit b5f0ab48ac
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 3 additions and 5 deletions

View File

@ -38,7 +38,7 @@ wchar_t *wpd::unicode_to_wchar(PyObject *o) {
len = PyUnicode_GET_SIZE(o); len = PyUnicode_GET_SIZE(o);
buf = (wchar_t *)calloc(len+2, sizeof(wchar_t)); buf = (wchar_t *)calloc(len+2, sizeof(wchar_t));
if (buf == NULL) { PyErr_NoMemory(); return NULL; } if (buf == NULL) { PyErr_NoMemory(); return NULL; }
len = PyUnicode_AsWideChar((PyUnicodeObject*)o, buf, len); len = PyUnicode_AsWideChar(o, buf, len);
if (len == -1) { free(buf); PyErr_Format(PyExc_TypeError, "Invalid python unicode object."); return NULL; } if (len == -1) { free(buf); PyErr_Format(PyExc_TypeError, "Invalid python unicode object."); return NULL; }
return buf; return buf;
} }
@ -69,4 +69,3 @@ int wpd::pump_waiting_messages() {
return result; return result;
} }

View File

@ -208,7 +208,7 @@ CALIBRE_MODINIT_FUNC initwpd(void) {
wpd::DeviceType.tp_new = PyType_GenericNew; wpd::DeviceType.tp_new = PyType_GenericNew;
if (PyType_Ready(&wpd::DeviceType) < 0) if (PyType_Ready(&wpd::DeviceType) < 0)
return; INITERROR;
m = INITMODULE; m = INITMODULE;
if (m == NULL) { if (m == NULL) {

View File

@ -27,7 +27,7 @@ static wchar_t* unicode_to_wchar(PyObject *o) {
len = PyUnicode_GET_SIZE(o); len = PyUnicode_GET_SIZE(o);
buf = (wchar_t *)calloc(len+2, sizeof(wchar_t)); buf = (wchar_t *)calloc(len+2, sizeof(wchar_t));
if (buf == NULL) { PyErr_NoMemory(); return NULL; } if (buf == NULL) { PyErr_NoMemory(); return NULL; }
len = PyUnicode_AsWideChar((PyUnicodeObject*)o, buf, len); len = PyUnicode_AsWideChar(o, buf, len);
if (len == -1) { free(buf); PyErr_Format(PyExc_TypeError, "Invalid python unicode object."); return NULL; } if (len == -1) { free(buf); PyErr_Format(PyExc_TypeError, "Invalid python unicode object."); return NULL; }
return buf; return buf;
} }

View File

@ -46,7 +46,6 @@ wherever possible in this module.
#include <locale.h> #include <locale.h>
#include <Python.h> #include <Python.h>
#include <structseq.h> #include <structseq.h>
#include <timefuncs.h>
#include <shlobj.h> #include <shlobj.h>
#include <stdio.h> #include <stdio.h>
#include <setupapi.h> #include <setupapi.h>