Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Fix werkzeug 2.1.0 import and skip calculation #82

Merged
merged 3 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to `jupyter-dash` will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
### Fixed
- Fixed `werkzeug` 2.1.0 import and `skip` calculation

## 0.4.1 - 2022-02-16
### Fixed
- Support Dash 2.1, fix `AttributeError: Read-only... requests_pathname_prefix`
Expand Down
22 changes: 12 additions & 10 deletions jupyter_dash/jupyter_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import re
import sys
import inspect
import traceback
import warnings

from IPython import get_ipython
Expand All @@ -17,10 +18,17 @@
from ansi2html import Ansi2HTMLConverter
import uuid

from .comms import _dash_comm, _jupyter_config, _request_jupyter_config

from werkzeug.debug.tbtools import get_current_traceback

from .comms import _dash_comm, _jupyter_config, _request_jupyter_config
def _get_skip(error: Exception):
tb = traceback.format_exception(type(error), error, error.__traceback__)
skip = 0
for i, line in enumerate(text):
if "%% callback invoked %%" in line:
skip = i + 1
break
return skip


class JupyterDash(dash.Dash):
Expand Down Expand Up @@ -356,18 +364,12 @@ def _config_callback_exception_handling(
):

@self.server.errorhandler(Exception)
def _wrap_errors(_):
def _wrap_errors(error):
"""Install traceback handling for callbacks"""
self._traceback = sys.exc_info()[2]

# Compute number of stack frames to skip to get down to callback
tb_werkzeug = get_current_traceback()
skip = 0
if dev_tools_prune_errors:
for i, line in enumerate(tb_werkzeug.plaintext.splitlines()):
if "%% callback invoked %%" in line:
skip = int((i + 1) / 2)
break
skip = _get_skip(error) if dev_tools_prune_errors else 0

# Customized formatargvalues function so we can place function parameters
# on separate lines
Expand Down