Skip to content

Commit fb1aa4d

Browse files
committed
Backward compat
1 parent 4b16152 commit fb1aa4d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

python/ipywidgets/ipywidgets/__init__.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323
import os
2424

2525
from traitlets import link, dlink
26-
from comm import get_comm_manager
26+
try:
27+
from comm import get_comm_manager
28+
except ImportError:
29+
def get_comm_manager():
30+
from IPython import get_ipython
31+
32+
return get_ipython().kernel.comm_manager
2733

2834
from .widgets import *
2935

python/ipywidgets/ipywidgets/widgets/widget.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
from contextlib import contextmanager
1111
from collections.abc import Iterable
1212
from IPython import get_ipython
13-
from comm import create_comm
13+
try:
14+
from comm import create_comm
15+
except ImportError:
16+
from ipykernel.comm import Comm
17+
18+
def create_comm(**kwargs):
19+
return Comm(**kwargs)
1420
from traitlets import (
1521
Any, HasTraits, Unicode, Dict, Instance, List, Int, Set, Bytes, observe, default, Container,
1622
Undefined)

0 commit comments

Comments
 (0)