Make pysane Python3-compatible #2

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@manisandro

These changes allow the pysane module to be compiled both as a python2 or python3 module.

@takluyver takluyver referenced this pull request in python-pillow/Pillow Jan 9, 2013
Closed

Install with Python 3.2 #18

@warsaw

String exceptions are no longer supported in Python 3, so you need to do this too:

  • ErrorObject = PyString_FromString("_sane.error");
  • ErrorObject = PyErr_NewException("_sane.error", NULL, NULL);
@warsaw warsaw commented on the diff Jan 9, 2013
Sane/_sane.c
- /* Create the module and add the functions */
- m = Py_InitModule("_sane", PySane_methods);
+PyMODINIT_FUNC
+init_sane(void)
+{
+ /* Create the module and add the functions */
+ PyObject *m = Py_InitModule("_sane", PySane_methods);
+ if(!m)
+ return;
@warsaw
warsaw Jan 9, 2013

This has to return NULL

@manisandro
manisandro Jan 9, 2013

That section of the code is for the python2 variant, where the module init function is void.

@warsaw warsaw commented on the diff Jan 9, 2013
Sane/_sane.c
@@ -28,6 +28,12 @@
#include <sys/time.h>
+#if PY_MAJOR_VERSION >= 3
@warsaw
warsaw Jan 9, 2013

Is the intention for Pillow to also provide Python 2 support? If not, it's better to drop the #if and do the renames inline.

@manisandro
manisandro Jan 9, 2013

I think that for the foreseeable future Pillow will also provide Python 2 support.

@fluggo
Owner

This was cherry-picked. (Which I now realize was the wrong thing to do, but the damage is done.)

@fluggo fluggo closed this Jan 10, 2013
@manisandro

Uhm, I actually had a patch ready with the suggested modifications (but can't commit it until this evening being behind an annoying corporate firewall atm). Should I post a new pull-request?

@manisandro

Oh, you already made the changes. Ok, never mind - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment