[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] swig-py svn_stream_t read() glue

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Thu, 4 Jan 2018 04:55:43 +0000

svn_swig_py_make_stream() is a function that wraps a PyObject in an
svn_stream_t. Its read implementation, read_handler_pyio(), just calls
the PyObject's .read() method.

According to <https://docs.python.org/2/library/io.html#io.RawIOBase.read>,
the read() method of "raw" file-like objects makes only one read(2)
syscall, and so may return fewer bytes than were requested. (The py3
docs are similar.)

However, svn_stream_t "full read" functions are obligated to return the
number of bytes requested, unless EOF.

Therefore, do we need the following patch?

[[[
swig-py: Support raw binary file-like objects for readable svn_stream_t*
parameters. [D:bindings]

* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
  (svn_swig_py_make_stream): Declare read_handler_pyio() as a non-full
    svn_read_fn_t, in case PY_IO is a raw binary file object.
]]]

[[[
Index: subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
===================================================================
--- subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c (revision 1819751)
+++ subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c (working copy)
@@ -2578,8 +2578,7 @@ svn_swig_py_make_stream(PyObject *py_io, apr_pool_
   svn_stream_t *stream;
 
   stream = svn_stream_create(py_io, pool);
- svn_stream_set_read2(stream, NULL /* only full read support */,
- read_handler_pyio);
+ svn_stream_set_read2(stream, read_handler_pyio, NULL);
   svn_stream_set_write(stream, write_handler_pyio);
   svn_stream_set_close(stream, close_handler_pyio);
   apr_pool_cleanup_register(pool, py_io, svn_swig_py_stream_destroy,
]]]

Cheers,

Daniel
Received on 2018-01-04 05:55:51 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.