Skip to content

Commit 37ecad1

Browse files
author
Quentin Peter
committed
Merge remote-tracking branch 'refs/remotes/upstream/master'
Conflicts: ipykernel/kernelbase.py
2 parents 99e3d4f + ff122dd commit 37ecad1

File tree

16 files changed

+194
-52
lines changed

16 files changed

+194
-52
lines changed

.travis.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
language: python
2-
python:
3-
- "nightly"
4-
- 3.8
5-
- 3.7
6-
- 3.6
7-
- 3.5
2+
matrix:
3+
include:
4+
- arch: arm64
5+
python: "nightly"
6+
dist: bionic
7+
- arch: amd64
8+
python: "nightly"
9+
- arch: arm64
10+
python: 3.5
11+
- arch: amd64
12+
python: 3.5
13+
- arch: arm64
14+
python: 3.6
15+
- arch: amd64
16+
python: 3.6
17+
- arch: arm64
18+
python: 3.7
19+
- arch: amd64
20+
python: 3.7
21+
- arch: arm64
22+
python: 3.8
23+
- arch: amd64
24+
python: 3.8
825
sudo: false
926
dist: xenial
1027
install:

appveyor.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ clone_depth: 1
66
environment:
77

88
matrix:
9+
- python: "C:/Python38-x64"
910
- python: "C:/Python36-x64"
10-
- python: "C:/Python36"
11+
- python: "C:/Python35"
1112

1213
cache:
1314
- C:\Users\appveyor\AppData\Local\pip\Cache
1415

1516
init:
1617
- cmd: set PATH=%python%;%python%\scripts;%PATH%
18+
1719
install:
1820
- cmd: |
1921
python -m pip install --upgrade setuptools pip wheel
@@ -25,8 +27,9 @@ install:
2527
pip install matplotlib numpy
2628
pip freeze
2729
- cmd: python -c "import ipykernel.kernelspec; ipykernel.kernelspec.install(user=True)"
30+
2831
test_script:
29-
- cmd: pytest -v --cov ipykernel ipykernel
32+
- cmd: pytest -v -x --cov ipykernel ipykernel
3033

3134
on_success:
3235
- cmd: pip install codecov

docs/changelog.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
Changes in IPython kernel
22
=========================
33

4+
5.2
5+
---
6+
7+
5.2.0
8+
*****
9+
10+
5.2.0 Includes several bugfixes and internal logic improvements.
11+
12+
- Produce better traceback when kernel is interrupted (:ghpull:`491`)
13+
- Add ``InProcessKernelClient.control_channel`` for compatibility with jupyter-client v6.0.0 (:ghpull:`489`)
14+
- Drop support for Python 3.4 (:ghpull:`483`)
15+
- Work around issue related to Tornado with python3.8 on Windows (:ghpull:`480`, :ghpull:`481`)
16+
- Prevent entering event loop if it is None (:ghpull:`464`)
17+
- Use ``shell.input_transformer_manager`` when available (:ghpull:`411`)
18+
419
5.1
520
---
621

22+
5.1.4
23+
*****
24+
25+
5.1.4 Includes a few bugfixes,
26+
especially for compatibility with Python 3.8 on Windows.
27+
28+
- Fix pickle issues when using inline matplotlib backend (:ghpull:`476`)
29+
- Fix an error during kernel shutdown (:ghpull:`463`)
30+
- Fix compatibility issues with Python 3.8 (:ghpull:`456`, :ghpull:`461`)
31+
- Remove some dead code (:ghpull:`474`, :ghpull:`467`)
32+
733
5.1.3
834
*****
935

examples/embedding/inprocess_qtconsole.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,48 @@
11
from __future__ import print_function
22
import os
3+
import sys
34

4-
from IPython.qt.console.rich_ipython_widget import RichIPythonWidget
5-
from IPython.qt.inprocess import QtInProcessKernelManager
5+
from qtconsole.rich_ipython_widget import RichIPythonWidget
6+
from qtconsole.inprocess import QtInProcessKernelManager
67
from IPython.lib import guisupport
78

89

910
def print_process_id():
1011
print('Process ID is:', os.getpid())
1112

1213

14+
def init_asyncio_patch():
15+
"""set default asyncio policy to be compatible with tornado
16+
Tornado 6 (at least) is not compatible with the default
17+
asyncio implementation on Windows
18+
Pick the older SelectorEventLoopPolicy on Windows
19+
if the known-incompatible default policy is in use.
20+
do this as early as possible to make it a low priority and overrideable
21+
ref: https://github.com/tornadoweb/tornado/issues/2608
22+
FIXME: if/when tornado supports the defaults in asyncio,
23+
remove and bump tornado requirement for py38
24+
"""
25+
if sys.platform.startswith("win") and sys.version_info >= (3, 8):
26+
import asyncio
27+
try:
28+
from asyncio import (
29+
WindowsProactorEventLoopPolicy,
30+
WindowsSelectorEventLoopPolicy,
31+
)
32+
except ImportError:
33+
pass
34+
# not affected
35+
else:
36+
if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy:
37+
# WindowsProactorEventLoopPolicy is not compatible with tornado 6
38+
# fallback to the pre-3.8 default of Selector
39+
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
40+
1341
def main():
1442
# Print the ID of the main process
1543
print_process_id()
1644

45+
init_asyncio_patch()
1746
app = guisupport.get_app_qt4()
1847

1948
# Create an in-process kernel

examples/embedding/inprocess_terminal.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,50 @@
11
from __future__ import print_function
22
import os
3+
import sys
34

