L i*0UddlmZddlZddlZddlmZmZmZmZddl m Z ddl m Z ddl mZmZddlmZddlmZdd lmZdd lmZdd lmZerdd lmZdd lmZddl mZee Z!de"d<dZ#de"d<GddZ$ed d ddZ% d d dZ&d!dZ'd"dZ(d#dZ) d$dZ*edZ+ d%dZ,y)&) annotationsN) TYPE_CHECKINGFinalTypeVarcast)config)validate_width)MarkdownFormattedExceptionStreamlitAPIWarning) get_logger) Exception) WidthConfig)gather_metrics)get_script_run_ctx)Callable)DeltaGenerator)WidthWithoutContentr_LOGGERzThis app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app). _GENERIC_UNCAUGHT_EXCEPTION_TEXTcJeZdZed d ddZeddZy)ExceptionMixin exceptionc2t|j||S)aDisplay an exception. When accessing the app through ``localhost``, in the lower-right corner of the exception, Streamlit displays links to Google and ChatGPT that are prefilled with the contents of the exception message. Parameters ---------- exception : Exception The exception to display. width : "stretch" or int The width of the exception element. This can be one of the following: - ``"stretch"`` (default): The width of the element matches the width of the parent container. - An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. Example ------- >>> import streamlit as st >>> >>> e = RuntimeError("This is an exception of type RuntimeError") >>> st.exception(e) .. output :: https://doc-status-exception.streamlit.app/ height: 220px )width) _exceptiondg)selfrrs b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/exception.pyrzExceptionMixin.exception3sH$''9E::ctd|S)zGet our DeltaGenerator.r)r)rs rrzExceptionMixin.dgYs$d++rN)stretch)r BaseExceptionrrreturnr)r#r)__name__ __module__ __qualname__rrpropertyrrrrr2sIK EN#;&#;/B#; #;!#;J,,rrrcVt}t|||||jd|S)Nr)ExceptionProtomarshall_enqueue)rrris_uncaught_app_exceptionexception_protos rrr`s,%&O _i0IJ ;;{O 44rc Nt|t|t}t|dd|j|_nt |j |_t|}|jj|t|t|_ t}t|tr||_nd|_|j j#| t|t$rt'||_n%t+|j-|_||_|r't9j:d}|t8j<j>k(xst8j<jA|} | xs>|t8j<jBk(xst8j<jE|} | xs|t8j<jFk(} | s tH|_| s|jKdn;t+t |} | jMd djMd d|_| s|jKd yyy#t0$rU}d|_t2j5dt |j |dj7t|Yd}~d}~wwxYw) aMarshalls an Exception.proto message. Parameters ---------- exception_proto : Exception.proto The Exception protobuf to fill out. exception : BaseException The exception whose data we're extracting. width : int or "stretch" The width of the exception display. Can be either an integer (pixels) or "stretch". Defaults to "stretch". is_uncaught_app_exception: bool The exception originates from an uncaught error during script execution. alternate_nameNTa* Streamlit was unable to parse the data from an exception in the user's script. This is usually due to a bug in the Exception object itself. Here is some info about that Exception object, so you can report a bug to the original author: Exception type: %s Problem: %s Traceback: %s  zclient.showErrorDetailstypez stack_trace)'r isinstancer getattrr0r3r$_get_stack_trace_str_listr4extendWarning is_warningrint pixel_width use_stretch width_configCopyFrom SyntaxError_format_syntax_error_messagemessagestrstripmessage_is_markdownr rwarningjoinr get_optionShowErrorDetailsConfigOptionsFULLis_true_variation STACKTRACEis_false_variationTYPEr ClearFieldreplace) r.rrr-is_markdown_exceptionr4r> str_exceptionshow_error_details show_message show_trace show_typetype_strs rr+r+ls[.5&y2LMy*D1=(77#I77+I6K&&{3!+Iw!?O=L%#(  #'    )),7" i -'C9&MO #&))n&:&:& ?'   sAI J$A JJ$c >|jr|jdt|jdz dznd}d|jd|jd|jj d|dt |jd |j St|S) aReturns a nicely formatted SyntaxError message that emulates what the Python interpreter outputs. For example: > File "raven.py", line 3 > st.write('Hello world!!')) > ^ > SyntaxError: invalid syntax  rr1zFile "z", line z z^ z: ) textoffsetmaxfilenamelinenorstripr3r$msgrC)r caret_indents rrArAs~~2;2B2B2NC#i&&*A. .TV  Y''(1A1A0BC&&()*cI''(9==/ ;  y>rcbd}t|tr |j}n+t|drt j |j }|dg}|St|\}}|rt j|}nt j|}|Dcgc]}|j}}|Scc}w)a Get the stack trace for the given exception. Parameters ---------- exception : BaseException The exception to extract the traceback from Returns ------- tuple of two string lists The exception traceback as two lists of strings. The first represents the part of the stack trace the users don't typically want to see, containing internal Streamlit code. The second is whatever comes after the Streamlit stack trace, which is usually what the user wants. N __traceback__zdCannot extract the stack trace for this exception. Try calling exception() within the `catch` block.) r5r tacked_on_stackhasattr traceback extract_tbrd _split_internal_streamlit_frames format_listrD)rextracted_tracebacktrace_str_listinternal_framesexternal_framesitems rr7r7s":>)01'77 O ,'2293J3JK" @  ,L , ( &22?CN&22?CN3AB4$**,BB CsB,c tjjtjj||g}||k(S#t$rYywxYw)z/True if the given file is part of package_path.F)ospath commonprefixrealpath ValueError)file package_path common_prefixs r_is_in_packagery+sP,,bgg.>.>t.Dl-ST L (( s>A AAct}|s gt|fStjj tjj t |jdt|fdS)aSplit the traceback into a Streamlit-internal part and an external part. The internal part is everything up to (but excluding) the first frame belonging to the user's code. The external part is everything else. So if the stack looks like this: 1. Streamlit frame 2. Pandas frame 3. Altair frame 4. Streamlit frame 5. User frame 6. User frame 7. Streamlit frame 8. Matplotlib frame ...then this should return 1-4 as the internal traceback and 5-8 as the external. (Note that something like the example above is extremely unlikely to happen since it's not like Altair is calling Streamlit code, but you get the idea.) r1c0t|jS)N)ryr^)tbrws rz2_split_internal_streamlit_frames..Xs~bkk<Hr) split_point) rlistrqrrrGrtrCmain_script_parent _split_list) extracted_tbctxrws @rriri6sa2  C 4 %%%77<< 0 0S5K5K1L MrRL H rTcg}g}d}|D]3}|s ||rd}|r|j|#|j|5||fS)NFT)append) orig_listr~beforeaftersaw_split_pointros rrr_sXFEO ;t#4"O  LL  MM$   5=r)r!F) rrrr"rrr-boolr#r) r.r*rr"rrr-rr#None)rr@r#rC)rr"r#z list[str])rvrCrwrCr#r)rztraceback.StackSummaryr#zAtuple[list[traceback.FrameSummary], list[traceback.FrameSummary]])rzlist[T]r~zCallable[[T], bool]r#ztuple[list[T], list[T]])- __future__rrqrgtypingrrrr streamlitr#streamlit.elements.lib.layout_utilsr streamlit.errorsr r streamlit.loggerr streamlit.proto.Exception_pb2r r*streamlit.proto.WidthConfig_pb2rstreamlit.runtime.metrics_utilr7streamlit.runtime.scriptrunner_utils.script_run_contextrcollections.abcrstreamlit.delta_generatorrrr$r__annotations__rrrr+rAr7ryrirrr(rrrsI# 66>(E79V(8GH%% \!%*,*,\ "+&+ 555 5 $ 5  55"+&+ s6#s6s6 s6 $ s6  s6l:)X)#(#F#L CL%8r