bugGNU Octave - Bugs: bug #66820, [octave forge] (pythonic) wiki...

 
 

bug #66820: [octave forge] (pythonic) wiki example not working

Submitter:  Muhali <muhali>
Submitted:  Wed 19 Feb 2025 04:54:35 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 9.2.0 Release: 
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 14 Mar 2025 05:20:54 AM UTC, comment #7: 

The package looks to be in a terrible shape.
I posted some additional patches on
https://gitlab.com/gnu-octave/octave-pythonic/-/issues/133

I see 7 errors now.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 14 Mar 2025 02:25:16 AM UTC, comment #6: 

"pkg test pythonic" dtill fails left ant right, but no crash (with the previous patch applied):

octave:3> pkg test pythonic
Testing functions in package 'pythonic':

Integrated test scripts:

                                                                                  [ CPU    /  CLOCK ]
  ...local/share/octave/api-v60/packages/pythonic-0.1.3+/@py/py.m  pass    2/5    [ 0.248s /  0.251s]
                                                                   FAIL    2
                                                (expected failure) XFAIL   1
  ..hare/octave/api-v60/packages/pythonic-0.1.3+/@pyobject/cell.m  pass    4/9    [ 0.188s /  0.190s]
                                                                   FAIL    5
  ..ctave/api-v60/packages/pythonic-0.1.3+/@pyobject/fieldnames.m  pass    1/5    [ 0.116s /  0.117s]
                                                                   FAIL    4
  ..e/octave/api-v60/packages/pythonic-0.1.3+/@pyobject/methods.m  pass    3/9    [ 0.195s /  0.197s]
                                                                   FAIL    6
  ../octave/api-v60/packages/pythonic-0.1.3+/@pyobject/pyobject.m  pass   51/90   [ 1.352s /  1.366s]
                                                                   FAIL   39
  ../octave/api-v60/packages/pythonic-0.1.3+/@pyobject/subsasgn.m  pass    3/7    [ 0.175s /  0.176s]
                                                                   FAIL    2
                                                (expected failure) XFAIL   2
  ..e/octave/api-v60/packages/pythonic-0.1.3+/@pyobject/subsref.m  pass   10/26   [ 0.489s /  0.494s]
                                                                   FAIL   13
                                                (expected failure) XFAIL   3
  ..3+/x86_64-pc-linux-gnu-api-v60/__py_struct_from_dict__.cc-tst  pass   66/73   [ 0.872s /  0.888s]
                                                                   FAIL    7
  ..ges/pythonic-0.1.3+/x86_64-pc-linux-gnu-api-v60/pycall.cc-tst  pass   43/62   [ 0.592s /  0.603s]
                                                                   FAIL   19
  ..ges/pythonic-0.1.3+/x86_64-pc-linux-gnu-api-v60/pyeval.cc-tst  pass   25/31   [ 0.500s /  0.506s]
                                                                   FAIL    6
  ..ges/pythonic-0.1.3+/x86_64-pc-linux-gnu-api-v60/pyexec.cc-tst  pass    2/2    [ 0.044s /  0.045s]
  ..ctave/api-v60/packages/pythonic-0.1.3+/__py_objstore_disp__.m  pass    1/1    [ 0.038s /  0.039s]
  ...local/share/octave/api-v60/packages/pythonic-0.1.3+/pyargs.m  pass    3/7    [ 0.097s /  0.099s]
                                                                   FAIL    4
  ..ocal/share/octave/api-v60/packages/pythonic-0.1.3+/pythonic.m  pass    2/2    [ 0.063s /  0.064s]
  ..cal/share/octave/api-v60/packages/pythonic-0.1.3+/pyversion.m  pass    5/6    [ 0.092s /  0.093s]
                                                                   FAIL    1

Fixed test scripts:

                                                        total time (CPU / CLOCK)  [   5.9s /    5.9s]
