Class UnboundLocalError
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
Python's UnboundLocalError: a local variable read before any value was bound to it
(cannot access local variable 'x' where it is not associated with a value).
public class UnboundLocalError : NameError, ISerializable, INumSharpException
- Inheritance
-
UnboundLocalError
- Implements
- Inherited Members
Remarks
A subclass of NameError, as in Python, so catch (NameError) catches it and it carries
name.
NumSharp never raises it: C#'s definite-assignment rules make the situation a compile error. The class exists so a port of code that raises or catches it compiles and behaves as in Python.
Constructors
UnboundLocalError()
Creates the error with Python's text for a bare raise UnboundLocalError: an empty
Message, as str(UnboundLocalError()) is ''.
public UnboundLocalError()
Remarks
ToString() then starts with the class name alone, as Python's traceback prints a
bare UnboundLocalError.
UnboundLocalError(string)
Creates the error with the interpreter's (or the port's) message; name stays null.
public UnboundLocalError(string message)
Parameters
messagestringThe text, verbatim (
cannot access local variable 'x' where it is not associated with a value).
UnboundLocalError(string, Exception)
Creates the error with a message and the exception that caused it: Python's raise
UnboundLocalError(message) from innerException, the cause kept in InnerException;
name stays null.
public UnboundLocalError(string message, Exception innerException)
Parameters
messagestringThe text, verbatim.
innerExceptionExceptionThe exception that led to this one, or null for none.
UnboundLocalError(string, string)
Python's UnboundLocalError(message, name=name): the message and the unbound name.
public UnboundLocalError(string message, string name)
Parameters
Remarks
Footgun, as for NameError(string, string): a literal null second argument is
ambiguous with the cause form; cast it ((string)null).