Skip to content
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
5 changes: 4 additions & 1 deletion ipykernel/codeutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# Distributed under the terms of the Modified BSD License.

import warnings
warnings.warn("ipykernel.codeutil is deprecated since IPykernel 4.3.1. It has moved to ipyparallel.serialize", DeprecationWarning)
warnings.warn("ipykernel.codeutil is deprecated since IPykernel 4.3.1. It has moved to ipyparallel.serialize",
DeprecationWarning,
stacklevel=2
)

import copyreg
import sys
Expand Down
17 changes: 14 additions & 3 deletions ipykernel/datapub.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@
"""

import warnings
warnings.warn("ipykernel.datapub is deprecated. It has moved to ipyparallel.datapub", DeprecationWarning)
warnings.warn("ipykernel.datapub is deprecated. It has moved to ipyparallel.datapub",
DeprecationWarning,
stacklevel=2
)

# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

from traitlets.config import Configurable
from traitlets import Instance, Dict, CBytes, Any
from ipykernel.jsonutil import json_clean
from ipykernel.serialize import serialize_object
try:
# available since ipyparallel 5.0.0
from ipyparallel.serialize import serialize_object
except ImportError:
# Deprecated since ipykernel 4.3.0
from ipykernel.serialize import serialize_object
from jupyter_client.session import Session, extract_header


Expand Down Expand Up @@ -56,7 +64,10 @@ def publish_data(data):
data : dict
The data to be published. Think of it as a namespace.
"""
warnings.warn("ipykernel.datapub is deprecated. It has moved to ipyparallel.datapub", DeprecationWarning)
warnings.warn("ipykernel.datapub is deprecated. It has moved to ipyparallel.datapub",
DeprecationWarning,
stacklevel=2
)

from ipykernel.zmqshell import ZMQInteractiveShell
ZMQInteractiveShell.instance().data_pub.publish_data(data)
6 changes: 5 additions & 1 deletion ipykernel/iostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
from io import StringIO, TextIOBase

import zmq
from zmq.eventloop.ioloop import IOLoop
if zmq.pyzmq_version_info() >= (17, 0):
from tornado.ioloop import IOLoop
else:
# deprecated since pyzmq 17
from zmq.eventloop.ioloop import IOLoop
from zmq.eventloop.zmqstream import ZMQStream

from jupyter_client.session import extract_header
Expand Down
14 changes: 9 additions & 5 deletions ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ipython_genutils.py3compat import safe_unicode
from IPython.utils.tokenutil import token_at_cursor, line_at_cursor
from tornado import gen
from traitlets import Instance, Type, Any, List, Bool
from traitlets import Instance, Type, Any, List, Bool, observe, observe_compat

from .comm import CommManager
from .kernelbase import Kernel as KernelBase
Expand Down Expand Up @@ -43,14 +43,18 @@ class IPythonKernel(KernelBase):
).tag(config=True)

user_module = Any()
def _user_module_changed(self, name, old, new):
@observe('user_module')
@observe_compat
def _user_module_changed(self, change):
if self.shell is not None:
self.shell.user_module = new
self.shell.user_module = change['new']

user_ns = Instance(dict, args=None, allow_none=True)
def _user_ns_changed(self, name, old, new):
@observe('user_ns')
@observe_compat
def _user_ns_changed(self, change):
if self.shell is not None:
self.shell.user_ns = new
self.shell.user_ns = change['new']
self.shell.init_user_ns()

# A reference to the Python builtin 'raw_input' function.
Expand Down
5 changes: 4 additions & 1 deletion ipykernel/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from zmq.log.handlers import PUBHandler

import warnings
warnings.warn("ipykernel.log is deprecated. It has moved to ipyparallel.engine.log", DeprecationWarning)
warnings.warn("ipykernel.log is deprecated. It has moved to ipyparallel.engine.log",
DeprecationWarning
stacklevel=2
)

class EnginePUBHandler(PUBHandler):
"""A simple PUBHandler subclass that sets root_topic"""
Expand Down
5 changes: 4 additions & 1 deletion ipykernel/pickleutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
# Distributed under the terms of the Modified BSD License.

import warnings
warnings.warn("ipykernel.pickleutil is deprecated. It has moved to ipyparallel.", DeprecationWarning)
warnings.warn("ipykernel.pickleutil is deprecated. It has moved to ipyparallel.",
DeprecationWarning,
stacklevel=2
)

import copy
import sys
Expand Down
22 changes: 17 additions & 5 deletions ipykernel/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,28 @@
# Distributed under the terms of the Modified BSD License.

import warnings
warnings.warn("ipykernel.serialize is deprecated. It has moved to ipyparallel.serialize", DeprecationWarning)
warnings.warn("ipykernel.serialize is deprecated. It has moved to ipyparallel.serialize",
DeprecationWarning,
stacklevel=2
)

import pickle

from itertools import chain

from ipykernel.pickleutil import (
can, uncan, can_sequence, uncan_sequence, CannedObject,
istype, sequence_types, PICKLE_PROTOCOL,
)
try:
# available since ipyparallel 5.0.0
from ipyparallel.serialize.canning import (
can, uncan, can_sequence, uncan_sequence, CannedObject,
istype, sequence_types,
)
from ipyparallel.serialize.serialize import PICKLE_PROTOCOL
except ImportError:
# Deprecated since ipykernel 4.3.0
from ipykernel.pickleutil import (
can, uncan, can_sequence, uncan_sequence, CannedObject,
istype, sequence_types, PICKLE_PROTOCOL,
)
from jupyter_client.session import MAX_ITEMS, MAX_BYTES


Expand Down
9 changes: 8 additions & 1 deletion ipykernel/zmqshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
from jupyter_core.paths import jupyter_runtime_dir
from jupyter_client.session import extract_header, Session

try:
# available since ipyparallel 5.0.0
from ipyparallel.engine.datapub import ZMQDataPublisher
except ImportError:
# Deprecated since ipykernel 4.3.0
from ipykernel.datapub import ZMQDataPublisher

#-----------------------------------------------------------------------------
# Functions and classes
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -438,7 +445,7 @@ class ZMQInteractiveShell(InteractiveShell):

displayhook_class = Type(ZMQShellDisplayHook)
display_pub_class = Type(ZMQDisplayPublisher)
data_pub_class = Type('ipykernel.datapub.ZMQDataPublisher')
data_pub_class = Type(ZMQDataPublisher)
kernel = Any()
parent_header = Any()

Expand Down