[Python-Dev] Nested scopes core dump

Ka-Ping Yee ping@lfw.org
Mon, 19 Mar 2001 13:07:10 -0800 (PST)


I just tried this:

    Python 2.1b1 (#15, Mar 16 2001, 04:31:43) 
    [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
    Type "copyright", "credits" or "license" for more information.
    >>> from __future__ import nested_scopes
    >>> def f(x):
    ...     x = x + 1
    ...     a = x + 3
    ...     b = x + 5
    ...     def g(y):
    ...         def h(z):
    ...             return a, b, x, y, z
    ...         return h
    ...     return g
    ...
    Fatal Python error: non-string found in code slot
    Aborted (core dumped)

gdb says v is NULL:

    #5  0x8059cce in PyCode_New (argcount=1, nlocals=2, stacksize=5, flags=3, code=0x8144688, consts=0x8145c1c, names=0x8122974, varnames=0x8145c6c, freevars=0x80ecc14, cellvars=0x81225d4, filename=0x812f900, name=0x810c288, firstlineno=5, lnotab=0x8144af0) at Python/compile.c:279
    279             intern_strings(freevars);
    (gdb) down
    #4  0x8059b80 in intern_strings (tuple=0x80ecc14) at Python/compile.c:233
    233                             Py_FatalError("non-string found in code slot");
    (gdb) list 230
    225     static int
    226     intern_strings(PyObject *tuple)
    227     {
    228             int i;
    229
    230             for (i = PyTuple_GET_SIZE(tuple); --i >= 0; ) {
    231                     PyObject *v = PyTuple_GET_ITEM(tuple, i);
    232                     if (v == NULL || !PyString_Check(v)) {
    233                             Py_FatalError("non-string found in code slot");
    234                             PyErr_BadInternalCall();
    (gdb) print v
    $1 = (PyObject *) 0x0

Hope this helps (this test should probably be added to test_scope.py too),


-- ?!ng

Happiness comes more from loving than being loved; and often when our
affection seems wounded it is is only our vanity bleeding. To love, and
to be hurt often, and to love again--this is the brave and happy life.
    -- J. E. Buchrose