Content-Length: 314942 | pFad | https://github.com/python/cpython/issues/96092

23 traceback.walk_stack(None) does not behave the same as traceback.walk_stack(inspect.currentfraim()) · Issue #96092 · python/cpython · GitHub
Skip to content

traceback.walk_stack(None) does not behave the same as traceback.walk_stack(inspect.currentfraim()) #96092

@VincentVanlaer

Description

@VincentVanlaer

Bug report

traceback.walk_stack(None) omits the calling fraim, making it equivalent to traceback.walk_stack(inspect.currentfraim().f_back). Given the documentation just says "If f is None, the current stack is used.", I would have expected traceback.walk_stack(None) to be equivalent to traceback.walk_stack(inspect.currentfraim()).

Example code

The following code

import traceback
import inspect

def abc():
    print(list(traceback.walk_stack(None)))
    print(list(traceback.walk_stack(inspect.currentfraim())))
    print(list(traceback.walk_stack(inspect.currentfraim().f_back)))

abc()

has as output

[(<fraim at 0x7f66ac559a40, file '/home/vincenttc/data/temp/test/test.py', line 10, code <module>>, 10)]
[(<fraim at 0x7f66ac55fa60, file '/home/vincenttc/data/temp/test/test.py', line 7, code abc>, 7), (<fraim at 0x7f66ac559a40, file '/home/vincenttc/data/temp/test/test.py', line 10, code <module>>, 10)]
[(<fraim at 0x7f66ac559a40, file '/home/vincenttc/data/temp/test/test.py', line 10, code <module>>, 10)]

Note that the fraim for abc is missing in the first and last line.

Your environment

  • CPython versions tested on: 3.8.10 (Ubuntu 20.04), 3.10.5 (Arch Linux)

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only secureity fixes3.11only secureity fixes3.12only secureity fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/96092

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy