Table of Contents

Class IndentationError

Namespace
NumSharp
Assembly
NumSharp.dll

Python's IndentationError: source whose indentation is wrong (unexpected indent, expected an indented block).

public class IndentationError : SyntaxError, ISerializable, INumSharpException
Inheritance
IndentationError
Implements
Derived
Inherited Members

Remarks

A subclass of SyntaxError, as in Python, with the same location attributes and the same text rules (a bare one reads None). Its own subclass is TabError.

NumSharp never raises it (NumPy's literal parsing never sees indentation); the class exists so a port of code that raises or catches it compiles and behaves as in Python.

Constructors

IndentationError()

Creates the error with Python's text for a bare raise IndentationError: "None", as for SyntaxError().

public IndentationError()

Remarks

Every location attribute, msg included, is null.

IndentationError(string)

Creates the error with the parser's message, which is also msg.

public IndentationError(string message)

Parameters

message string

The text, verbatim.

IndentationError(string, Exception)

Creates the error with the parser's message and the exception that caused it (Python's raise ... from innerException).

public IndentationError(string message, Exception innerException)

Parameters

message string

The text, verbatim.

innerException Exception

The exception that led to this one, or null for none.

IndentationError(string, string, int?, int?, string, int?, int?)

Python's SyntaxError(msg, (filename, lineno, offset, text[, end_lineno, end_offset])): the message and where the error is. Message is CPython's str() of the error: msg (file, line N), msg (file) without a line number, msg (line N) without a file name, msg alone without either; the file is its base name.

public IndentationError(string msg, string filename, int? lineno, int? offset, string text, int? end_lineno = null, int? end_offset = null)

Parameters

msg string

The parser's message without the location (invalid syntax), or null (printed None).

filename string

The source's name (<unknown> for ast.literal_eval, a path), or null for none.

lineno int?

The 1-based line, or null for none.

offset int?

The 1-based column (CPython reports 0 for some tokenizer errors), or null for none.

text string

The source line, or null for none.

end_lineno int?

The line the error ends on, or null for none.

end_offset int?

The column it ends at, or null for none; required when end_lineno is given.

Remarks

The base name follows the operating system NumSharp runs on, as CPython's does (its my_basename splits at the platform's SEP): on Windows C:\a\b\c.py reads c.py and a/b/c.py stays whole; elsewhere a/b/c.py reads c.py and C:\a\b\c.py stays whole. A name that ends in the separator reads as empty (m (, line 3)), as in CPython.

Exceptions

TypeError

end_lineno is given without end_offset (CPython: end_offset must be provided when end_lineno is provided).