Failure Summary:

  ...local/share/octave/api-v60/packages/pythonic-0.1.3+/@py/py.m  pass    2/5
                                                                   FAIL    2
                                                (expected failure) XFAIL   1
  ..hare/octave/api-v60/packages/pythonic-0.1.3+/@pyobject/cell.m  pass    4/9
                                                                   FAIL    5
  ..ctave/api-v60/packages/pythonic-0.1.3+/@pyobject/fieldnames.m  pass    1/5
                                                                   FAIL    4
  ..e/octave/api-v60/packages/pythonic-0.1.3+/@pyobject/methods.m  pass    3/9
                                                                   FAIL    6
  ../octave/api-v60/packages/pythonic-0.1.3+/@pyobject/pyobject.m  pass   51/90
                                                                   FAIL   39
  ../octave/api-v60/packages/pythonic-0.1.3+/@pyobject/subsasgn.m  pass    3/7
                                                                   FAIL    2
                                                (expected failure) XFAIL   2
  ..e/octave/api-v60/packages/pythonic-0.1.3+/@pyobject/subsref.m  pass   10/26
                                                                   FAIL   13
                                                (expected failure) XFAIL   3
  ..3+/x86_64-pc-linux-gnu-api-v60/__py_struct_from_dict__.cc-tst  pass   66/73
                                                                   FAIL    7
  ..ges/pythonic-0.1.3+/x86_64-pc-linux-gnu-api-v60/pycall.cc-tst  pass   43/62
                                                                   FAIL   19
  ..ges/pythonic-0.1.3+/x86_64-pc-linux-gnu-api-v60/pyeval.cc-tst  pass   25/31
                                                                   FAIL    6
  ...local/share/octave/api-v60/packages/pythonic-0.1.3+/pyargs.m  pass    3/7
                                                                   FAIL    4
  ..cal/share/octave/api-v60/packages/pythonic-0.1.3+/pyversion.m  pass    5/6
                                                                   FAIL    1

Summary:

  PASS                              221
  FAIL                              108
  XFAIL (expected failure)            6


Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 14 Mar 2025 01:28:25 AM UTC, comment #5: 

The following diff (also attached) fixes crash for me:

diff --git a/src/Makefile b/src/Makefile
index fbc5c1f..c0a7a22 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -30,7 +30,6 @@ SED             ?= sed

 ARFLAGS  = cr

-export CXXFLAGS ?= -g -O2

 srcdir = .

