Skip to contentSkip to conversation

bundles/pyml: Remove bindings for PyObject_As(Char|Read|Write)Buffer

PATCH In review Richard W.M. Jones 2 participants 4 messages Nov 10, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bundles/pyml: Remove bindings for PyObject_As(Char|Read|Write)Buffer

Some more functions were deprecated/removed in Python 10, breaking Coccinelle compiles. It was reported by Fedora's Python team here:

https://bugzilla.redhat.com/show_bug.cgi?id=1896393

I have fixed it by chopping out bindings for these functions from the bundled pyml, and it compiles fine for me with Python 10 now.

Rich.

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#1 lore raw

PATCH 1/1 bundles/pyml: Remove bindings for PyObject_As(Char|Read|Write)Buffer

These have been removed in Python 3.10.

---
 bundles/pyml/pyml-current/py.ml        | 12 ------------
 bundles/pyml/pyml-current/py.mli       | 12 ------------
 bundles/pyml/pyml-current/pycaml.ml    |  6 ------
 bundles/pyml/pyml-current/pycaml.mli   |  3 ---
 bundles/pyml/pyml-current/pyml_stubs.c | 12 ------------
 5 files changed, 45 deletions(-)
bundles/pyml/pyml-current/py.ml +0 -12
index fc49bc42..d33dcf77 100644
@@ -36,12 +36,6 @@ external pyerr_fetch_internal: unit -> pyobject * pyobject * pyobject
     = "PyErr_Fetch_wrapper"
 external pystring_asstringandsize: pyobject -> string option
     = "PyString_AsStringAndSize_wrapper"
-external pyobject_ascharbuffer: pyobject -> string option
-    = "PyObject_AsCharBuffer_wrapper"
-external pyobject_asreadbuffer: pyobject -> string option
-    = "PyObject_AsReadBuffer_wrapper"
-external pyobject_aswritebuffer: pyobject -> string option
-    = "PyObject_AsWriteBuffer_wrapper"
 external pylong_fromstring: string -> int -> pyobject * int
     = "PyLong_FromString_wrapper"
 external pycapsule_isvalid: Pytypes.pyobject -> string -> int
@@ -1429,12 +1423,6 @@ module Object = struct
 
   let to_string item = String.to_string (str item)
 
-  let as_char_buffer obj = check_some (pyobject_ascharbuffer obj)
-
-  let as_read_buffer obj = check_some (pyobject_asreadbuffer obj)
-
-  let as_write_buffer obj = check_some (pyobject_aswritebuffer obj)
-
   external reference_count: pyobject -> int = "pyrefcount"
 
   let repr_or_string repr v =
bundles/pyml/pyml-current/py.mli +0 -12
index 19a4599e..df509a02 100644
@@ -239,18 +239,6 @@ module Object: sig
       We have
       [Py.Object.to_string o = Py.String.to_string (Py.Object.str o)]. *)
 
