https://bugs.kde.org/show_bug.cgi?id=369367

            Bug ID: 369367
           Summary: Caught exceptions get wrong scope (py3 change)
           Product: kdev-python
           Version: 5.0.1
          Platform: Other
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: Language support
          Assignee: m...@svenbrauch.de
          Reporter: nicolas.alva...@gmail.com

Python3 has changed the scoping for exceptions caught in an 'except..as'
statement. The Python3 documentation says: "When an exception has been assigned
using "as target", it is cleared at the end of the except clause. This means
the exception must be assigned to a different name to be able to refer to it
after the except clause."

Sample code:

try:
    a=1/0
except Exception as exc:
    print("1", exc)

print("2", exc)

If I run this on Python2, it prints "division by zero" twice. If I run it on
Python3, it prints "division by zero" in print #1, and then raises a NameError
in #2 because 'exc' is not defined.

KDevelop still follows the Python2 scoping in this case, and 'exc' is still
highlighted as a use of the variable in the second 'print' call.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to