Skip to content

Commit

Permalink
Fix core when None is passed to some YCP functions
Browse files Browse the repository at this point in the history
e.g. examples/Table1.py

has

            Table(
              Header(
                "\u00C4nerhe\u00DF",
                "\u00C4\u00DF\u00F6\u00F6\u00E4\u00E4\u00E4\u00E4\u00E4"
              ),
              [
                Item(
                  Id('1'),
                  "\u011B\u0161\u010D\u0159\u017E\u00FD\u00E1\u00ED\u02C7",
                  6
                ),
=>              Item(Id(2), "\u011B\u0161\u0159\u017E", None),
                Item(Id(3), "\u00C4nder\u00DF\u00DF\u00DF", 8),

where the value of the TableItem is passed None, this results in the
following core

(gdb) where

 #0  YCPValueRep::isTerm() const (this=0x0) at YCPValue.cc:70
 #1  0x00007ffff48c1974 in YCPTableItemParser::parseTableItem(YCPTerm const&) (itemTerm=...) at YCPTableItemParser.cc:117
 #2  0x00007ffff48c13e0 in YCPTableItemParser::parseTableItemList(YCPList const&) (itemList=...) at YCPTableItemParser.cc:60
 #3  0x00007ffff489ad44 in YCPDialogParser::parseTable(YWidget*, YWidgetOpt&, YCPTerm const&, YCPList const&, int) (parent=parent@entry=0x7fffe840ee30, opt=..., term=..., optList=..., argnr=0) at YCPDialogParser.cc:2604
 #4  0x00007ffff48b151d in YCPDialogParser::parseWidgetTreeTerm(YWidget*, YWidgetOpt&, YCPTerm const&) (p=p@entry=0x7fffe840ee30, opt=..., term=...) at YCPDialogParser.cc:311
 #5  0x00007ffff48b1c9a in YCPDialogParser::parseWidgetTreeTerm(YWidget*, YCPTerm const&) (parent=parent@entry=0x7fffe840ee30, term=...) at YCPDialogParser.cc:413
 #6  0x00007ffff48b373a in YCPDialogParser::parseMinSize(YWidget*, YWidgetOpt&, YCPTerm const&, YCPList const&, int, bool, bool) (parent=parent@entry=0x7fffe831eab0, opt=..., term=..., optList=..., argnr=<optimized out>, hor=<optimized out>, vert=true) at YCPDialogParser.cc:713

so it appears the correct translation for Py_None is YCP_Void()
rather than YCP_Null()

Signed-off-by: Noel Power <noel.power@suse.com>
  • Loading branch information
noelpower committed Feb 8, 2023
1 parent 8b4c3a3 commit 775cef3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ytypes.i
Expand Up @@ -5,7 +5,7 @@ YCPValue pyval_to_ycp(PyObject *input)
void *arg = 0;

if (input == Py_None)
return YCPNull();
return YCPVoid();
if (PyBool_Check(input)) {
#if PY_MAJOR_VERSION >= 3
if (PyObject_RichCompareBool(input, Py_True, Py_EQ) == 1)
Expand Down

0 comments on commit 775cef3

Please sign in to comment.