[vlc-commits] python bindings: PyFile_FromFile/AsFile are removed in python3. Use PyFile_FromFd/PyObject_AsFileDescriptor

Olivier Aubert git at videolan.org
Mon Sep 10 17:00:15 CEST 2012


vlc/python | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Mon Sep 10 14:09:09 2012 +0200| [3e5e5b36c7a309360b34de85c5b7a6f357ad7176] | committer: Olivier Aubert

python bindings: PyFile_FromFile/AsFile are removed in python3. Use PyFile_FromFd/PyObject_AsFileDescriptor

> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=3e5e5b36c7a309360b34de85c5b7a6f357ad7176
---

 header.py |   36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/header.py b/header.py
index e5cca3f..404d6bd 100755
--- a/header.py
+++ b/header.py
@@ -240,16 +240,32 @@ class FILE(ctypes.Structure):
     pass
 FILE_ptr = ctypes.POINTER(FILE)
 
-PyFile_FromFile = ctypes.pythonapi.PyFile_FromFile
-PyFile_FromFile.restype = ctypes.py_object
-PyFile_FromFile.argtypes = [FILE_ptr,
-                            ctypes.c_char_p,
-                            ctypes.c_char_p,
-                            ctypes.CFUNCTYPE(ctypes.c_int, FILE_ptr)]
-
-PyFile_AsFile = ctypes.pythonapi.PyFile_AsFile
-PyFile_AsFile.restype = FILE_ptr
-PyFile_AsFile.argtypes = [ctypes.py_object]
+if sys.version_info.major == 2:
+    PyFile_FromFile = ctypes.pythonapi.PyFile_FromFile
+    PyFile_FromFile.restype = ctypes.py_object
+    PyFile_FromFile.argtypes = [FILE_ptr,
+                                ctypes.c_char_p,
+                                ctypes.c_char_p,
+                                ctypes.CFUNCTYPE(ctypes.c_int, FILE_ptr)]
+
+    PyFile_AsFile = ctypes.pythonapi.PyFile_AsFile
+    PyFile_AsFile.restype = FILE_ptr
+    PyFile_AsFile.argtypes = [ctypes.py_object]
+else:
+    PyFile_FromFd = ctypes.pythonapi.PyFile_FromFd
+    PyFile_FromFd.restype = ctypes.py_object
+    PyFile_FromFd.argtypes = [ctypes.c_int,
+                              ctypes.c_char_p,
+                              ctypes.c_char_p,
+                              ctypes.c_int,
+                              ctypes.c_char_p,
+                              ctypes.c_char_p,
+                              ctypes.c_char_p,
+                              ctypes.c_int ]
+
+    PyFile_AsFd = ctypes.pythonapi.PyObject_AsFileDescriptor
+    PyFile_AsFd.restype = ctypes.c_int
+    PyFile_AsFd.argtypes = [ctypes.py_object]
 
  # Generated enum types #
 # GENERATED_ENUMS go here  # see generate.py



More information about the vlc-commits mailing list