-  val as_char_buffer: t -> string
-  (** Wrapper for
-      {{:https://docs.python.org/3/c-api/objbuffer.html#c.PyObject_AsCharBuffer} PyObject_AsCharBuffer} *)
-
-  val as_read_buffer: t -> string
-  (** Wrapper for
-      {{:https://docs.python.org/3/c-api/objbuffer.html#c.PyObject_AsReadBuffer} PyObject_AsReadBuffer} *)
-
-  val as_write_buffer: t -> string
-  (** Wrapper for
-      {{:https://docs.python.org/3/c-api/objbuffer.html#c.PyObject_AsWriteBuffer} PyObject_AsWriteBuffer} *)
-
   val reference_count: t -> int
   (** [reference_count o] returns the number of references to the Python
       object [o]. *)
bundles/pyml/pyml-current/pycaml.ml +0 -6
index 8c93cf4a..13b16aa8 100644
@@ -347,12 +347,6 @@ let pyunicode_asunicode = Py.String.to_unicode
 
 let pyunicode_getsize = Py.String.length
 
-let pyobject_ascharbuffer = Py.Object.as_char_buffer
-
-let pyobject_asreadbuffer = Py.Object.as_read_buffer
-
-let pyobject_aswritebuffer = Py.Object.as_write_buffer
-
 let python () =
   Py.Run.interactive ();
   0
bundles/pyml/pyml-current/pycaml.mli +0 -3
index 85b5f83c..da800bac 100644
@@ -758,9 +758,6 @@ val pyobject_size : pyobject -> int
 val pyobject_getitem : pyobject * pyobject -> pyobject
 val pyobject_setitem : pyobject * pyobject * pyobject -> int
 val pyobject_delitem : pyobject * pyobject -> int
-val pyobject_ascharbuffer : pyobject -> string
-val pyobject_asreadbuffer : pyobject -> string
-val pyobject_aswritebuffer : pyobject -> string
 
 val pynumber_check : pyobject -> int
 val pynumber_add : pyobject * pyobject -> pyobject
bundles/pyml/pyml-current/pyml_stubs.c +0 -12
index 5158a0e4..cc10e821 100644
@@ -195,12 +195,6 @@ static PyObject *Python__Py_FalseStruct;
 /* Buffer and size */
 static int (*Python_PyString_AsStringAndSize)
 (PyObject *, char **, Py_ssize_t *);
-static int (*Python_PyObject_AsCharBuffer)
-(PyObject *, const char **, Py_ssize_t *);
-static int (*Python_PyObject_AsReadBuffer)
-(PyObject *, const void **, Py_ssize_t *);
-static int (*Python_PyObject_AsWriteBuffer)
-(PyObject *, void **, Py_ssize_t *);
 
 /* Length argument */
 static PyObject *(*Python_PyLong_FromString)(const char *, const char **, int);
@@ -684,9 +678,6 @@ py_load_library(value filename_ocaml, value debug_build_ocaml)
         resolve("PyObject_CallMethodObjArgs");
     Python_PyErr_Fetch = resolve("PyErr_Fetch");
     Python_PyErr_NormalizeException = resolve("PyErr_NormalizeException");
-    Python_PyObject_AsCharBuffer = resolve("PyObject_AsCharBuffer");
-    Python_PyObject_AsReadBuffer = resolve("PyObject_AsReadBuffer");
-    Python_PyObject_AsWriteBuffer = resolve("PyObject_AsWriteBuffer");
     if (version_major >= 3) {
         Python__Py_FalseStruct = resolve("_Py_FalseStruct");
         Python_PyString_AsStringAndSize = resolve("PyBytes_AsStringAndSize");
@@ -1272,9 +1263,6 @@ pyml_wrap_ucs4_option_and_free(int32_t *buffer, bool free)
     }
 
 StringAndSize_wrapper(PyString_AsStringAndSize, char);
-StringAndSize_wrapper(PyObject_AsCharBuffer, const char);
-StringAndSize_wrapper(PyObject_AsReadBuffer, const void);
-StringAndSize_wrapper(PyObject_AsWriteBuffer, void);
 
 static FILE *
 open_file(value file, const char *mode)
Signature · 6 lines
2.28.0.rc2

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
#2 lore raw
In reply to Richard W.M. Jones
Quoted 9 lines · Richard W.M. Jones

Some more functions were deprecated/removed in Python 10, breaking Coccinelle compiles. It was reported by Fedora's Python team here:

https://bugzilla.redhat.com/show_bug.cgi?id=1896393

I have fixed it by chopping out bindings for these functions from the bundled pyml, and it compiles fine for me with Python 10 now.

Erm, Python 3.10, not Python 10 obviously :-)

Rich.

Signature · 10 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
#3 lore raw
Quoted 5 lines · Richard W.M. Jones
Quoted 4 lines · Richard W.M. Jones

Some more functions were deprecated/removed in Python 10, breaking Coccinelle compiles. It was reported by Fedora's Python team here:

Quoted 7 lines
Quoted 5 lines

https://bugzilla.redhat.com/show_bug.cgi?id=1896393

I have fixed it by chopping out bindings for these functions from the bundled pyml, and it compiles fine for me with Python 10 now.

Erm, Python 3.10, not Python 10 obviously :-)

Thanks for the patch.

julia

Quoted 11 lines

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci