HyukjinKwon opened a new pull request #31239: URL: https://github.com/apache/spark/pull/31239
### What changes were proposed in this pull request? This PR proposes to consider the case when [`inspect.currentframe()`](https://docs.python.org/3/library/inspect.html#inspect.currentframe) returns `None` because the underlyining Python implementation does not support frame. ### Why are the changes needed? To be safer and potentially for the official support of other Python implementations in the future. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Manually tested via: When frame is available: ``` vi tmp.py ``` ```python from inspect import * lineno = getframeinfo(currentframe()).lineno + 1 if currentframe() is not None else 0 print(warnings.formatwarning( "Failed to set memory limit: {0}".format(Exception("argh!")), ResourceWarning, __file__, lineno), file=sys.stderr) ``` ``` python tmp.py ``` ``` /.../tmp.py:3: ResourceWarning: Failed to set memory limit: argh! print(warnings.formatwarning( ``` When frame is not available: ``` vi tmp.py ``` ```python from inspect import * lineno = getframeinfo(currentframe()).lineno + 1 if None is not None else 0 print(warnings.formatwarning( "Failed to set memory limit: {0}".format(Exception("argh!")), ResourceWarning, __file__, lineno), file=sys.stderr) ``` ``` python tmp.py ``` ``` /.../tmp.py:0: ResourceWarning: Failed to set memory limit: argh! ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
