Preserve stack trace when conditionally re-raising.
The error handling code in question looks to see if a raised exception is of type TypeError, and if so, if its message matches a pattern, in which case it raises a more informative message about dynamic control flow. However, If it doesn't match the message, it seeks just to reraise the underlying exception. When doing this with "raise e", the underlying stack trace is lost; instead, we should just use "raise", which keeps the source stack trace. Source for the re-raise behavior: https://stackoverflow.com/questions/8146386/python-conditionally-catching-exceptions PiperOrigin-RevId: 231500445
Loading
Please sign in to comment