Pylons / pyramid

Pyramid - A Python web framework
https://trypyramid.com/
Other
3.97k stars 887 forks source link

Handle possible None value safely in view_config class #3601

Closed sudhir-b closed 4 years ago

sudhir-b commented 4 years ago

Bug Report

Description

https://github.com/Pylons/pyramid/blob/5269b28e728a470b94f194bf8febd46278b1f356/src/pyramid/view.py#L235

The function inspect.getframeinfo() returns a named tuple.

In _get_info() in the view_config class, we subscript straight into the element at index 3 in the returned named tuple.

However, the function inspect.getframeinfo() can return None as the third element, which will raise a TypeError if unhandled.

To Reproduce I'm unsure how to reproduce this from outside the Pyramid code base.

However, we should be able to trigger this error by adding the kwarg context=0 to the getframeinfo() call.

Expected behavior A user should expect the None case to be safely handled instead of triggering a TypeError.

digitalresistor commented 4 years ago

Could you please provide a sample code that is broken because of this? Due to the nature of how and where that code is used, I believe that if the code_context is None that view_config itself would already not be useful in any way shape or form, since Venusian will never be able to find it.

mmerickel commented 4 years ago

Please update this issue with more info and we can re-open it, but at this time I do not see any cause for us to worry about this case without an example.