SyntaxError's filename and lineno may be undefined. (#3918)

The Python source (Objects/exceptions.c) explicitly checks for null
pointers before using the filename and lineno members. Some libraries,
e.g. pkg_resources, set filename and lineno to undefined values if
indeed none are appropriate.
This commit is contained in:
Peter Pentchev
2020-04-08 21:50:49 +03:00
committed by GitHub
parent ea919fdce9
commit 0d7665d7b8
2 changed files with 4 additions and 4 deletions

View File

@@ -1570,10 +1570,10 @@ if sys.version_info >= (3, 5):
value: Any
class SyntaxError(_StandardError):
msg: str
lineno: int
lineno: Optional[int]
offset: Optional[int]
text: Optional[str]
filename: str
filename: Optional[str]
class SystemError(_StandardError): ...
class TypeError(_StandardError): ...
class ValueError(_StandardError): ...

View File

@@ -1570,10 +1570,10 @@ if sys.version_info >= (3, 5):
value: Any
class SyntaxError(_StandardError):
msg: str
lineno: int
lineno: Optional[int]
offset: Optional[int]
text: Optional[str]
filename: str
filename: Optional[str]
class SystemError(_StandardError): ...
class TypeError(_StandardError): ...
class ValueError(_StandardError): ...