-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhplip-3.22.10-python-3.11.patch
More file actions
58 lines (51 loc) · 1.83 KB
/
Copy pathhplip-3.22.10-python-3.11.patch
File metadata and controls
58 lines (51 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
diff -up hplip-3.22.10/pcard/pcardext/pcardext.c.omv~ hplip-3.22.10/pcard/pcardext/pcardext.c
--- hplip-3.22.10/pcard/pcardext/pcardext.c.omv~ 2022-11-06 19:06:14.873746854 +0100
+++ hplip-3.22.10/pcard/pcardext/pcardext.c 2022-11-06 19:23:46.906581300 +0100
@@ -31,6 +31,10 @@ Author: Don Welch
#include <structmember.h>
#include "../fat.h"
+#define PyString_AsStringAndSize(ob, charpp, sizep) \
+ (PyUnicode_Check(ob)? \
+ ((*(charpp) = (char*)PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
+ PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
/* Ref: PEP 353 (Python 2.5) */
#if PY_VERSION_HEX < 0x02050000
@@ -83,7 +87,7 @@ int WriteSector(int sector, int nsector,
{
result = PyObject_CallFunction( writesectorFunc, "iis#", sector, nsector, buf, size );
- return PyInt_AS_LONG( result );
+ return PyLong_AS_LONG( result );
}
return 1;
@@ -208,7 +212,7 @@ PyObject * pcardext_read( PyObject * sel
if( FatReadFileExt( name, offset, len, buffer ) == len )
{
- return PyString_FromStringAndSize( (char *)buffer, len );
+ return PyUnicode_FromStringAndSize( (char *)buffer, len );
}
else
{
@@ -236,12 +240,21 @@ static PyMethodDef pcardext_methods[] =
static char pcardext_documentation[] = "Python extension for HP photocard services";
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "pcardext",
+ pcardext_documentation,
+ -1,
+ pcardext_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
void initpcardext( void )
{
- PyObject * mod = Py_InitModule4( "pcardext", pcardext_methods,
- pcardext_documentation, (PyObject*)NULL,
- PYTHON_API_VERSION );
-
+ PyObject * mod = PyModule_Create(&moduledef);
if (mod == NULL)
return;
}