Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit f8ec1be

Browse files
authored
Merge pull request #82 from deepyaman/patch-1
Fix `werkzeug` 2.1.0 import and `skip` calculation
2 parents a6b9adf + dbec597 commit f8ec1be

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to `jupyter-dash` will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## Unreleased
6+
### Fixed
7+
- Fixed `werkzeug` 2.1.0 import and `skip` calculation
8+
59
## 0.4.1 - 2022-02-16
610
### Fixed
711
- Support Dash 2.1, fix `AttributeError: Read-only... requests_pathname_prefix`

jupyter_dash/jupyter_app.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import re
1010
import sys
1111
import inspect
12+
import traceback
1213
import warnings
1314

1415
from IPython import get_ipython
@@ -17,10 +18,17 @@
1718
from ansi2html import Ansi2HTMLConverter
1819
import uuid
1920

21+
from .comms import _dash_comm, _jupyter_config, _request_jupyter_config
2022

21-
from werkzeug.debug.tbtools import get_current_traceback
2223

23-
from .comms import _dash_comm, _jupyter_config, _request_jupyter_config
24+
def _get_skip(error: Exception):
25+
tb = traceback.format_exception(type(error), error, error.__traceback__)
26+
skip = 0
27+
for i, line in enumerate(text):
28+
if "%% callback invoked %%" in line:
29+
skip = i + 1
30+
break
31+
return skip
2432

2533

2634
class JupyterDash(dash.Dash):
@@ -356,18 +364,12 @@ def _config_callback_exception_handling(
356364
):
357365

358366
@self.server.errorhandler(Exception)
359-
def _wrap_errors(_):
367+
def _wrap_errors(error):
360368
"""Install traceback handling for callbacks"""
361369
self._traceback = sys.exc_info()[2]
362370

363371
# Compute number of stack frames to skip to get down to callback
364-
tb_werkzeug = get_current_traceback()
365-
skip = 0
366-
if dev_tools_prune_errors:
367-
for i, line in enumerate(tb_werkzeug.plaintext.splitlines()):
368-
if "%% callback invoked %%" in line:
369-
skip = int((i + 1) / 2)
370-
break
372+
skip = _get_skip(error) if dev_tools_prune_errors else 0
371373

372374
# Customized formatargvalues function so we can place function parameters
373375
# on separate lines

0 commit comments

Comments
 (0)