summaryrefslogtreecommitdiff
path: root/libre/hplip/python3.diff
diff options
context:
space:
mode:
authorDavid P <megver83@parabola.nu>2019-12-27 16:44:44 -0300
committerDavid P <megver83@parabola.nu>2019-12-27 16:44:44 -0300
commit8067374d02616d5d14bb7f1b0a97852eb1cf3b76 (patch)
tree0016bd54b36291dee4fd0ef01c4e325c3bb8b580 /libre/hplip/python3.diff
parent92f9d0dcbb5c9a6a8606a40e5e68485636a86a77 (diff)
downloadabslibre-8067374d02616d5d14bb7f1b0a97852eb1cf3b76.tar.gz
abslibre-8067374d02616d5d14bb7f1b0a97852eb1cf3b76.tar.bz2
abslibre-8067374d02616d5d14bb7f1b0a97852eb1cf3b76.zip
updpkg: libre/hplip 1:3.19.12-1.par1
Signed-off-by: David P <megver83@parabola.nu>
Diffstat (limited to 'libre/hplip/python3.diff')
-rw-r--r--libre/hplip/python3.diff147
1 files changed, 147 insertions, 0 deletions
diff --git a/libre/hplip/python3.diff b/libre/hplip/python3.diff
new file mode 100644
index 000000000..b79f0c017
--- /dev/null
+++ b/libre/hplip/python3.diff
@@ -0,0 +1,147 @@
+From: Till Kamppeter <till.kamppeter@gmail.com>
+Date: Fri, 22 Jul 2016 09:33:04 +0200
+Subject: Workaround patch for missing Python3 transition of the old
+ (pre-USB-storage) photo memory card support (pcardext) as this part builds
+ in Python3 environments but with pointer-related warnings which are fatal
+ errors for Ubuntu's build servers. The patch silences the warnings but the
+ memory card support is dropped in Python3 environments. This patch is
+ supplied by the HPLIP upstream developers and will be replaced by a more
+ proper solution in the next upstream release of HPLIP (see LP: #1275353)
+
+---
+ pcard/pcardext/pcardext.c | 59 +++++++++++++++++++++++++++++++++++++----------
+ pcard/photocard.py | 2 +-
+ unload.py | 5 ++++
+ 3 files changed, 53 insertions(+), 13 deletions(-)
+
+diff --git a/pcard/pcardext/pcardext.c b/pcard/pcardext/pcardext.c
+index c1a8273..37d979b 100644
+--- a/pcard/pcardext/pcardext.c
++++ b/pcard/pcardext/pcardext.c
+@@ -20,7 +20,7 @@ pcardext - Python extension for HP photocard services
+ Requires:
+ Python 2.2+
+
+-Author: Don Welch
++Author: Don Welch
+
+ \*****************************************************************************/
+
+@@ -38,9 +38,37 @@ typedef int Py_ssize_t;
+
+ int verbose=0;
+
++#if PY_MAJOR_VERSION >= 3
++ #define MOD_ERROR_VAL NULL
++ #define MOD_SUCCESS_VAL(val) val
++ #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
++ #define PyInt_AS_LONG PyLong_AS_LONG
++ #define MOD_DEF(ob, name, doc, methods) \
++ static struct PyModuleDef moduledef = { \
++ PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \
++ ob = PyModule_Create(&moduledef);
++
++
++ #define PY_String_Bytes PyBytes_FromStringAndSize
++ #define PY_AsString_Bytes PyBytes_AsStringAndSize
++
++#else
++ #define MOD_ERROR_VAL
++ #define MOD_SUCCESS_VAL(val)
++ #define MOD_INIT(name) void init##name(void)
++ #define MOD_DEF(ob, name, doc, methods) \
++ ob = Py_InitModule3(name, methods, doc);
++
++ #define PY_String_Bytes PyString_FromStringAndSize
++ #define PY_AsString_Bytes PyString_AsStringAndSize
++
++#endif
++
+ PyObject * readsectorFunc = NULL;
+ PyObject * writesectorFunc = NULL;
+
++
++
+ int ReadSector(int sector, int nsector, void *buf, int size)
+ {
+ PyObject * result;
+@@ -56,9 +84,13 @@ int ReadSector(int sector, int nsector, void *buf, int size)
+ if( result )
+ {
+ Py_ssize_t len = 0;
+- PyString_AsStringAndSize( result, &result_str, &len );
++
++ //PyString_AsStringAndSize( result, &result_str, &len );
++ //PyBytes_AsStringAndSize( result, &result_str, &len );
++ PY_AsString_Bytes( result, &result_str, &len );
+
+- if( len < nsector*FAT_HARDSECT )
++
++ if( len < nsector*FAT_HARDSECT )
+ {
+ goto abort;
+ }
+@@ -205,7 +237,9 @@ PyObject * pcardext_read( PyObject * self, PyObject * args )
+
+ if( FatReadFileExt( name, offset, len, buffer ) == len )
+ {
+- return PyString_FromStringAndSize( (char *)buffer, len );
++ // return PyString_FromStringAndSize( (char *)buffer, len );
++ return PY_String_Bytes( (char *)buffer, len );
++ // return PyBytes_FromStringAndSize( (char *)buffer, len );
+ }
+ else
+ {
+@@ -233,14 +267,15 @@ static PyMethodDef pcardext_methods[] =
+
+ static char pcardext_documentation[] = "Python extension for HP photocard services";
+
+-void initpcardext( void )
+-{
+- PyObject * mod = Py_InitModule4( "pcardext", pcardext_methods,
+- pcardext_documentation, (PyObject*)NULL,
+- PYTHON_API_VERSION );
+-
+- if (mod == NULL)
+- return;
++MOD_INIT(pcardext) {
++
++ PyObject* mod ;
++ MOD_DEF(mod, "pcardext", pcardext_documentation, pcardext_methods);
++ if (mod == NULL)
++ return MOD_ERROR_VAL;
++
++ return MOD_SUCCESS_VAL(mod);
++
+ }
+
+
+diff --git a/pcard/photocard.py b/pcard/photocard.py
+index 913dc4e..2c73158 100644
+--- a/pcard/photocard.py
++++ b/pcard/photocard.py
+@@ -30,7 +30,7 @@ from base.codes import *
+ from base import device, utils, exif
+
+ try:
+- from . import pcardext
++ import pcardext
+ except ImportError:
+ if not os.getenv("HPLIP_BUILD"):
+ log.error("PCARDEXT could not be loaded. Please check HPLIP installation.")
+diff --git a/unload.py b/unload.py
+index 3fdd5a3..ce8b069 100755
+--- a/unload.py
++++ b/unload.py
+@@ -44,6 +44,11 @@ except ImportError:
+
+ # Local
+ from base.g import *
++from base.sixext import PY3
++if PY3:
++ log.error("This functionality is not spported in python3 environment.")
++ sys.exit(1)
++
+ from base import device, utils, tui, module
+ from prnt import cups
+