Python 我没有调用的函数抛出异常

Python throwing exception for function I didn't call

我有一个具有以下逻辑的函数:

def align(val, al): # This is technically imported from a separate file
    return (val + (al - 1)) & -al

def compileFont(font, output, audiobank_off=0):
    # Get used slot counts
    icount = font.instSlotCount()
    pcount = font.percSlotCount()
    xcount = font.sfxSlotCount()
    
    # Calculate head offset table size
    current_pos = (2 + icount) * packspecs.pointerSize()
    current_pos = align(current_pos, 16)

要清楚,current_pos 是最后一行的整数。但是,当它到达最后一行时,Python 最终抛出以下异常:

Exception has occurred: TypeError       (note: full exception trace is
 shown but execution is paused at: <module>)
object of type 'int' has no len()
  File "tools/assemble_sound.py", line 311, in compileFont
    current_pos = align(current_pos, 16)
  File "tools/assemble_sound.py", line 1020, in main
    compileFont(font, f, aboff)
  File "tools/assemble_sound.py", line 1136, in <module> (Current frame)
    main()

我不知道 len() 在这里是如何发挥作用的。我仔细检查了一下,align() 函数甚至没有调用 len()。有没有人见过这个?我该怎么做才能解决此问题?

编辑:我添加了更多代码和堆栈跟踪以提供额外的上下文。从类型上看,current_pos是int类型。

回溯显然是正确的线索。出于某种原因,当我在 VS Code 中 运行 this 时,它显示的异常堆栈跟踪不完整(如上文所述)。当我从命令行 运行 它时,我得到了这个:

Traceback (most recent call last):
  File "oot/tools/assemble_sound.py", line 1136, in <module>
    main()
  File "oot/tools/assemble_sound.py", line 1020, in main
    compileFont(font, f, aboff)
  File "oot/tools/assemble_sound.py", line 311, in compileFont
    current_pos = align(current_pos, 16)
  File "~/.local/lib/python3.9/site-packages/makeelf/type/align.py", line 8, in align
    full = ceil(len(b) / alignment)
TypeError: object of type 'int' has no len()

这为我指出了正确的方向,它调用了错误的 align() 方法。 VS Code 无法进入 align(),所以我在尝试命令行之前无法弄清楚。