4-
from IPython.kernel.inprocess import InProcessKernelManager
5-
from IPython.terminal.console.interactiveshell import ZMQTerminalInteractiveShell
5+
from ipykernel.inprocess import InProcessKernelManager
6+
from jupyter_console.ptshell import ZMQTerminalInteractiveShell
67

78

89
def print_process_id():
910
print('Process ID is:', os.getpid())
1011

1112

13+
def init_asyncio_patch():
14+
"""set default asyncio policy to be compatible with tornado
15+
Tornado 6 (at least) is not compatible with the default
16+
asyncio implementation on Windows
17+
Pick the older SelectorEventLoopPolicy on Windows
18+
if the known-incompatible default policy is in use.
19+
do this as early as possible to make it a low priority and overrideable
20+
ref: https://github.com/tornadoweb/tornado/issues/2608
21+
FIXME: if/when tornado supports the defaults in asyncio,
22+
remove and bump tornado requirement for py38
23+
"""
24+
if sys.platform.startswith("win") and sys.version_info >= (3, 8):
25+
import asyncio
26+
try:
27+
from asyncio import (
28+
WindowsProactorEventLoopPolicy,
29+
WindowsSelectorEventLoopPolicy,
30+
)
31+
except ImportError:
32+
pass
33+
# not affected
34+
else:
35+
if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy:
36+
# WindowsProactorEventLoopPolicy is not compatible with tornado 6
37+
# fallback to the pre-3.8 default of Selector
38+
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
39+
40+
1241
def main():
1342
print_process_id()
1443

1544
# Create an in-process kernel
1645
# >>> print_process_id()
1746
# will print the same process ID as the main process
47+
init_asyncio_patch()
1848
kernel_manager = InProcessKernelManager()
1949
kernel_manager.start_kernel()
2050
kernel = kernel_manager.kernel

examples/embedding/internal_ipkernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66

77
from IPython.lib.kernel import connect_qtconsole
8-
from IPython.kernel.zmq.kernelapp import IPKernelApp
8+
from ipykernel.kernelapp import IPKernelApp
99

1010
#-----------------------------------------------------------------------------
1111
# Functions and classes

ipykernel/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version_info = (5, 2, 0, 'dev')
1+
version_info = (5, 3, 0, 'dev')
22
__version__ = '.'.join(map(str, version_info[:3]))
33

44
# pep440 is annoying, beta/alpha/rc should _not_ have dots or pip/setuptools

ipykernel/inprocess/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class InProcessKernelClient(KernelClient):
4141
shell_channel_class = Type(InProcessChannel)
4242
iopub_channel_class = Type(InProcessChannel)
4343
stdin_channel_class = Type(InProcessChannel)
44+
control_channel_class = Type(InProcessChannel)
4445
hb_channel_class = Type(InProcessHBChannel)
4546

4647
kernel = Instance('ipykernel.inprocess.ipkernel.InProcessKernel',
@@ -82,6 +83,12 @@ def stdin_channel(self):
8283
self._stdin_channel = self.stdin_channel_class(self)
8384
return self._stdin_channel
8485

86+
@property
87+
def control_channel(self):
88+
if self._control_channel is None:
89+
self._control_channel = self.control_channel_class(self)
90+
return self._control_channel
91+
8592
@property
8693
def hb_channel(self):
8794
if self._hb_channel is None:

ipykernel/inprocess/tests/test_kernel.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,43 @@
2020
from StringIO import StringIO
2121

2222

23+
def _init_asyncio_patch():
24+
"""set default asyncio policy to be compatible with tornado
25+
26+
Tornado 6 (at least) is not compatible with the default
27+
asyncio implementation on Windows
28+
29+
Pick the older SelectorEventLoopPolicy on Windows
30+
if the known-incompatible default policy is in use.
31+
32+
do this as early as possible to make it a low priority and overrideable
33+
34+
ref: https://github.com/tornadoweb/tornado/issues/2608
35+
36+
FIXME: if/when tornado supports the defaults in asyncio,
37+
remove and bump tornado requirement for py38
38+
"""
39+
if sys.platform.startswith("win") and sys.version_info >= (3, 8):
40+
import asyncio
41+
try:
42+
from asyncio import (
43+
WindowsProactorEventLoopPolicy,
44+
WindowsSelectorEventLoopPolicy,
45+
)
46+
except ImportError:
47+
pass
48+
# not affected
49+
else:
50+
if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy:
51+
# WindowsProactorEventLoopPolicy is not compatible with tornado 6
52+
# fallback to the pre-3.8 default of Selector
53+
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
54+
55+
2356
class InProcessKernelTestCase(unittest.TestCase):
2457

2558
def setUp(self):
59+
_init_asyncio_patch()
2660
self.km = InProcessKernelManager()
2761
self.km.start_kernel()
2862
self.kc = self.km.client()

ipykernel/ipkernel.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,11 @@ def do_shutdown(self, restart):
453453
return dict(status='ok', restart=restart)
454454

455455
def do_is_complete(self, code):
456-
status, indent_spaces = self.shell.input_splitter.check_complete(code)
456+
transformer_manager = getattr(self.shell, 'input_transformer_manager', None)
457+
if transformer_manager is None:
458+
# input_splitter attribute is deprecated
459+
transformer_manager = self.shell.input_splitter
460+
status, indent_spaces = transformer_manager.check_complete(code)
457461
r = {'status': status}
458462
if status == 'incomplete':
459463
r['indent'] = ' ' * indent_spaces

0 commit comments

Comments
 (0)