8000 Incorrect error place reported in python traceback · Issue #542 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content
Incorrect error place reported in python traceback #542
Closed
@testrunner123

Description

@testrunner123

Environment

  • Pythonnet version: 2.3.0
  • Python version: 3.4 64-bit
  • Operating System: Ubuntu 14.04

Details

  • I tried to run test program and got following:

GetPreferredSize
Traceback (most recent call last):
File "t.py", line 29, in
main()
File "t.py", line 24, in main
form = StatusWindow()
File "t.py", line 19, in init
self.Controls.Add(_StagesGroup())
NameError: name 'xyz' is not defined

As we see, function GetPrefferedSize() got called. But stack traceback shows error in line 19 that is wrong. Bacause error is in line 14.

python3 t.py

import clr, sys
import System.Windows.Forms as WinForms
import System.Drawing as Drawing

class _StagesGroup(WinForms.GroupBox):
    __namespace__ = "System.Windows.Forms"
    def __init__(self):
        self.Text = "Stages"
        self.AutoSize = True

    def GetPreferredSize(self, proposedSize):
        print ("GetPreferredSize")
        retsz = WinForms.GroupBox.GetPreferredSize(self, proposedSize)
        print("GetPreferredSize",xyz)
        return retsz

class StatusWindow(WinForms.Form):
    def __init__(self):
        self.Controls.Add(_StagesGroup())
    def run(self):
        WinForms.Application.Run(self)

def main():
    form = StatusWindow()
    app = WinForms.Application
    app.Run(form)

if __name__ == '__main__':
    main()

So why the error place is incorrect in traceback?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0