You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Alexey Neyman <st...@att.net> on 2010/03/04 21:40:56 UTC
Bug with svn_txdelta_window_t Python binding?
Hi all,
It looks like there's a bug with Python binding for the
svn_txdelta_window_t structure. The problem is that the 'ops' array is
mapped to Python as a single object, not as a sequence of 'num_ops'
items. That is, the following code for apply_textdelta does not work:
def apply_textdelta(self, file_baton, base_checksum):
self.dbg(("apply_textdelta to %s" % (file_baton[0])))
def txdelta_handler(window):
if window is None:
self.dbg("txdelta - stop")
else:
self.dbg(("txdelta - %s [%d,%d] [X,%d] %d %d" %
(file_baton[0], window.sview_offset, window.sview_len,
window.tview_len, window.src_ops, window.num_ops)))
for o in window.ops:
self.dbg((" op: %d,%d,%d" % (o.action_code, o.offset, o.length)))
return txdelta_handler
It fails with the error that "for o in window.ops: TypeError: iteration
over non-sequence". The following code works, but it can only access the
first item in the 'ops' array:
self.dbg((" op: %d,%d,%d" %
(window.ops.action_code, window.ops.offset, window.ops.length)))
I am not a SWIG expert; could someone confirm if it's a bug in SWIG Python
bindings?
Regards,
Alexey.
Re: Bug with svn_txdelta_window_t Python binding?
Posted by Alexey Neyman <st...@att.net>.
On Tuesday, August 03, 2010 04:26:58 pm Роман Донченко wrote:
> Alexey Neyman <st...@att.net> писал в своём письме Fri, 12 Mar 2010
>
> 01:23:47 +0300:
> > On Thursday 11 March 2010 02:05:56 pm Роман Донченко wrote:
> >> Alexey Neyman <st...@att.net> писал в своём письме Fri, 12 Mar 2010
> >>
> >> 00:25:12 +0300:
> >> > Sorry to bug you, but are you working on a fix for this, or just
> >> > confirmed
> >> > it's a bug (in which case, I need to submit it to issues DB, I
> >> > guess)?
> >> >
> >> > Best regards,
> >> > Alexey.
> >>
> >> I've entered it into my TODO list, and I will (hopefully) fix it the
> >> next time I'm hacking on the bindings. I'm just kind of busy with other
> >> stuff right now.
> >
> > Thanks! Just checking so that it does not get lost.
> >
> > Regards,
> > Alexey.
>
> Well, guess what. I actually got a round tuit, and fixed this. For the
> record, this happened in r981683, r981701 and r982064.
>
> Roman.
Thanks! I updated issue 3688 to reflect that.
Regards,
Alexey.
Re: Bug with svn_txdelta_window_t Python binding?
Posted by Роман Донченко <DX...@yandex.ru>.
Alexey Neyman <st...@att.net> писал в своём письме Fri, 12 Mar 2010
01:23:47 +0300:
> On Thursday 11 March 2010 02:05:56 pm Роман Донченко wrote:
>> Alexey Neyman <st...@att.net> писал в своём письме Fri, 12 Mar 2010
>>
>> 00:25:12 +0300:
>> > Sorry to bug you, but are you working on a fix for this, or just
>> > confirmed
>> > it's a bug (in which case, I need to submit it to issues DB, I
>> > guess)?
>> >
>> > Best regards,
>> > Alexey.
>>
>> I've entered it into my TODO list, and I will (hopefully) fix it the
>> next time I'm hacking on the bindings. I'm just kind of busy with other
>> stuff right now.
>
> Thanks! Just checking so that it does not get lost.
>
> Regards,
> Alexey.
>
Well, guess what. I actually got a round tuit, and fixed this. For the
record, this happened in r981683, r981701 and r982064.
Roman.
Re: Bug with svn_txdelta_window_t Python binding?
Posted by Alexey Neyman <st...@att.net>.
On Thursday 11 March 2010 02:05:56 pm Роман Донченко wrote:
> Alexey Neyman <st...@att.net> писал в своём письме Fri, 12 Mar 2010
>
> 00:25:12 +0300:
> > Sorry to bug you, but are you working on a fix for this, or just
> > confirmed
> > it's a bug (in which case, I need to submit it to issues DB, I
> > guess)?
> >
> > Best regards,
> > Alexey.
>
> I've entered it into my TODO list, and I will (hopefully) fix it the
> next time I'm hacking on the bindings. I'm just kind of busy with other
> stuff right now.
Thanks! Just checking so that it does not get lost.
Regards,
Alexey.
Re: Bug with svn_txdelta_window_t Python binding?
Posted by Роман Донченко <DX...@yandex.ru>.
Alexey Neyman <st...@att.net> писал в своём письме Fri, 12 Mar 2010
00:25:12 +0300:
> Sorry to bug you, but are you working on a fix for this, or just
> confirmed
> it's a bug (in which case, I need to submit it to issues DB, I guess)?
>
> Best regards,
> Alexey.
I've entered it into my TODO list, and I will (hopefully) fix it the next
time I'm hacking on the bindings. I'm just kind of busy with other stuff
right now.
Roman.
Re: Bug with svn_txdelta_window_t Python binding?
Posted by Alexey Neyman <st...@att.net>.
On Monday 08 March 2010 11:59:28 am Роман Донченко wrote:
> Alexey Neyman <st...@att.net> писал в своём письме Mon, 08 Mar 2010
>
> 20:29:41 +0300:
> > Any experts on Python bindings on this list? :)
> >
> > Could this at least be confirmed to be a bug, so that I could enter
> > it into issues database?
>
> Um, I'm standing right here. 8=]
>
> http://permalink.gmane.org/gmane.comp.version-control.subversion.devel/
>118547
Sorry, I somehow missed your reply.
Please find a test script attached. It should abort the commit (so that
stderr from pre-commit script is seen) and dump the 'ops' list contents.
Instead, it produces a traceback:
======================================
Transmitting file data .svn: Commit failed (details follow):
svn: Commit blocked by pre-commit hook (exit code 1) with output:
@DEBUG@ open_file foo
@DEBUG@ apply_textdelta to foo
@DEBUG@ txdelta received on foo src[0,1333] tgt[X,1391] src_ops 2 num_ops
4
@DEBUG@ new_data 'medextra new line
'
Traceback (most recent call last):
File "/tmp/test-repo/hooks/pre-commit", line 62, in <module>
core.run_app(verify, sys.argv[1], sys.argv[2])
File "/usr/local/lib/svn-python/svn/core.py", line 281, in run_app
return func(application_pool, *args, **kw)
File "/tmp/test-repo/hooks/pre-commit", line 56, in verify
repos.svn_repos_replay2(txn_root, "", -1, True, e_ptr, e_baton, None,
pool)
File "/usr/local/lib/svn-python/libsvn/repos.py", line 311, in
svn_repos_replay2
return apply(_repos.svn_repos_replay2, args)
File "/tmp/test-repo/hooks/pre-commit", line 45, in txdelta_handler
for op in window.ops:
TypeError: iteration over non-sequence
====================================
As a side note, I think that 'num_ops' and 'src_ops' should be
declared %immutable and only changed via assignment to 'ops'.
Perhaps, 'ops' should also be made read-only, as it doesn't make much
sense to allow assignments to 'ops' while having 'new_data' as read-only
('ops' refer to certain parts in 'new_data', and 'new_data' is currently
declared %immutable).
Regards,
Alexey.
Re: Bug with svn_txdelta_window_t Python binding?
Posted by Роман Донченко <DX...@yandex.ru>.
Alexey Neyman <st...@att.net> писал в своём письме Mon, 08 Mar 2010
20:29:41 +0300:
> Any experts on Python bindings on this list? :)
>
> Could this at least be confirmed to be a bug, so that I could enter it
> into issues database?
Um, I'm standing right here. 8=]
http://permalink.gmane.org/gmane.comp.version-control.subversion.devel/118547
Re: Bug with svn_txdelta_window_t Python binding?
Posted by Alexey Neyman <st...@att.net>.
Any experts on Python bindings on this list? :)
Could this at least be confirmed to be a bug, so that I could enter it
into issues database?
Regards,
Alexey
On Thursday 04 March 2010 01:40:56 pm Alexey Neyman wrote:
> Hi all,
>
> It looks like there's a bug with Python binding for the
> svn_txdelta_window_t structure. The problem is that the 'ops' array is
> mapped to Python as a single object, not as a sequence of 'num_ops'
> items. That is, the following code for apply_textdelta does not work:
>
> def apply_textdelta(self, file_baton, base_checksum):
> self.dbg(("apply_textdelta to %s" % (file_baton[0])))
> def txdelta_handler(window):
> if window is None:
> self.dbg("txdelta - stop")
> else:
> self.dbg(("txdelta - %s [%d,%d] [X,%d] %d %d" %
> (file_baton[0], window.sview_offset, window.sview_len,
> window.tview_len, window.src_ops, window.num_ops)))
> for o in window.ops:
> self.dbg((" op: %d,%d,%d" % (o.action_code, o.offset,
> o.length))) return txdelta_handler
>
> It fails with the error that "for o in window.ops: TypeError: iteration
> over non-sequence". The following code works, but it can only access
> the first item in the 'ops' array:
>
> self.dbg((" op: %d,%d,%d" %
> (window.ops.action_code, window.ops.offset, window.ops.length)))
>
> I am not a SWIG expert; could someone confirm if it's a bug in SWIG
> Python bindings?
>
> Regards,
> Alexey.
Re: Bug with svn_txdelta_window_t Python binding?
Posted by Роман Донченко <DX...@yandex.ru>.
Alexey Neyman <st...@att.net> писал в своём письме Fri, 05 Mar 2010
00:40:56 +0300:
> Hi all,
>
> It looks like there's a bug with Python binding for the
> svn_txdelta_window_t structure. The problem is that the 'ops' array is
> mapped to Python as a single object, not as a sequence of 'num_ops'
> items. That is, the following code for apply_textdelta does not work:
>
> def apply_textdelta(self, file_baton, base_checksum):
> self.dbg(("apply_textdelta to %s" % (file_baton[0])))
> def txdelta_handler(window):
> if window is None:
> self.dbg("txdelta - stop")
> else:
> self.dbg(("txdelta - %s [%d,%d] [X,%d] %d %d" %
> (file_baton[0], window.sview_offset, window.sview_len,
> window.tview_len, window.src_ops, window.num_ops)))
> for o in window.ops:
> self.dbg((" op: %d,%d,%d" % (o.action_code, o.offset,
> o.length)))
> return txdelta_handler
>
> It fails with the error that "for o in window.ops: TypeError: iteration
> over non-sequence". The following code works, but it can only access the
> first item in the 'ops' array:
>
> self.dbg((" op: %d,%d,%d" %
> (window.ops.action_code, window.ops.offset, window.ops.length)))
>
> I am not a SWIG expert; could someone confirm if it's a bug in SWIG
> Python
> bindings?
Confirmed. Since 'ops' is declared as a const svn_txdelta_op_t *, SWIG
can't automatically deduce that it's an array. I'll see what I can do.
By the way, can you submit a complete test case? It would tremendously
help to fix this.
Thanks,
Roman.