From ce0783f5796a0d1e56f093944318d55099e254b6 Mon Sep 17 00:00:00 2001 From: James Hutchison <122519877+JamesHutchison@users.noreply.github.com> Date: Fri, 17 May 2024 23:54:28 +0000 Subject: [PATCH 1/2] Add line to caller info --- src/py/reactpy/reactpy/core/hooks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/py/reactpy/reactpy/core/hooks.py b/src/py/reactpy/reactpy/core/hooks.py index 7279b0191..d1a042321 100644 --- a/src/py/reactpy/reactpy/core/hooks.py +++ b/src/py/reactpy/reactpy/core/hooks.py @@ -3,6 +3,7 @@ import asyncio from functools import lru_cache import hashlib +import linecache import sys from collections.abc import Coroutine, Sequence from hashlib import md5 @@ -103,7 +104,10 @@ def get_caller_info(): if patch_path is not None: break # Extract the relevant information: file path and line number and hash it - return f"{caller_frame.f_code.co_filename} {caller_frame.f_lineno} {patch_path}" + filename = caller_frame.f_code.co_filename + lineno = caller_frame.f_lineno + line = linecache.getline(filename, lineno) + return f"{filename} {lineno} {line}, {patch_path}" __DEBUG_CALLER_INFO_TO_STATE_KEY = {} From 1d4c1464cc8b80881e930bf6c165520db45ff24d Mon Sep 17 00:00:00 2001 From: James Hutchison <122519877+JamesHutchison@users.noreply.github.com> Date: Fri, 17 May 2024 23:58:34 +0000 Subject: [PATCH 2/2] comment update --- src/py/reactpy/reactpy/core/hooks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/py/reactpy/reactpy/core/hooks.py b/src/py/reactpy/reactpy/core/hooks.py index d1a042321..f0434789f 100644 --- a/src/py/reactpy/reactpy/core/hooks.py +++ b/src/py/reactpy/reactpy/core/hooks.py @@ -103,10 +103,10 @@ def get_caller_info(): patch_path = render_frame.f_locals.get("patch_path_for_state") if patch_path is not None: break - # Extract the relevant information: file path and line number and hash it + # Extract the relevant information: file path, line number, and line and hash it filename = caller_frame.f_code.co_filename lineno = caller_frame.f_lineno - line = linecache.getline(filename, lineno) + line = linecache.getline(filename, lineno) return f"{filename} {lineno} {line}, {patch_path}"