diff options
author | Tijl Coosemans <tijl@FreeBSD.org> | 2023-02-10 20:22:42 +0000 |
---|---|---|
committer | Tijl Coosemans <tijl@FreeBSD.org> | 2023-02-10 21:15:11 +0000 |
commit | 67d92e052a364083dc46c6d9a071bd22ee64a814 (patch) | |
tree | a2f652dea2bbedc7a07079de3b3b9d0469f9919a | |
parent | 230cf3bad636e34e916bcba192aa5934d8fc5211 (diff) | |
download | ports-67d92e052a364083dc46c6d9a071bd22ee64a814.tar.gz ports-67d92e052a364083dc46c6d9a071bd22ee64a814.zip |
print/hplip: Port pcardext module to Python 3.x
-rw-r--r-- | print/hplip/Makefile | 1 | ||||
-rw-r--r-- | print/hplip/files/patch-pcard_pcardext_pcardext.c | 54 |
2 files changed, 55 insertions, 0 deletions
diff --git a/print/hplip/Makefile b/print/hplip/Makefile index 8e4e4ab51d06..b5d7277f7048 100644 --- a/print/hplip/Makefile +++ b/print/hplip/Makefile @@ -1,5 +1,6 @@ PORTNAME= hplip PORTVERSION= 3.22.10 +PORTREVISION= 1 CATEGORIES= print MASTER_SITES= SF diff --git a/print/hplip/files/patch-pcard_pcardext_pcardext.c b/print/hplip/files/patch-pcard_pcardext_pcardext.c new file mode 100644 index 000000000000..2b6ea5eb61d3 --- /dev/null +++ b/print/hplip/files/patch-pcard_pcardext_pcardext.c @@ -0,0 +1,54 @@ +--- pcard/pcardext/pcardext.c.orig 2022-10-27 13:08:44 UTC ++++ pcard/pcardext/pcardext.c +@@ -59,7 +59,7 @@ int ReadSector(int sector, int nsector, void *buf, int + if( result ) + { + Py_ssize_t len = 0; +- PyString_AsStringAndSize( result, &result_str, &len ); ++ PyBytes_AsStringAndSize( result, &result_str, &len ); + + if( len < nsector*FAT_HARDSECT ) + { +@@ -83,7 +83,7 @@ int WriteSector(int sector, int nsector, void *buf, in + { + result = PyObject_CallFunction( writesectorFunc, "iis#", sector, nsector, buf, size ); + +- return PyInt_AS_LONG( result ); ++ return PyLong_AS_LONG( result ); + } + + return 1; +@@ -208,7 +208,7 @@ PyObject * pcardext_read( PyObject * self, PyObject * + + if( FatReadFileExt( name, offset, len, buffer ) == len ) + { +- return PyString_FromStringAndSize( (char *)buffer, len ); ++ return PyBytes_FromStringAndSize( (char *)buffer, len ); + } + else + { +@@ -234,16 +234,16 @@ static PyMethodDef pcardext_methods[] = + }; + + +-static char pcardext_documentation[] = "Python extension for HP photocard services"; ++PyDoc_STRVAR(pcardext_documentation, "Python extension for HP photocard services"); + +-void initpcardext( void ) ++static struct PyModuleDef pcardext_module = { ++ PyModuleDef_HEAD_INIT, "pcardext", pcardext_documentation, -1, ++ pcardext_methods, ++}; ++ ++PyMODINIT_FUNC PyInit_pcardext( void ) + { +- PyObject * mod = Py_InitModule4( "pcardext", pcardext_methods, +- pcardext_documentation, (PyObject*)NULL, +- PYTHON_API_VERSION ); +- +- if (mod == NULL) +- return; ++ return PyModule_Create(&pcardext_module); + } + + |