SHA256
1
0
forked from printing/hplip
Files
hplip/pcardext-python3-fixes.patch
Martin Wilck 9fe62f807f Update to HPLIP 3.25.8
Added support for the following new Printers
  * HP LaserJet Enterprise Flow MFP 8601z
  * HP LaserJet Enterprise 5501
  * HP LaserJet Enterprise MFP 5601dn
  * HP LaserJet Enterprise 6500dn
  * HP LaserJet Enterprise 5501n
  * HP LaserJet Enterprise MFP 5601
  * HP LaserJet Enterprise 6500
  * HP LaserJet Enterprise 5502dn
  * HP LaserJet Enterprise MFP 5602dn
  * HP LaserJet Enterprise 6500n
  * HP LaserJet Enterprise 5502
  * HP LaserJet Enterprise MFP 5602f
  * HP LaserJet Enterprise 6501dn
  * HP LaserJet Enterprise X50452dn
  * HP LaserJet Enterprise Flow MFP 5602zfw
  * HP LaserJet Enterprise 6501
  * HP LaserJet Enterprise X50452
  * HP LaserJet Enterprise MFP 5602
  * HP LaserJet Enterprise X60257dn
  * HP LaserJet Enterprise MFP X53052dn
  * HP LaserJet Enterprise Flow MFP X530
  * HP LaserJet Enterprise X60257
  * HP LaserJet Enterprise MFP X53052
  * HP LaserJet Enterprise X60357dn
  * HP LaserJet Enterprise X60357
  * HP LaserJet Enterprise MFP 6600dn
  * HP LaserJet Enterprise Flow MFP 6600zfw
  * HP LaserJet Enterprise MFP 6600
  * HP LaserJet Enterprise Flow MFP 6600zfsw
  * HP LaserJet Enterprise MFP X62757dn
  * HP LaserJet Enterprise Flow MFP X62757zs
  * HP LaserJet Enterprise MFP X62757
  * DEX D50452dn
  * DEX MFP D53052dn

Drop patches that have been merged upstream
  * Drop hplip-change-pgp-server.patch
  * Drop hp-setup-fix-python-crash-when-manually-importing-gz.patch

Fix handling of readfp() and read_filke() for ConfigParser objects,
  avoiding confusing error messages (lp#2139771)
  * Add hplip-fix-handling-of-ConfigParser-.readfp-vs.-read_.patch
  * Drop hplip-base-replace-f-string-with-string.format-for-p.patch
Fix compiler warnings on SLE15
  * Add Fix-two-compiler-warnings-that-cause-build-failure-o.patch

Renamed patch files to achieve a consistent patch naming according
  to the rules of git-format-patch
  * Rename change-udev-rules.diff -> hplip-change-udev-rules.patch
  * Rename disable_hp-upgrade.patch -> disable-hp-upgrade.patch
  * Rename add_missing_includes_and_define_GNU_SOURCE.patch
        -> add-missing-includes-and-define-GNU_SOURCE.patch
  * Rename hplip-remove-imageprocessor.diff
        -> hplip-remove-imageprocessor.patch
  * Rename hplip-orblite-return-null.diff -> hplip-orblite-return-null.patch
  * Rename hplip-hpaio-gcc14.patch -> hplip-hpaio-avoid-C99-violations.patch
  * Rename hplip-no-urlopener.patch
        -> URLopener-was-removed-in-Python-3.14-and-hplip-trace.patch
  * Rename hplip-3.24.4-gcc15.patch -> hplip-sane-fix-compilation-with-gcc-15.patch
  Patches are now managed under https://github.com/mwilck/hplip
2026-02-03 20:51:32 +01:00

82 lines
2.1 KiB
Diff

From 0e635e8c5d97b4ab86a16678c38cd43c8086679e Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 21 Mar 2018 23:55:12 +0100
Subject: [PATCH 07/33] pcardext: python3 fixes
---
pcard/pcardext/pcardext.c | 36 ++++++++++++++++++++++++++++++++++--
1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/pcard/pcardext/pcardext.c b/pcard/pcardext/pcardext.c
index 131e5e9..e1eb3e1 100644
--- a/pcard/pcardext/pcardext.c
+++ b/pcard/pcardext/pcardext.c
@@ -39,6 +39,12 @@ typedef int Py_ssize_t;
#define PY_SSIZE_T_MIN INT_MIN
#endif
+#if PY_MAJOR_VERSION >= 3
+#define PyString_AsStringAndSize PyBytes_AsStringAndSize
+#define PyString_FromStringAndSize PyBytes_FromStringAndSize
+#define PyInt_AS_LONG PyLong_AS_LONG
+#endif
+
int verbose=0;
PyObject * readsectorFunc = NULL;
@@ -81,8 +87,11 @@ int WriteSector(int sector, int nsector, void *buf, int size )
if( writesectorFunc )
{
+#if PY_MAJOR_VERSION >= 3
result = PyObject_CallFunction( writesectorFunc, "iis#", sector, nsector, buf, size );
-
+#else
+ result = PyObject_CallFunction( writesectorFunc, "iiy#", sector, nsector, buf, size );
+#endif
return PyInt_AS_LONG( result );
}
@@ -233,9 +242,31 @@ static PyMethodDef pcardext_methods[] =
{ NULL, NULL }
};
-
static char pcardext_documentation[] = "Python extension for HP photocard services";
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef moduledef = {
+ .m_base = PyModuleDef_HEAD_INIT,
+ .m_name = "pcardext",
+ .m_doc = pcardext_documentation,
+ .m_size = -1,
+ .m_methods = pcardext_methods,
+ .m_slots = NULL,
+ .m_traverse = NULL,
+ .m_clear = NULL,
+ .m_free = NULL,
+};
+
+PyMODINIT_FUNC
+PyInit_pcardext( void )
+{
+ PyObject *module = PyModule_Create2(&moduledef, PYTHON_API_VERSION);
+
+ return module;
+}
+
+#else
+
void initpcardext( void )
{
PyObject * mod = Py_InitModule4( "pcardext", pcardext_methods,
@@ -246,4 +277,5 @@ void initpcardext( void )
return;
}
+#endif
--
2.52.0