diff --git a/src/oct-py-types.cc b/src/oct-py-types.cc
index a863344..831a6bb 100644
--- a/src/oct-py-types.cc
+++ b/src/oct-py-types.cc
@@ -407,8 +407,21 @@ namespace pythonic
     if (PyLong_Check (obj))
       {
         // FIXME: if (value < 0), may be very implementation dependent
-        if (Py_SIZE (obj) < 0)
+        // if (Py_SIZE (obj) < 0)
+
+        // Check if the number is negative
+        // In Python 3.13+, we can't use Py_SIZE on PyLong objects
+        // Instead, check if the number is negative by comparing with zero
+        // using a public API
+        int is_negative = PyObject_RichCompareBool(obj, PyLong_FromLong(0), Py_LT);
+        if (is_negative == 1)
           return 0;
+        else if (is_negative == -1)
+          // If the comparison fails for some reason (returns -1),
+          // just call PyErr_Clear() to clear that exception and allow
+          // the code to continue execution.
+          // Is there a better way to handle it?
+          PyErr_Clear();

 #if (defined (HAVE_LONG_LONG) && (SIZEOF_LONG_LONG == 8))
         unsigned PY_LONG_LONG value = PyLong_AsUnsignedLongLong (obj);


but I really do not know this code, so it could be completely superficial and wrong.

Dmitri.
--


(file #57014)

Dmitri A. Sergatskov <dasergatskov>
Fri 14 Mar 2025 01:07:29 AM UTC, comment #4: 

In oct-py-types.cc (line 410):

if (PyLong_Check (obj))
{
  // FIXME: if (value < 0), may be very implementation dependent
  if (Py_SIZE (obj) < 0)
    return 0;


but this comarison is illegal now:
there is a check in the Py_SIZE macro
(/usr/include/python3.13/object.h line 347):

static inline Py_ssize_t Py_SIZE(PyObject *ob) {
    assert(ob->ob_type != &PyLong_Type);
    assert(ob->ob_type != &PyBool_Type);
    return  _PyVarObject_CAST(ob)->ob_size;
}


Looks like it is time to fix this FIXME :)

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 14 Mar 2025 12:43:30 AM UTC, comment #3: 

It crashes for me too:

Thread 1 (Thread 0x7f4d22d07940 (LWP 328499)):
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007f4d23c7fbc3 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:78
#2  0x00007f4d23c26f9e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007f4d23c0e942 in __GI_abort () at abort.c:79
#4  0x00007f4d23c0e85e in __assert_fail_base (fmt=0x7f4d23dc3cb0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x7f4c1e8d9802 "ob->ob_type != &PyLong_Type", file=file@entry=0x7f4c1e8d8273 "/usr/include/python3.13/object.h", line=line@entry=347, function=function@entry=0x7f4c1e8d981e "Py_ssize_t Py_SIZE(PyObject *)") at assert.c:96
#5  0x00007f4d23c1f0c7 in __assert_fail (assertion=0x7f4c1e8d9802 "ob->ob_type != &PyLong_Type", file=0x7f4c1e8d8273 "/usr/include/python3.13/object.h", line=347, function=0x7f4c1e8d981e "Py_ssize_t Py_SIZE(PyObject *)") at assert.c:105
#6  0x00007f4c1e889509 in Py_SIZE (ob=0x7f4c10111f90 <_PyRuntime+14000>) at /usr/include/python3.13/object.h:347
#7  0x00007f4c1e88918d in pythonic::extract_py_uint64 (obj=0x7f4c10111f90 <_PyRuntime+14000>) at oct-py-types.cc:410
#8  0x00007f4c1e8739cd in F__py_uint64_scalar_value__ (args=...) at __py_struct_from_dict__.cc:142
#9  0x00007f4d2c9d7f59 in octave::tree_evaluator::execute_builtin_function (this=0x3fd6e5d8, builtin_function=..., nargout=1, args=...) at ../libinterp/parse-tree/pt-eval.cc:3551
...

Full coredump is attached.
Perhaps somebody Cc to Colin Macdonald (who is current maintainer).

I had to remove CXXFLAGS from src/Makefile so it would respect mine and I can get a decent trace.

Dmitri.
--


(file #57013)

Dmitri A. Sergatskov <dasergatskov>
Thu 13 Mar 2025 09:42:57 PM UTC, comment #2: 

Adding @mtmiller, the package maintainer, to the recipient list.

Pantxo Diribarne <pantxo>
Group Member
Thu 13 Mar 2025 09:39:35 PM UTC, comment #1: 

I can confirm this failure. The curly braces indexing (`x{1}`) seems to work though. For me `pkg test pythonic` shows a number of test failures and then crashes Octave:


octave:1> pkg load pythonic
octave:2> pyversion
       version: "3.12"
    executable: "/usr/bin/python3"
       library: "/usr/lib/x86_64-linux-gnu/x86_64-linux-gnu/libpython3.12.so"
        prefix: "/usr"
        loaded: 1
octave:3> pkg test pythonic
Testing functions in package 'pythonic':

Integrated test scripts:

                                                                                  [ CPU    /  CLOCK ]
  ../.local/share/octave/api-v59/packages/pythonic-0.1.3/@py/py.m  pass    4/5    [ 0.120s /  0.120s]
                                                (expected failure) XFAIL   1
  ..share/octave/api-v59/packages/pythonic-0.1.3/@pyobject/cell.m  pass    9/9    [ 0.050s /  0.050s]
  ..octave/api-v59/packages/pythonic-0.1.3/@pyobject/fieldnames.m  pass    5/5    [ 0.035s /  0.035s]
  ..re/octave/api-v59/packages/pythonic-0.1.3/@pyobject/methods.m  pass    9/9    [ 0.119s /  0.119s]
  ..e/octave/api-v59/packages/pythonic-0.1.3/@pyobject/pyobject.m  pass   87/90   [ 0.204s /  0.204s]
                                                                   FAIL    3
  ..e/octave/api-v59/packages/pythonic-0.1.3/@pyobject/subsasgn.m  pass    5/7    [ 0.031s /  0.031s]
                                                (expected failure) XFAIL   2
  ..re/octave/api-v59/packages/pythonic-0.1.3/@pyobject/subsref.m  pass   22/26   [ 0.089s /  0.089s]
                                                                   FAIL    1
                                                (expected failure) XFAIL   3
  ...3/x86_64-pc-linux-gnu-api-v59/__py_struct_from_dict__.cc-tst octave-gui: /usr/include/python3.12/object.h :231 : Py_ssize_t Py_SIZE(PyObject*):  l'assertion « ob->ob_type != &PyLong_Type » a échoué.
fatal: caught signal Abandon -- stopping myself...
Abandon (core dumped)


So it looks like the package is indeed partly broken currently.

Pantxo Diribarne <pantxo>
Group Member
Wed 19 Feb 2025 04:54:35 PM UTC, original submission:  

the first example from the wiki does not seem to work:

x = pyeval ("{1:'one',2:'two'}");
x.("1")

error: AttributeError: 'dict' object has no attribute '1'
error: called from
    subsref at line 44 column 9

Is the package still maintained?

Muhali <muhali>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #57014:  das_pythonic.diff.gz added by dasergatskov (703B - application/gzip)
file #57013:  coredump_pythonic.txt.gz added by dasergatskov (4KiB - application/gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Updated the item)
  • -email is unavailable- added by pantxo
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by muhali (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-03-14 dasergatskov Attached File- Added das_pythonic.diff.gz, #57014
    2025-03-14 dasergatskov Attached File- Added coredump_pythonic.txt.gz, #57013
    2025-03-13 pantxo Item GroupNone Unexpected Error or Warning
        StatusNone Confirmed
        Carbon-Copy- Added mtmiller

    Back to the top

    Powered by Savane 3.14-7003.
    Corresponding source code