File use-python3.patch of Package sphinxbase
Index: sphinxbase-0.8/python/Makefile.am
===================================================================
--- sphinxbase-0.8.orig/python/Makefile.am
+++ sphinxbase-0.8/python/Makefile.am
@@ -35,5 +35,5 @@ endif
if BUILD_CYTHON
$(srcdir)/sphinxbase.c: $(srcdir)/sphinxbase.pyx $(srcdir)/sphinxbase.pxd
- cython -o $@ $<
+ cython -3 -o $@ $<
endif
Index: sphinxbase-0.8/python/Makefile.in
===================================================================
--- sphinxbase-0.8.orig/python/Makefile.in
+++ sphinxbase-0.8/python/Makefile.in
@@ -503,7 +503,7 @@ uninstall-am: uninstall-local uninstall-
@BUILD_PYTHON_TRUE@ touch $@
@BUILD_CYTHON_TRUE@$(srcdir)/sphinxbase.c: $(srcdir)/sphinxbase.pyx $(srcdir)/sphinxbase.pxd
-@BUILD_CYTHON_TRUE@ cython -o $@ $<
+@BUILD_CYTHON_TRUE@ cython -3 -o $@ $<
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
Index: sphinxbase-0.8/python/sphinxbase.pyx
===================================================================
--- sphinxbase-0.8.orig/python/sphinxbase.pyx
+++ sphinxbase-0.8/python/sphinxbase.pyx
@@ -6,6 +6,8 @@
# notice is not removed.
#
# Author: David Huggins-Daines <dhuggins@cs.cmu.edu>
+import io
+from libc.stdio cimport fdopen
cdef class LogMath:
"""
@@ -534,20 +536,20 @@ cdef class HuffCode:
ckd_free(symbols)
def read(self, infile):
- if not isinstance(infile, file):
- infile = file(infile, "rb")
+ if not isinstance(infile, io.IOBase):
+ infile = open(infile, "rb")
huff_code_free(self.hc)
- self.hc = huff_code_read(PyFile_AsFile(infile))
+ self.hc = huff_code_read(fdopen(PyObject_AsFileDescriptor(infile), "rb"))
def write(self, outfile):
- if not isinstance(outfile, file):
- outfile = file(outfile, "wb")
- huff_code_write(self.hc, PyFile_AsFile(outfile))
+ if not isinstance(outfile, io.IOBase):
+ outfile = open(outfile, "wb")
+ huff_code_write(self.hc, fdopen(PyObject_AsFileDescriptor(outfile), "wb"))
def dump(self, outfile):
- if not isinstance(outfile, file):
- outfile = file(outfile, "w")
- huff_code_dump(self.hc, PyFile_AsFile(outfile))
+ if not isinstance(outfile, io.IOBase):
+ outfile = open(outfile, "w")
+ huff_code_dump(self.hc, fdopen(PyObject_AsFileDescriptor(outfile), "w"))
def encode(self, seq):
"""
@@ -619,7 +621,7 @@ cdef class HuffCode:
nbits += offset
i += 1
#print "output:", binstr(output, nbits)
- outstr = PyString_FromStringAndSize(output, nbytes)
+ outstr = PyBytes_FromStringAndSize(output, nbytes)
PyMem_Free(output)
return (outstr, offset)
@@ -648,10 +650,10 @@ cdef class HuffCode:
return (output, offset)
def attach(self, fh, char *mode):
- if not isinstance(fh, file):
- fh = file(fh, mode)
+ if not isinstance(fh, io.IOBase):
+ fh = open(fh, mode)
self.fh = fh
- huff_code_attach(self.hc, PyFile_AsFile(fh), mode)
+ huff_code_attach(self.hc, fdopen(PyObject_AsFileDescriptor(fh), mode), mode)
def detach(self):
huff_code_detach(self.hc)
Index: sphinxbase-0.8/python/setup.py.in
===================================================================
--- sphinxbase-0.8.orig/python/setup.py.in
+++ sphinxbase-0.8/python/setup.py.in
@@ -28,7 +28,7 @@ class bogus_uninstall(distutils.command.
if os.path.isdir(f):
dirs[f] = 1
continue
- print "Trying to remove file", f
+ print("Trying to remove file %s" % f)
try:
os.unlink(f)
except:
@@ -37,11 +37,11 @@ class bogus_uninstall(distutils.command.
# This is really not guaranteed to work!!!
for d in dirs:
while d != self.prefix:
- print "Trying to remove dir", d
+ print("Trying to remove dir %s" % d)
try:
if d.endswith(".egg-info"):
files=[os.path.join(d,f) for f in os.listdir(d)]
- print "Trying to remove:", " ".join(files)
+ print("Trying to remove: " + " ".join(files))
for f in files: os.unlink(f)
os.rmdir(d)
except:
Index: sphinxbase-0.8/python/sphinxbase.pxd
===================================================================
--- sphinxbase-0.8.orig/python/sphinxbase.pxd
+++ sphinxbase-0.8/python/sphinxbase.pxd
@@ -20,10 +20,10 @@ cdef extern from *:
# Get Python stuff to access stdio
cdef extern from "Python.h":
ctypedef struct FILE
- FILE *PyFile_AsFile(object)
+ int PyObject_AsFileDescriptor(object)
void *PyMem_Malloc(size_t n)
void PyMem_Free(void *p)
- object PyString_FromStringAndSize(char *v, Py_ssize_t len)
+ object PyBytes_FromStringAndSize(char *v, Py_ssize_t len)
cdef extern from "sphinxbase/logmath.h":
ctypedef struct logmath_t