Message256165
It seems like there is already sufficient detection of invalid stack levels in warnings.warn, and one of the code paths does `module = "<string>"` and later another does `filename = module`, so `filename` can be intentionally junk data, which will be passed to `linecache`.
I expect this could be satisfactorily resolved by warn() setting filename = '<invalid stacklevel>', and `formatwarning` not invoking linecache when the filename is '<string>', '<invalid stacklevel>', etc., or at least ignoring the exception from linecache when the filename is <foo>.
Looking forward, why not let Python 3.6 warn() behave 'better' when the stacklevel is invalid.
e.g. it could raise ValueError (ouch, but 'correct'), or it could reset the stacklevel to 1 (a sensible fallback) and issue an auxillary SyntaxWarning to inform everyone that the stacklevel requested was incorrect. |
|
Date |
User |
Action |
Args |
2015-12-10 06:00:22 | jayvdb | set | recipients:
+ jayvdb, brett.cannon, Arfrever, r.david.murray, serhiy.storchaka, bevan, lazka |
2015-12-10 06:00:22 | jayvdb | set | messageid: <1449727222.63.0.780901072163.issue25493@psf.upfronthosting.co.za> |
2015-12-10 06:00:22 | jayvdb | link | issue25493 messages |
2015-12-10 06:00:22 | jayvdb | create | |
|