Mailinglist Archive: yast-devel (144 mails)

< Previous Next >
Re: [yast-devel] Slight incompatibility between Ruby and YCP
On Thu, 1 Aug 2013 13:11:16 +0200
Thomas Fehr <fehr@xxxxxxx> wrote:


I think I found a slight incompatibility between Ruby and YCP

in YCP, I have the following code:

map btrfs = GetTargetMap()["/dev/btrfs"]:$[];
map ret = filter( map p, btrfs["partitions"]:[],

which, in case of an empty list returned by filter call, relies on
default parameter "$[]" after index operation.

In RUby this is:

btrfs = Ops.get(GetTargetMap(), "/dev/btrfs", {})
ret = Ops.get(
Builtins.filter(Ops.get_list(btrfs, "partitions", [])) do |p|
Ops.get_string(p, "uuid", "") == uuid

This works as before in assigning empty map to ret, but it now has
the side effect of a line being written to y2log stating:
[Ruby] yast/ops.rb:62 Index 0 is out of array size
while the equivalent YCP code did not create any y2log entries.

Is this intentional?
Depending on the number of occurrences of such accesses in YCP code it
could clutter y2log a lot.

Thomas Fehr

Hi Thomas,
at first it is feature of ruby bindings that can be disabled, but I
found it quite useful, because for me it is usually indication of error
if you access array out of its index.
If team agree then it can be removed at
But you detect also another bug, that integer passed to log should be
inside while cycle 2 and not 1, so you get where in your code you
access out of array dimensions.
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >