##// END OF EJS Templates
Merge pull request from GHSA-pq7m-3gw7-gq5x...
Matthias Bussonnier -
Show More
@@ -0,0 +1,56 b''
1 """
2 Test that CVEs stay fixed.
3 """
4
5 from IPython.utils.tempdir import TemporaryDirectory, TemporaryWorkingDirectory
6 from pathlib import Path
7 import random
8 import sys
9 import os
10 import string
11 import subprocess
12 import time
13
14 def test_cve_2022_21699():
15 """
16 Here we test CVE-2022-21699.
17
18 We create a temporary directory, cd into it.
19 Make a profile file that should not be executed and start IPython in a subprocess,
20 checking for the value.
21
22
23
24 """
25
26 dangerous_profile_dir = Path('profile_default')
27
28 dangerous_startup_dir = dangerous_profile_dir / 'startup'
29 dangerous_expected = 'CVE-2022-21699-'+''.join([random.choice(string.ascii_letters) for i in range(10)])
30
31 with TemporaryWorkingDirectory() as t:
32 dangerous_startup_dir.mkdir(parents=True)
33 (dangerous_startup_dir/ 'foo.py').write_text(f'print("{dangerous_expected}")')
34 # 1 sec to make sure FS is flushed.
35 #time.sleep(1)
36 cmd = [sys.executable,'-m', 'IPython']
37 env = os.environ.copy()
38 env['IPY_TEST_SIMPLE_PROMPT'] = '1'
39
40
41 # First we fake old behavior, making sure the profile is/was actually dangerous
42 p_dangerous = subprocess.Popen(cmd + [f'--profile-dir={dangerous_profile_dir}'], env=env, stdin=subprocess.PIPE,
43 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
44 out_dangerous, err_dangerouns = p_dangerous.communicate(b"exit\r")
45 assert dangerous_expected in out_dangerous.decode()
46
47 # Now that we know it _would_ have been dangerous, we test it's not loaded
48 p = subprocess.Popen(cmd, env=env, stdin=subprocess.PIPE,
49 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
50 out, err = p.communicate(b"exit\r")
51 assert b'IPython' in out
52 assert dangerous_expected not in out.decode()
53 assert err == b''
54
55
56
@@ -1,152 +1,156 b''
1 # encoding: utf-8
1 # encoding: utf-8
2 """
2 """
3 IPython: tools for interactive and parallel computing in Python.
3 IPython: tools for interactive and parallel computing in Python.
4
4
5 https://ipython.org
5 https://ipython.org
6 """
6 """
7 #-----------------------------------------------------------------------------
7 #-----------------------------------------------------------------------------
8 # Copyright (c) 2008-2011, IPython Development Team.
8 # Copyright (c) 2008-2011, IPython Development Team.
9 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
9 # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
10 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
10 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
11 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
11 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
12 #
12 #
13 # Distributed under the terms of the Modified BSD License.
13 # Distributed under the terms of the Modified BSD License.
14 #
14 #
15 # The full license is in the file COPYING.txt, distributed with this software.
15 # The full license is in the file COPYING.txt, distributed with this software.
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17
17
18 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
19 # Imports
19 # Imports
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21
21
22 import os
22 import os
23 import sys
23 import sys
24
24
25 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
26 # Setup everything
26 # Setup everything
27 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
28
28
29 # Don't forget to also update setup.py when this changes!
29 # Don't forget to also update setup.py when this changes!
30 if sys.version_info < (3, 6):
30 if sys.version_info < (3, 6):
31 raise ImportError(
31 raise ImportError(
32 """
32 """
33 IPython 7.10+ supports Python 3.6 and above.
33 IPython 7.10+ supports Python 3.6 and above.
34 When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
34 When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
35 Python 3.3 and 3.4 were supported up to IPython 6.x.
35 Python 3.3 and 3.4 were supported up to IPython 6.x.
36 Python 3.5 was supported with IPython 7.0 to 7.9.
36 Python 3.5 was supported with IPython 7.0 to 7.9.
37
37
38 See IPython `README.rst` file for more information:
38 See IPython `README.rst` file for more information:
39
39
40 https://github.com/ipython/ipython/blob/master/README.rst
40 https://github.com/ipython/ipython/blob/master/README.rst
41
41
42 """)
42 """)
43
43
44 # Make it easy to import extensions - they are always directly on pythonpath.
44 # Make it easy to import extensions - they are always directly on pythonpath.
45 # Therefore, non-IPython modules can be added to extensions directory.
45 # Therefore, non-IPython modules can be added to extensions directory.
46 # This should probably be in ipapp.py.
46 # This should probably be in ipapp.py.
47 sys.path.append(os.path.join(os.path.dirname(__file__), "extensions"))
47 sys.path.append(os.path.join(os.path.dirname(__file__), "extensions"))
48
48
49 #-----------------------------------------------------------------------------
49 #-----------------------------------------------------------------------------
50 # Setup the top level names
50 # Setup the top level names
51 #-----------------------------------------------------------------------------
51 #-----------------------------------------------------------------------------
52
52
53 from .core.getipython import get_ipython
53 from .core.getipython import get_ipython
54 from .core import release
54 from .core import release
55 from .core.application import Application
55 from .core.application import Application
56 from .terminal.embed import embed
56 from .terminal.embed import embed
57
57
58 from .core.interactiveshell import InteractiveShell
58 from .core.interactiveshell import InteractiveShell
59 from .testing import test
59 from .testing import test
60 from .utils.sysinfo import sys_info
60 from .utils.sysinfo import sys_info
61 from .utils.frame import extract_module_locals
61 from .utils.frame import extract_module_locals
62
62
63 # Release data
63 # Release data
64 __author__ = '%s <%s>' % (release.author, release.author_email)
64 __author__ = '%s <%s>' % (release.author, release.author_email)
65 __license__ = release.license
65 __license__ = release.license
66 __version__ = release.version
66 __version__ = release.version
67 version_info = release.version_info
67 version_info = release.version_info
68 # list of CVEs that should have been patched in this release.
69 # this is informational and should not be relied upon.
70 __patched_cves__ = {"CVE-2022-21699"}
71
68
72
69 def embed_kernel(module=None, local_ns=None, **kwargs):
73 def embed_kernel(module=None, local_ns=None, **kwargs):
70 """Embed and start an IPython kernel in a given scope.
74 """Embed and start an IPython kernel in a given scope.
71
75
72 If you don't want the kernel to initialize the namespace
76 If you don't want the kernel to initialize the namespace
73 from the scope of the surrounding function,
77 from the scope of the surrounding function,
74 and/or you want to load full IPython configuration,
78 and/or you want to load full IPython configuration,
75 you probably want `IPython.start_kernel()` instead.
79 you probably want `IPython.start_kernel()` instead.
76
80
77 Parameters
81 Parameters
78 ----------
82 ----------
79 module : types.ModuleType, optional
83 module : types.ModuleType, optional
80 The module to load into IPython globals (default: caller)
84 The module to load into IPython globals (default: caller)
81 local_ns : dict, optional
85 local_ns : dict, optional
82 The namespace to load into IPython user namespace (default: caller)
86 The namespace to load into IPython user namespace (default: caller)
83
87
84 kwargs : various, optional
88 kwargs : various, optional
85 Further keyword args are relayed to the IPKernelApp constructor,
89 Further keyword args are relayed to the IPKernelApp constructor,
86 allowing configuration of the Kernel. Will only have an effect
90 allowing configuration of the Kernel. Will only have an effect
87 on the first embed_kernel call for a given process.
91 on the first embed_kernel call for a given process.
88 """
92 """
89
93
90 (caller_module, caller_locals) = extract_module_locals(1)
94 (caller_module, caller_locals) = extract_module_locals(1)
91 if module is None:
95 if module is None:
92 module = caller_module
96 module = caller_module
93 if local_ns is None:
97 if local_ns is None:
94 local_ns = caller_locals
98 local_ns = caller_locals
95
99
96 # Only import .zmq when we really need it
100 # Only import .zmq when we really need it
97 from ipykernel.embed import embed_kernel as real_embed_kernel
101 from ipykernel.embed import embed_kernel as real_embed_kernel
98 real_embed_kernel(module=module, local_ns=local_ns, **kwargs)
102 real_embed_kernel(module=module, local_ns=local_ns, **kwargs)
99
103
100 def start_ipython(argv=None, **kwargs):
104 def start_ipython(argv=None, **kwargs):
101 """Launch a normal IPython instance (as opposed to embedded)
105 """Launch a normal IPython instance (as opposed to embedded)
102
106
103 `IPython.embed()` puts a shell in a particular calling scope,
107 `IPython.embed()` puts a shell in a particular calling scope,
104 such as a function or method for debugging purposes,
108 such as a function or method for debugging purposes,
105 which is often not desirable.
109 which is often not desirable.
106
110
107 `start_ipython()` does full, regular IPython initialization,
111 `start_ipython()` does full, regular IPython initialization,
108 including loading startup files, configuration, etc.
112 including loading startup files, configuration, etc.
109 much of which is skipped by `embed()`.
113 much of which is skipped by `embed()`.
110
114
111 This is a public API method, and will survive implementation changes.
115 This is a public API method, and will survive implementation changes.
112
116
113 Parameters
117 Parameters
114 ----------
118 ----------
115
119
116 argv : list or None, optional
120 argv : list or None, optional
117 If unspecified or None, IPython will parse command-line options from sys.argv.
121 If unspecified or None, IPython will parse command-line options from sys.argv.
118 To prevent any command-line parsing, pass an empty list: `argv=[]`.
122 To prevent any command-line parsing, pass an empty list: `argv=[]`.
119 user_ns : dict, optional
123 user_ns : dict, optional
120 specify this dictionary to initialize the IPython user namespace with particular values.
124 specify this dictionary to initialize the IPython user namespace with particular values.
121 kwargs : various, optional
125 kwargs : various, optional
122 Any other kwargs will be passed to the Application constructor,
126 Any other kwargs will be passed to the Application constructor,
123 such as `config`.
127 such as `config`.
124 """
128 """
125 from IPython.terminal.ipapp import launch_new_instance
129 from IPython.terminal.ipapp import launch_new_instance
126 return launch_new_instance(argv=argv, **kwargs)
130 return launch_new_instance(argv=argv, **kwargs)
127
131
128 def start_kernel(argv=None, **kwargs):
132 def start_kernel(argv=None, **kwargs):
129 """Launch a normal IPython kernel instance (as opposed to embedded)
133 """Launch a normal IPython kernel instance (as opposed to embedded)
130
134
131 `IPython.embed_kernel()` puts a shell in a particular calling scope,
135 `IPython.embed_kernel()` puts a shell in a particular calling scope,
132 such as a function or method for debugging purposes,
136 such as a function or method for debugging purposes,
133 which is often not desirable.
137 which is often not desirable.
134
138
135 `start_kernel()` does full, regular IPython initialization,
139 `start_kernel()` does full, regular IPython initialization,
136 including loading startup files, configuration, etc.
140 including loading startup files, configuration, etc.
137 much of which is skipped by `embed()`.
141 much of which is skipped by `embed()`.
138
142
139 Parameters
143 Parameters
140 ----------
144 ----------
141
145
142 argv : list or None, optional
146 argv : list or None, optional
143 If unspecified or None, IPython will parse command-line options from sys.argv.
147 If unspecified or None, IPython will parse command-line options from sys.argv.
144 To prevent any command-line parsing, pass an empty list: `argv=[]`.
148 To prevent any command-line parsing, pass an empty list: `argv=[]`.
145 user_ns : dict, optional
149 user_ns : dict, optional
146 specify this dictionary to initialize the IPython user namespace with particular values.
150 specify this dictionary to initialize the IPython user namespace with particular values.
147 kwargs : various, optional
151 kwargs : various, optional
148 Any other kwargs will be passed to the Application constructor,
152 Any other kwargs will be passed to the Application constructor,
149 such as `config`.
153 such as `config`.
150 """
154 """
151 from IPython.kernel.zmq.kernelapp import launch_new_instance
155 from IPython.kernel.zmq.kernelapp import launch_new_instance
152 return launch_new_instance(argv=argv, **kwargs)
156 return launch_new_instance(argv=argv, **kwargs)
@@ -1,462 +1,462 b''
1 # encoding: utf-8
1 # encoding: utf-8
2 """
2 """
3 An application for IPython.
3 An application for IPython.
4
4
5 All top-level applications should use the classes in this module for
5 All top-level applications should use the classes in this module for
6 handling configuration and creating configurables.
6 handling configuration and creating configurables.
7
7
8 The job of an :class:`Application` is to create the master configuration
8 The job of an :class:`Application` is to create the master configuration
9 object and then create the configurable objects, passing the config to them.
9 object and then create the configurable objects, passing the config to them.
10 """
10 """
11
11
12 # Copyright (c) IPython Development Team.
12 # Copyright (c) IPython Development Team.
13 # Distributed under the terms of the Modified BSD License.
13 # Distributed under the terms of the Modified BSD License.
14
14
15 import atexit
15 import atexit
16 from copy import deepcopy
16 from copy import deepcopy
17 import glob
17 import glob
18 import logging
18 import logging
19 import os
19 import os
20 import shutil
20 import shutil
21 import sys
21 import sys
22
22
23 from traitlets.config.application import Application, catch_config_error
23 from traitlets.config.application import Application, catch_config_error
24 from traitlets.config.loader import ConfigFileNotFound, PyFileConfigLoader
24 from traitlets.config.loader import ConfigFileNotFound, PyFileConfigLoader
25 from IPython.core import release, crashhandler
25 from IPython.core import release, crashhandler
26 from IPython.core.profiledir import ProfileDir, ProfileDirError
26 from IPython.core.profiledir import ProfileDir, ProfileDirError
27 from IPython.paths import get_ipython_dir, get_ipython_package_dir
27 from IPython.paths import get_ipython_dir, get_ipython_package_dir
28 from IPython.utils.path import ensure_dir_exists
28 from IPython.utils.path import ensure_dir_exists
29 from traitlets import (
29 from traitlets import (
30 List, Unicode, Type, Bool, Set, Instance, Undefined,
30 List, Unicode, Type, Bool, Set, Instance, Undefined,
31 default, observe,
31 default, observe,
32 )
32 )
33
33
34 if os.name == 'nt':
34 if os.name == 'nt':
35 programdata = os.environ.get('PROGRAMDATA', None)
35 programdata = os.environ.get('PROGRAMDATA', None)
36 if programdata:
36 if programdata:
37 SYSTEM_CONFIG_DIRS = [os.path.join(programdata, 'ipython')]
37 SYSTEM_CONFIG_DIRS = [os.path.join(programdata, 'ipython')]
38 else: # PROGRAMDATA is not defined by default on XP.
38 else: # PROGRAMDATA is not defined by default on XP.
39 SYSTEM_CONFIG_DIRS = []
39 SYSTEM_CONFIG_DIRS = []
40 else:
40 else:
41 SYSTEM_CONFIG_DIRS = [
41 SYSTEM_CONFIG_DIRS = [
42 "/usr/local/etc/ipython",
42 "/usr/local/etc/ipython",
43 "/etc/ipython",
43 "/etc/ipython",
44 ]
44 ]
45
45
46
46
47 ENV_CONFIG_DIRS = []
47 ENV_CONFIG_DIRS = []
48 _env_config_dir = os.path.join(sys.prefix, 'etc', 'ipython')
48 _env_config_dir = os.path.join(sys.prefix, 'etc', 'ipython')
49 if _env_config_dir not in SYSTEM_CONFIG_DIRS:
49 if _env_config_dir not in SYSTEM_CONFIG_DIRS:
50 # only add ENV_CONFIG if sys.prefix is not already included
50 # only add ENV_CONFIG if sys.prefix is not already included
51 ENV_CONFIG_DIRS.append(_env_config_dir)
51 ENV_CONFIG_DIRS.append(_env_config_dir)
52
52
53
53
54 _envvar = os.environ.get('IPYTHON_SUPPRESS_CONFIG_ERRORS')
54 _envvar = os.environ.get('IPYTHON_SUPPRESS_CONFIG_ERRORS')
55 if _envvar in {None, ''}:
55 if _envvar in {None, ''}:
56 IPYTHON_SUPPRESS_CONFIG_ERRORS = None
56 IPYTHON_SUPPRESS_CONFIG_ERRORS = None
57 else:
57 else:
58 if _envvar.lower() in {'1','true'}:
58 if _envvar.lower() in {'1','true'}:
59 IPYTHON_SUPPRESS_CONFIG_ERRORS = True
59 IPYTHON_SUPPRESS_CONFIG_ERRORS = True
60 elif _envvar.lower() in {'0','false'} :
60 elif _envvar.lower() in {'0','false'} :
61 IPYTHON_SUPPRESS_CONFIG_ERRORS = False
61 IPYTHON_SUPPRESS_CONFIG_ERRORS = False
62 else:
62 else:
63 sys.exit("Unsupported value for environment variable: 'IPYTHON_SUPPRESS_CONFIG_ERRORS' is set to '%s' which is none of {'0', '1', 'false', 'true', ''}."% _envvar )
63 sys.exit("Unsupported value for environment variable: 'IPYTHON_SUPPRESS_CONFIG_ERRORS' is set to '%s' which is none of {'0', '1', 'false', 'true', ''}."% _envvar )
64
64
65 # aliases and flags
65 # aliases and flags
66
66
67 base_aliases = {
67 base_aliases = {
68 'profile-dir' : 'ProfileDir.location',
68 'profile-dir' : 'ProfileDir.location',
69 'profile' : 'BaseIPythonApplication.profile',
69 'profile' : 'BaseIPythonApplication.profile',
70 'ipython-dir' : 'BaseIPythonApplication.ipython_dir',
70 'ipython-dir' : 'BaseIPythonApplication.ipython_dir',
71 'log-level' : 'Application.log_level',
71 'log-level' : 'Application.log_level',
72 'config' : 'BaseIPythonApplication.extra_config_file',
72 'config' : 'BaseIPythonApplication.extra_config_file',
73 }
73 }
74
74
75 base_flags = dict(
75 base_flags = dict(
76 debug = ({'Application' : {'log_level' : logging.DEBUG}},
76 debug = ({'Application' : {'log_level' : logging.DEBUG}},
77 "set log level to logging.DEBUG (maximize logging output)"),
77 "set log level to logging.DEBUG (maximize logging output)"),
78 quiet = ({'Application' : {'log_level' : logging.CRITICAL}},
78 quiet = ({'Application' : {'log_level' : logging.CRITICAL}},
79 "set log level to logging.CRITICAL (minimize logging output)"),
79 "set log level to logging.CRITICAL (minimize logging output)"),
80 init = ({'BaseIPythonApplication' : {
80 init = ({'BaseIPythonApplication' : {
81 'copy_config_files' : True,
81 'copy_config_files' : True,
82 'auto_create' : True}
82 'auto_create' : True}
83 }, """Initialize profile with default config files. This is equivalent
83 }, """Initialize profile with default config files. This is equivalent
84 to running `ipython profile create <profile>` prior to startup.
84 to running `ipython profile create <profile>` prior to startup.
85 """)
85 """)
86 )
86 )
87
87
88 class ProfileAwareConfigLoader(PyFileConfigLoader):
88 class ProfileAwareConfigLoader(PyFileConfigLoader):
89 """A Python file config loader that is aware of IPython profiles."""
89 """A Python file config loader that is aware of IPython profiles."""
90 def load_subconfig(self, fname, path=None, profile=None):
90 def load_subconfig(self, fname, path=None, profile=None):
91 if profile is not None:
91 if profile is not None:
92 try:
92 try:
93 profile_dir = ProfileDir.find_profile_dir_by_name(
93 profile_dir = ProfileDir.find_profile_dir_by_name(
94 get_ipython_dir(),
94 get_ipython_dir(),
95 profile,
95 profile,
96 )
96 )
97 except ProfileDirError:
97 except ProfileDirError:
98 return
98 return
99 path = profile_dir.location
99 path = profile_dir.location
100 return super(ProfileAwareConfigLoader, self).load_subconfig(fname, path=path)
100 return super(ProfileAwareConfigLoader, self).load_subconfig(fname, path=path)
101
101
102 class BaseIPythonApplication(Application):
102 class BaseIPythonApplication(Application):
103
103
104 name = u'ipython'
104 name = u'ipython'
105 description = Unicode(u'IPython: an enhanced interactive Python shell.')
105 description = Unicode(u'IPython: an enhanced interactive Python shell.')
106 version = Unicode(release.version)
106 version = Unicode(release.version)
107
107
108 aliases = base_aliases
108 aliases = base_aliases
109 flags = base_flags
109 flags = base_flags
110 classes = List([ProfileDir])
110 classes = List([ProfileDir])
111
111
112 # enable `load_subconfig('cfg.py', profile='name')`
112 # enable `load_subconfig('cfg.py', profile='name')`
113 python_config_loader_class = ProfileAwareConfigLoader
113 python_config_loader_class = ProfileAwareConfigLoader
114
114
115 # Track whether the config_file has changed,
115 # Track whether the config_file has changed,
116 # because some logic happens only if we aren't using the default.
116 # because some logic happens only if we aren't using the default.
117 config_file_specified = Set()
117 config_file_specified = Set()
118
118
119 config_file_name = Unicode()
119 config_file_name = Unicode()
120 @default('config_file_name')
120 @default('config_file_name')
121 def _config_file_name_default(self):
121 def _config_file_name_default(self):
122 return self.name.replace('-','_') + u'_config.py'
122 return self.name.replace('-','_') + u'_config.py'
123 @observe('config_file_name')
123 @observe('config_file_name')
124 def _config_file_name_changed(self, change):
124 def _config_file_name_changed(self, change):
125 if change['new'] != change['old']:
125 if change['new'] != change['old']:
126 self.config_file_specified.add(change['new'])
126 self.config_file_specified.add(change['new'])
127
127
128 # The directory that contains IPython's builtin profiles.
128 # The directory that contains IPython's builtin profiles.
129 builtin_profile_dir = Unicode(
129 builtin_profile_dir = Unicode(
130 os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default')
130 os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default')
131 )
131 )
132
132
133 config_file_paths = List(Unicode())
133 config_file_paths = List(Unicode())
134 @default('config_file_paths')
134 @default('config_file_paths')
135 def _config_file_paths_default(self):
135 def _config_file_paths_default(self):
136 return [os.getcwd()]
136 return []
137
137
138 extra_config_file = Unicode(
138 extra_config_file = Unicode(
139 help="""Path to an extra config file to load.
139 help="""Path to an extra config file to load.
140
140
141 If specified, load this config file in addition to any other IPython config.
141 If specified, load this config file in addition to any other IPython config.
142 """).tag(config=True)
142 """).tag(config=True)
143 @observe('extra_config_file')
143 @observe('extra_config_file')
144 def _extra_config_file_changed(self, change):
144 def _extra_config_file_changed(self, change):
145 old = change['old']
145 old = change['old']
146 new = change['new']
146 new = change['new']
147 try:
147 try:
148 self.config_files.remove(old)
148 self.config_files.remove(old)
149 except ValueError:
149 except ValueError:
150 pass
150 pass
151 self.config_file_specified.add(new)
151 self.config_file_specified.add(new)
152 self.config_files.append(new)
152 self.config_files.append(new)
153
153
154 profile = Unicode(u'default',
154 profile = Unicode(u'default',
155 help="""The IPython profile to use."""
155 help="""The IPython profile to use."""
156 ).tag(config=True)
156 ).tag(config=True)
157
157
158 @observe('profile')
158 @observe('profile')
159 def _profile_changed(self, change):
159 def _profile_changed(self, change):
160 self.builtin_profile_dir = os.path.join(
160 self.builtin_profile_dir = os.path.join(
161 get_ipython_package_dir(), u'config', u'profile', change['new']
161 get_ipython_package_dir(), u'config', u'profile', change['new']
162 )
162 )
163
163
164 ipython_dir = Unicode(
164 ipython_dir = Unicode(
165 help="""
165 help="""
166 The name of the IPython directory. This directory is used for logging
166 The name of the IPython directory. This directory is used for logging
167 configuration (through profiles), history storage, etc. The default
167 configuration (through profiles), history storage, etc. The default
168 is usually $HOME/.ipython. This option can also be specified through
168 is usually $HOME/.ipython. This option can also be specified through
169 the environment variable IPYTHONDIR.
169 the environment variable IPYTHONDIR.
170 """
170 """
171 ).tag(config=True)
171 ).tag(config=True)
172 @default('ipython_dir')
172 @default('ipython_dir')
173 def _ipython_dir_default(self):
173 def _ipython_dir_default(self):
174 d = get_ipython_dir()
174 d = get_ipython_dir()
175 self._ipython_dir_changed({
175 self._ipython_dir_changed({
176 'name': 'ipython_dir',
176 'name': 'ipython_dir',
177 'old': d,
177 'old': d,
178 'new': d,
178 'new': d,
179 })
179 })
180 return d
180 return d
181
181
182 _in_init_profile_dir = False
182 _in_init_profile_dir = False
183 profile_dir = Instance(ProfileDir, allow_none=True)
183 profile_dir = Instance(ProfileDir, allow_none=True)
184 @default('profile_dir')
184 @default('profile_dir')
185 def _profile_dir_default(self):
185 def _profile_dir_default(self):
186 # avoid recursion
186 # avoid recursion
187 if self._in_init_profile_dir:
187 if self._in_init_profile_dir:
188 return
188 return
189 # profile_dir requested early, force initialization
189 # profile_dir requested early, force initialization
190 self.init_profile_dir()
190 self.init_profile_dir()
191 return self.profile_dir
191 return self.profile_dir
192
192
193 overwrite = Bool(False,
193 overwrite = Bool(False,
194 help="""Whether to overwrite existing config files when copying"""
194 help="""Whether to overwrite existing config files when copying"""
195 ).tag(config=True)
195 ).tag(config=True)
196 auto_create = Bool(False,
196 auto_create = Bool(False,
197 help="""Whether to create profile dir if it doesn't exist"""
197 help="""Whether to create profile dir if it doesn't exist"""
198 ).tag(config=True)
198 ).tag(config=True)
199
199
200 config_files = List(Unicode())
200 config_files = List(Unicode())
201 @default('config_files')
201 @default('config_files')
202 def _config_files_default(self):
202 def _config_files_default(self):
203 return [self.config_file_name]
203 return [self.config_file_name]
204
204
205 copy_config_files = Bool(False,
205 copy_config_files = Bool(False,
206 help="""Whether to install the default config files into the profile dir.
206 help="""Whether to install the default config files into the profile dir.
207 If a new profile is being created, and IPython contains config files for that
207 If a new profile is being created, and IPython contains config files for that
208 profile, then they will be staged into the new directory. Otherwise,
208 profile, then they will be staged into the new directory. Otherwise,
209 default config files will be automatically generated.
209 default config files will be automatically generated.
210 """).tag(config=True)
210 """).tag(config=True)
211
211
212 verbose_crash = Bool(False,
212 verbose_crash = Bool(False,
213 help="""Create a massive crash report when IPython encounters what may be an
213 help="""Create a massive crash report when IPython encounters what may be an
214 internal error. The default is to append a short message to the
214 internal error. The default is to append a short message to the
215 usual traceback""").tag(config=True)
215 usual traceback""").tag(config=True)
216
216
217 # The class to use as the crash handler.
217 # The class to use as the crash handler.
218 crash_handler_class = Type(crashhandler.CrashHandler)
218 crash_handler_class = Type(crashhandler.CrashHandler)
219
219
220 @catch_config_error
220 @catch_config_error
221 def __init__(self, **kwargs):
221 def __init__(self, **kwargs):
222 super(BaseIPythonApplication, self).__init__(**kwargs)
222 super(BaseIPythonApplication, self).__init__(**kwargs)
223 # ensure current working directory exists
223 # ensure current working directory exists
224 try:
224 try:
225 os.getcwd()
225 os.getcwd()
226 except:
226 except:
227 # exit if cwd doesn't exist
227 # exit if cwd doesn't exist
228 self.log.error("Current working directory doesn't exist.")
228 self.log.error("Current working directory doesn't exist.")
229 self.exit(1)
229 self.exit(1)
230
230
231 #-------------------------------------------------------------------------
231 #-------------------------------------------------------------------------
232 # Various stages of Application creation
232 # Various stages of Application creation
233 #-------------------------------------------------------------------------
233 #-------------------------------------------------------------------------
234
234
235 deprecated_subcommands = {}
235 deprecated_subcommands = {}
236
236
237 def initialize_subcommand(self, subc, argv=None):
237 def initialize_subcommand(self, subc, argv=None):
238 if subc in self.deprecated_subcommands:
238 if subc in self.deprecated_subcommands:
239 self.log.warning("Subcommand `ipython {sub}` is deprecated and will be removed "
239 self.log.warning("Subcommand `ipython {sub}` is deprecated and will be removed "
240 "in future versions.".format(sub=subc))
240 "in future versions.".format(sub=subc))
241 self.log.warning("You likely want to use `jupyter {sub}` in the "
241 self.log.warning("You likely want to use `jupyter {sub}` in the "
242 "future".format(sub=subc))
242 "future".format(sub=subc))
243 return super(BaseIPythonApplication, self).initialize_subcommand(subc, argv)
243 return super(BaseIPythonApplication, self).initialize_subcommand(subc, argv)
244
244
245 def init_crash_handler(self):
245 def init_crash_handler(self):
246 """Create a crash handler, typically setting sys.excepthook to it."""
246 """Create a crash handler, typically setting sys.excepthook to it."""
247 self.crash_handler = self.crash_handler_class(self)
247 self.crash_handler = self.crash_handler_class(self)
248 sys.excepthook = self.excepthook
248 sys.excepthook = self.excepthook
249 def unset_crashhandler():
249 def unset_crashhandler():
250 sys.excepthook = sys.__excepthook__
250 sys.excepthook = sys.__excepthook__
251 atexit.register(unset_crashhandler)
251 atexit.register(unset_crashhandler)
252
252
253 def excepthook(self, etype, evalue, tb):
253 def excepthook(self, etype, evalue, tb):
254 """this is sys.excepthook after init_crashhandler
254 """this is sys.excepthook after init_crashhandler
255
255
256 set self.verbose_crash=True to use our full crashhandler, instead of
256 set self.verbose_crash=True to use our full crashhandler, instead of
257 a regular traceback with a short message (crash_handler_lite)
257 a regular traceback with a short message (crash_handler_lite)
258 """
258 """
259
259
260 if self.verbose_crash:
260 if self.verbose_crash:
261 return self.crash_handler(etype, evalue, tb)
261 return self.crash_handler(etype, evalue, tb)
262 else:
262 else:
263 return crashhandler.crash_handler_lite(etype, evalue, tb)
263 return crashhandler.crash_handler_lite(etype, evalue, tb)
264
264
265 @observe('ipython_dir')
265 @observe('ipython_dir')
266 def _ipython_dir_changed(self, change):
266 def _ipython_dir_changed(self, change):
267 old = change['old']
267 old = change['old']
268 new = change['new']
268 new = change['new']
269 if old is not Undefined:
269 if old is not Undefined:
270 str_old = os.path.abspath(old)
270 str_old = os.path.abspath(old)
271 if str_old in sys.path:
271 if str_old in sys.path:
272 sys.path.remove(str_old)
272 sys.path.remove(str_old)
273 str_path = os.path.abspath(new)
273 str_path = os.path.abspath(new)
274 sys.path.append(str_path)
274 sys.path.append(str_path)
275 ensure_dir_exists(new)
275 ensure_dir_exists(new)
276 readme = os.path.join(new, 'README')
276 readme = os.path.join(new, 'README')
277 readme_src = os.path.join(get_ipython_package_dir(), u'config', u'profile', 'README')
277 readme_src = os.path.join(get_ipython_package_dir(), u'config', u'profile', 'README')
278 if not os.path.exists(readme) and os.path.exists(readme_src):
278 if not os.path.exists(readme) and os.path.exists(readme_src):
279 shutil.copy(readme_src, readme)
279 shutil.copy(readme_src, readme)
280 for d in ('extensions', 'nbextensions'):
280 for d in ('extensions', 'nbextensions'):
281 path = os.path.join(new, d)
281 path = os.path.join(new, d)
282 try:
282 try:
283 ensure_dir_exists(path)
283 ensure_dir_exists(path)
284 except OSError as e:
284 except OSError as e:
285 # this will not be EEXIST
285 # this will not be EEXIST
286 self.log.error("couldn't create path %s: %s", path, e)
286 self.log.error("couldn't create path %s: %s", path, e)
287 self.log.debug("IPYTHONDIR set to: %s" % new)
287 self.log.debug("IPYTHONDIR set to: %s" % new)
288
288
289 def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS):
289 def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS):
290 """Load the config file.
290 """Load the config file.
291
291
292 By default, errors in loading config are handled, and a warning
292 By default, errors in loading config are handled, and a warning
293 printed on screen. For testing, the suppress_errors option is set
293 printed on screen. For testing, the suppress_errors option is set
294 to False, so errors will make tests fail.
294 to False, so errors will make tests fail.
295
295
296 `suppress_errors` default value is to be `None` in which case the
296 `suppress_errors` default value is to be `None` in which case the
297 behavior default to the one of `traitlets.Application`.
297 behavior default to the one of `traitlets.Application`.
298
298
299 The default value can be set :
299 The default value can be set :
300 - to `False` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '0', or 'false' (case insensitive).
300 - to `False` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '0', or 'false' (case insensitive).
301 - to `True` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '1' or 'true' (case insensitive).
301 - to `True` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '1' or 'true' (case insensitive).
302 - to `None` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '' (empty string) or leaving it unset.
302 - to `None` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '' (empty string) or leaving it unset.
303
303
304 Any other value are invalid, and will make IPython exit with a non-zero return code.
304 Any other value are invalid, and will make IPython exit with a non-zero return code.
305 """
305 """
306
306
307
307
308 self.log.debug("Searching path %s for config files", self.config_file_paths)
308 self.log.debug("Searching path %s for config files", self.config_file_paths)
309 base_config = 'ipython_config.py'
309 base_config = 'ipython_config.py'
310 self.log.debug("Attempting to load config file: %s" %
310 self.log.debug("Attempting to load config file: %s" %
311 base_config)
311 base_config)
312 try:
312 try:
313 if suppress_errors is not None:
313 if suppress_errors is not None:
314 old_value = Application.raise_config_file_errors
314 old_value = Application.raise_config_file_errors
315 Application.raise_config_file_errors = not suppress_errors;
315 Application.raise_config_file_errors = not suppress_errors;
316 Application.load_config_file(
316 Application.load_config_file(
317 self,
317 self,
318 base_config,
318 base_config,
319 path=self.config_file_paths
319 path=self.config_file_paths
320 )
320 )
321 except ConfigFileNotFound:
321 except ConfigFileNotFound:
322 # ignore errors loading parent
322 # ignore errors loading parent
323 self.log.debug("Config file %s not found", base_config)
323 self.log.debug("Config file %s not found", base_config)
324 pass
324 pass
325 if suppress_errors is not None:
325 if suppress_errors is not None:
326 Application.raise_config_file_errors = old_value
326 Application.raise_config_file_errors = old_value
327
327
328 for config_file_name in self.config_files:
328 for config_file_name in self.config_files:
329 if not config_file_name or config_file_name == base_config:
329 if not config_file_name or config_file_name == base_config:
330 continue
330 continue
331 self.log.debug("Attempting to load config file: %s" %
331 self.log.debug("Attempting to load config file: %s" %
332 self.config_file_name)
332 self.config_file_name)
333 try:
333 try:
334 Application.load_config_file(
334 Application.load_config_file(
335 self,
335 self,
336 config_file_name,
336 config_file_name,
337 path=self.config_file_paths
337 path=self.config_file_paths
338 )
338 )
339 except ConfigFileNotFound:
339 except ConfigFileNotFound:
340 # Only warn if the default config file was NOT being used.
340 # Only warn if the default config file was NOT being used.
341 if config_file_name in self.config_file_specified:
341 if config_file_name in self.config_file_specified:
342 msg = self.log.warning
342 msg = self.log.warning
343 else:
343 else:
344 msg = self.log.debug
344 msg = self.log.debug
345 msg("Config file not found, skipping: %s", config_file_name)
345 msg("Config file not found, skipping: %s", config_file_name)
346 except Exception:
346 except Exception:
347 # For testing purposes.
347 # For testing purposes.
348 if not suppress_errors:
348 if not suppress_errors:
349 raise
349 raise
350 self.log.warning("Error loading config file: %s" %
350 self.log.warning("Error loading config file: %s" %
351 self.config_file_name, exc_info=True)
351 self.config_file_name, exc_info=True)
352
352
353 def init_profile_dir(self):
353 def init_profile_dir(self):
354 """initialize the profile dir"""
354 """initialize the profile dir"""
355 self._in_init_profile_dir = True
355 self._in_init_profile_dir = True
356 if self.profile_dir is not None:
356 if self.profile_dir is not None:
357 # already ran
357 # already ran
358 return
358 return
359 if 'ProfileDir.location' not in self.config:
359 if 'ProfileDir.location' not in self.config:
360 # location not specified, find by profile name
360 # location not specified, find by profile name
361 try:
361 try:
362 p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
362 p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
363 except ProfileDirError:
363 except ProfileDirError:
364 # not found, maybe create it (always create default profile)
364 # not found, maybe create it (always create default profile)
365 if self.auto_create or self.profile == 'default':
365 if self.auto_create or self.profile == 'default':
366 try:
366 try:
367 p = ProfileDir.create_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
367 p = ProfileDir.create_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
368 except ProfileDirError:
368 except ProfileDirError:
369 self.log.fatal("Could not create profile: %r"%self.profile)
369 self.log.fatal("Could not create profile: %r"%self.profile)
370 self.exit(1)
370 self.exit(1)
371 else:
371 else:
372 self.log.info("Created profile dir: %r"%p.location)
372 self.log.info("Created profile dir: %r"%p.location)
373 else:
373 else:
374 self.log.fatal("Profile %r not found."%self.profile)
374 self.log.fatal("Profile %r not found."%self.profile)
375 self.exit(1)
375 self.exit(1)
376 else:
376 else:
377 self.log.debug(f"Using existing profile dir: {p.location!r}")
377 self.log.debug(f"Using existing profile dir: {p.location!r}")
378 else:
378 else:
379 location = self.config.ProfileDir.location
379 location = self.config.ProfileDir.location
380 # location is fully specified
380 # location is fully specified
381 try:
381 try:
382 p = ProfileDir.find_profile_dir(location, self.config)
382 p = ProfileDir.find_profile_dir(location, self.config)
383 except ProfileDirError:
383 except ProfileDirError:
384 # not found, maybe create it
384 # not found, maybe create it
385 if self.auto_create:
385 if self.auto_create:
386 try:
386 try:
387 p = ProfileDir.create_profile_dir(location, self.config)
387 p = ProfileDir.create_profile_dir(location, self.config)
388 except ProfileDirError:
388 except ProfileDirError:
389 self.log.fatal("Could not create profile directory: %r"%location)
389 self.log.fatal("Could not create profile directory: %r"%location)
390 self.exit(1)
390 self.exit(1)
391 else:
391 else:
392 self.log.debug("Creating new profile dir: %r"%location)
392 self.log.debug("Creating new profile dir: %r"%location)
393 else:
393 else:
394 self.log.fatal("Profile directory %r not found."%location)
394 self.log.fatal("Profile directory %r not found."%location)
395 self.exit(1)
395 self.exit(1)
396 else:
396 else:
397 self.log.debug(f"Using existing profile dir: {p.location!r}")
397 self.log.debug(f"Using existing profile dir: {p.location!r}")
398 # if profile_dir is specified explicitly, set profile name
398 # if profile_dir is specified explicitly, set profile name
399 dir_name = os.path.basename(p.location)
399 dir_name = os.path.basename(p.location)
400 if dir_name.startswith('profile_'):
400 if dir_name.startswith('profile_'):
401 self.profile = dir_name[8:]
401 self.profile = dir_name[8:]
402
402
403 self.profile_dir = p
403 self.profile_dir = p
404 self.config_file_paths.append(p.location)
404 self.config_file_paths.append(p.location)
405 self._in_init_profile_dir = False
405 self._in_init_profile_dir = False
406
406
407 def init_config_files(self):
407 def init_config_files(self):
408 """[optionally] copy default config files into profile dir."""
408 """[optionally] copy default config files into profile dir."""
409 self.config_file_paths.extend(ENV_CONFIG_DIRS)
409 self.config_file_paths.extend(ENV_CONFIG_DIRS)
410 self.config_file_paths.extend(SYSTEM_CONFIG_DIRS)
410 self.config_file_paths.extend(SYSTEM_CONFIG_DIRS)
411 # copy config files
411 # copy config files
412 path = self.builtin_profile_dir
412 path = self.builtin_profile_dir
413 if self.copy_config_files:
413 if self.copy_config_files:
414 src = self.profile
414 src = self.profile
415
415
416 cfg = self.config_file_name
416 cfg = self.config_file_name
417 if path and os.path.exists(os.path.join(path, cfg)):
417 if path and os.path.exists(os.path.join(path, cfg)):
418 self.log.warning("Staging %r from %s into %r [overwrite=%s]"%(
418 self.log.warning("Staging %r from %s into %r [overwrite=%s]"%(
419 cfg, src, self.profile_dir.location, self.overwrite)
419 cfg, src, self.profile_dir.location, self.overwrite)
420 )
420 )
421 self.profile_dir.copy_config_file(cfg, path=path, overwrite=self.overwrite)
421 self.profile_dir.copy_config_file(cfg, path=path, overwrite=self.overwrite)
422 else:
422 else:
423 self.stage_default_config_file()
423 self.stage_default_config_file()
424 else:
424 else:
425 # Still stage *bundled* config files, but not generated ones
425 # Still stage *bundled* config files, but not generated ones
426 # This is necessary for `ipython profile=sympy` to load the profile
426 # This is necessary for `ipython profile=sympy` to load the profile
427 # on the first go
427 # on the first go
428 files = glob.glob(os.path.join(path, '*.py'))
428 files = glob.glob(os.path.join(path, '*.py'))
429 for fullpath in files:
429 for fullpath in files:
430 cfg = os.path.basename(fullpath)
430 cfg = os.path.basename(fullpath)
431 if self.profile_dir.copy_config_file(cfg, path=path, overwrite=False):
431 if self.profile_dir.copy_config_file(cfg, path=path, overwrite=False):
432 # file was copied
432 # file was copied
433 self.log.warning("Staging bundled %s from %s into %r"%(
433 self.log.warning("Staging bundled %s from %s into %r"%(
434 cfg, self.profile, self.profile_dir.location)
434 cfg, self.profile, self.profile_dir.location)
435 )
435 )
436
436
437
437
438 def stage_default_config_file(self):
438 def stage_default_config_file(self):
439 """auto generate default config file, and stage it into the profile."""
439 """auto generate default config file, and stage it into the profile."""
440 s = self.generate_config_file()
440 s = self.generate_config_file()
441 fname = os.path.join(self.profile_dir.location, self.config_file_name)
441 fname = os.path.join(self.profile_dir.location, self.config_file_name)
442 if self.overwrite or not os.path.exists(fname):
442 if self.overwrite or not os.path.exists(fname):
443 self.log.warning("Generating default config file: %r"%(fname))
443 self.log.warning("Generating default config file: %r"%(fname))
444 with open(fname, 'w') as f:
444 with open(fname, 'w') as f:
445 f.write(s)
445 f.write(s)
446
446
447 @catch_config_error
447 @catch_config_error
448 def initialize(self, argv=None):
448 def initialize(self, argv=None):
449 # don't hook up crash handler before parsing command-line
449 # don't hook up crash handler before parsing command-line
450 self.parse_command_line(argv)
450 self.parse_command_line(argv)
451 self.init_crash_handler()
451 self.init_crash_handler()
452 if self.subapp is not None:
452 if self.subapp is not None:
453 # stop here if subapp is taking over
453 # stop here if subapp is taking over
454 return
454 return
455 # save a copy of CLI config to re-load after config files
455 # save a copy of CLI config to re-load after config files
456 # so that it has highest priority
456 # so that it has highest priority
457 cl_config = deepcopy(self.config)
457 cl_config = deepcopy(self.config)
458 self.init_profile_dir()
458 self.init_profile_dir()
459 self.init_config_files()
459 self.init_config_files()
460 self.load_config_file()
460 self.load_config_file()
461 # enforce cl-opts override configfile opts:
461 # enforce cl-opts override configfile opts:
462 self.update_config(cl_config)
462 self.update_config(cl_config)
@@ -1,311 +1,312 b''
1 # encoding: utf-8
1 # encoding: utf-8
2 """
2 """
3 An application for managing IPython profiles.
3 An application for managing IPython profiles.
4
4
5 To be invoked as the `ipython profile` subcommand.
5 To be invoked as the `ipython profile` subcommand.
6
6
7 Authors:
7 Authors:
8
8
9 * Min RK
9 * Min RK
10
10
11 """
11 """
12
12
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14 # Copyright (C) 2008 The IPython Development Team
14 # Copyright (C) 2008 The IPython Development Team
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
19
19
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21 # Imports
21 # Imports
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23
23
24 import os
24 import os
25
25
26 from traitlets.config.application import Application
26 from traitlets.config.application import Application
27 from IPython.core.application import (
27 from IPython.core.application import (
28 BaseIPythonApplication, base_flags
28 BaseIPythonApplication, base_flags
29 )
29 )
30 from IPython.core.profiledir import ProfileDir
30 from IPython.core.profiledir import ProfileDir
31 from IPython.utils.importstring import import_item
31 from IPython.utils.importstring import import_item
32 from IPython.paths import get_ipython_dir, get_ipython_package_dir
32 from IPython.paths import get_ipython_dir, get_ipython_package_dir
33 from traitlets import Unicode, Bool, Dict, observe
33 from traitlets import Unicode, Bool, Dict, observe
34
34
35 #-----------------------------------------------------------------------------
35 #-----------------------------------------------------------------------------
36 # Constants
36 # Constants
37 #-----------------------------------------------------------------------------
37 #-----------------------------------------------------------------------------
38
38
39 create_help = """Create an IPython profile by name
39 create_help = """Create an IPython profile by name
40
40
41 Create an ipython profile directory by its name or
41 Create an ipython profile directory by its name or
42 profile directory path. Profile directories contain
42 profile directory path. Profile directories contain
43 configuration, log and security related files and are named
43 configuration, log and security related files and are named
44 using the convention 'profile_<name>'. By default they are
44 using the convention 'profile_<name>'. By default they are
45 located in your ipython directory. Once created, you will
45 located in your ipython directory. Once created, you will
46 can edit the configuration files in the profile
46 can edit the configuration files in the profile
47 directory to configure IPython. Most users will create a
47 directory to configure IPython. Most users will create a
48 profile directory by name,
48 profile directory by name,
49 `ipython profile create myprofile`, which will put the directory
49 `ipython profile create myprofile`, which will put the directory
50 in `<ipython_dir>/profile_myprofile`.
50 in `<ipython_dir>/profile_myprofile`.
51 """
51 """
52 list_help = """List available IPython profiles
52 list_help = """List available IPython profiles
53
53
54 List all available profiles, by profile location, that can
54 List all available profiles, by profile location, that can
55 be found in the current working directly or in the ipython
55 be found in the current working directly or in the ipython
56 directory. Profile directories are named using the convention
56 directory. Profile directories are named using the convention
57 'profile_<profile>'.
57 'profile_<profile>'.
58 """
58 """
59 profile_help = """Manage IPython profiles
59 profile_help = """Manage IPython profiles
60
60
61 Profile directories contain
61 Profile directories contain
62 configuration, log and security related files and are named
62 configuration, log and security related files and are named
63 using the convention 'profile_<name>'. By default they are
63 using the convention 'profile_<name>'. By default they are
64 located in your ipython directory. You can create profiles
64 located in your ipython directory. You can create profiles
65 with `ipython profile create <name>`, or see the profiles you
65 with `ipython profile create <name>`, or see the profiles you
66 already have with `ipython profile list`
66 already have with `ipython profile list`
67
67
68 To get started configuring IPython, simply do:
68 To get started configuring IPython, simply do:
69
69
70 $> ipython profile create
70 $> ipython profile create
71
71
72 and IPython will create the default profile in <ipython_dir>/profile_default,
72 and IPython will create the default profile in <ipython_dir>/profile_default,
73 where you can edit ipython_config.py to start configuring IPython.
73 where you can edit ipython_config.py to start configuring IPython.
74
74
75 """
75 """
76
76
77 _list_examples = "ipython profile list # list all profiles"
77 _list_examples = "ipython profile list # list all profiles"
78
78
79 _create_examples = """
79 _create_examples = """
80 ipython profile create foo # create profile foo w/ default config files
80 ipython profile create foo # create profile foo w/ default config files
81 ipython profile create foo --reset # restage default config files over current
81 ipython profile create foo --reset # restage default config files over current
82 ipython profile create foo --parallel # also stage parallel config files
82 ipython profile create foo --parallel # also stage parallel config files
83 """
83 """
84
84
85 _main_examples = """
85 _main_examples = """
86 ipython profile create -h # show the help string for the create subcommand
86 ipython profile create -h # show the help string for the create subcommand
87 ipython profile list -h # show the help string for the list subcommand
87 ipython profile list -h # show the help string for the list subcommand
88
88
89 ipython locate profile foo # print the path to the directory for profile 'foo'
89 ipython locate profile foo # print the path to the directory for profile 'foo'
90 """
90 """
91
91
92 #-----------------------------------------------------------------------------
92 #-----------------------------------------------------------------------------
93 # Profile Application Class (for `ipython profile` subcommand)
93 # Profile Application Class (for `ipython profile` subcommand)
94 #-----------------------------------------------------------------------------
94 #-----------------------------------------------------------------------------
95
95
96
96
97 def list_profiles_in(path):
97 def list_profiles_in(path):
98 """list profiles in a given root directory"""
98 """list profiles in a given root directory"""
99 profiles = []
99 profiles = []
100
100
101 # for python 3.6+ rewrite to: with os.scandir(path) as dirlist:
101 # for python 3.6+ rewrite to: with os.scandir(path) as dirlist:
102 files = os.scandir(path)
102 files = os.scandir(path)
103 for f in files:
103 for f in files:
104 if f.is_dir() and f.name.startswith('profile_'):
104 if f.is_dir() and f.name.startswith('profile_'):
105 profiles.append(f.name.split('_', 1)[-1])
105 profiles.append(f.name.split('_', 1)[-1])
106 return profiles
106 return profiles
107
107
108
108
109 def list_bundled_profiles():
109 def list_bundled_profiles():
110 """list profiles that are bundled with IPython."""
110 """list profiles that are bundled with IPython."""
111 path = os.path.join(get_ipython_package_dir(), u'core', u'profile')
111 path = os.path.join(get_ipython_package_dir(), u'core', u'profile')
112 profiles = []
112 profiles = []
113
113
114 # for python 3.6+ rewrite to: with os.scandir(path) as dirlist:
114 # for python 3.6+ rewrite to: with os.scandir(path) as dirlist:
115 files = os.scandir(path)
115 files = os.scandir(path)
116 for profile in files:
116 for profile in files:
117 if profile.is_dir() and profile.name != "__pycache__":
117 if profile.is_dir() and profile.name != "__pycache__":
118 profiles.append(profile.name)
118 profiles.append(profile.name)
119 return profiles
119 return profiles
120
120
121
121
122 class ProfileLocate(BaseIPythonApplication):
122 class ProfileLocate(BaseIPythonApplication):
123 description = """print the path to an IPython profile dir"""
123 description = """print the path to an IPython profile dir"""
124
124
125 def parse_command_line(self, argv=None):
125 def parse_command_line(self, argv=None):
126 super(ProfileLocate, self).parse_command_line(argv)
126 super(ProfileLocate, self).parse_command_line(argv)
127 if self.extra_args:
127 if self.extra_args:
128 self.profile = self.extra_args[0]
128 self.profile = self.extra_args[0]
129
129
130 def start(self):
130 def start(self):
131 print(self.profile_dir.location)
131 print(self.profile_dir.location)
132
132
133
133
134 class ProfileList(Application):
134 class ProfileList(Application):
135 name = u'ipython-profile'
135 name = u'ipython-profile'
136 description = list_help
136 description = list_help
137 examples = _list_examples
137 examples = _list_examples
138
138
139 aliases = Dict({
139 aliases = Dict({
140 'ipython-dir' : 'ProfileList.ipython_dir',
140 'ipython-dir' : 'ProfileList.ipython_dir',
141 'log-level' : 'Application.log_level',
141 'log-level' : 'Application.log_level',
142 })
142 })
143 flags = Dict(dict(
143 flags = Dict(dict(
144 debug = ({'Application' : {'log_level' : 0}},
144 debug = ({'Application' : {'log_level' : 0}},
145 "Set Application.log_level to 0, maximizing log output."
145 "Set Application.log_level to 0, maximizing log output."
146 )
146 )
147 ))
147 ))
148
148
149 ipython_dir = Unicode(get_ipython_dir(),
149 ipython_dir = Unicode(get_ipython_dir(),
150 help="""
150 help="""
151 The name of the IPython directory. This directory is used for logging
151 The name of the IPython directory. This directory is used for logging
152 configuration (through profiles), history storage, etc. The default
152 configuration (through profiles), history storage, etc. The default
153 is usually $HOME/.ipython. This options can also be specified through
153 is usually $HOME/.ipython. This options can also be specified through
154 the environment variable IPYTHONDIR.
154 the environment variable IPYTHONDIR.
155 """
155 """
156 ).tag(config=True)
156 ).tag(config=True)
157
157
158
158
159 def _print_profiles(self, profiles):
159 def _print_profiles(self, profiles):
160 """print list of profiles, indented."""
160 """print list of profiles, indented."""
161 for profile in profiles:
161 for profile in profiles:
162 print(' %s' % profile)
162 print(' %s' % profile)
163
163
164 def list_profile_dirs(self):
164 def list_profile_dirs(self):
165 profiles = list_bundled_profiles()
165 profiles = list_bundled_profiles()
166 if profiles:
166 if profiles:
167 print()
167 print()
168 print("Available profiles in IPython:")
168 print("Available profiles in IPython:")
169 self._print_profiles(profiles)
169 self._print_profiles(profiles)
170 print()
170 print()
171 print(" The first request for a bundled profile will copy it")
171 print(" The first request for a bundled profile will copy it")
172 print(" into your IPython directory (%s)," % self.ipython_dir)
172 print(" into your IPython directory (%s)," % self.ipython_dir)
173 print(" where you can customize it.")
173 print(" where you can customize it.")
174
174
175 profiles = list_profiles_in(self.ipython_dir)
175 profiles = list_profiles_in(self.ipython_dir)
176 if profiles:
176 if profiles:
177 print()
177 print()
178 print("Available profiles in %s:" % self.ipython_dir)
178 print("Available profiles in %s:" % self.ipython_dir)
179 self._print_profiles(profiles)
179 self._print_profiles(profiles)
180
180
181 profiles = list_profiles_in(os.getcwd())
181 profiles = list_profiles_in(os.getcwd())
182 if profiles:
182 if profiles:
183 print()
183 print()
184 print("Available profiles in current directory (%s):" % os.getcwd())
184 print(
185 self._print_profiles(profiles)
185 "Profiles from CWD have been removed for security reason, see CVE-2022-21699:"
186
186 )
187
187 print()
188 print()
188 print("To use any of the above profiles, start IPython with:")
189 print("To use any of the above profiles, start IPython with:")
189 print(" ipython --profile=<name>")
190 print(" ipython --profile=<name>")
190 print()
191 print()
191
192
192 def start(self):
193 def start(self):
193 self.list_profile_dirs()
194 self.list_profile_dirs()
194
195
195
196
196 create_flags = {}
197 create_flags = {}
197 create_flags.update(base_flags)
198 create_flags.update(base_flags)
198 # don't include '--init' flag, which implies running profile create in other apps
199 # don't include '--init' flag, which implies running profile create in other apps
199 create_flags.pop('init')
200 create_flags.pop('init')
200 create_flags['reset'] = ({'ProfileCreate': {'overwrite' : True}},
201 create_flags['reset'] = ({'ProfileCreate': {'overwrite' : True}},
201 "reset config files in this profile to the defaults.")
202 "reset config files in this profile to the defaults.")
202 create_flags['parallel'] = ({'ProfileCreate': {'parallel' : True}},
203 create_flags['parallel'] = ({'ProfileCreate': {'parallel' : True}},
203 "Include the config files for parallel "
204 "Include the config files for parallel "
204 "computing apps (ipengine, ipcontroller, etc.)")
205 "computing apps (ipengine, ipcontroller, etc.)")
205
206
206
207
207 class ProfileCreate(BaseIPythonApplication):
208 class ProfileCreate(BaseIPythonApplication):
208 name = u'ipython-profile'
209 name = u'ipython-profile'
209 description = create_help
210 description = create_help
210 examples = _create_examples
211 examples = _create_examples
211 auto_create = Bool(True)
212 auto_create = Bool(True)
212 def _log_format_default(self):
213 def _log_format_default(self):
213 return "[%(name)s] %(message)s"
214 return "[%(name)s] %(message)s"
214
215
215 def _copy_config_files_default(self):
216 def _copy_config_files_default(self):
216 return True
217 return True
217
218
218 parallel = Bool(False,
219 parallel = Bool(False,
219 help="whether to include parallel computing config files"
220 help="whether to include parallel computing config files"
220 ).tag(config=True)
221 ).tag(config=True)
221
222
222 @observe('parallel')
223 @observe('parallel')
223 def _parallel_changed(self, change):
224 def _parallel_changed(self, change):
224 parallel_files = [ 'ipcontroller_config.py',
225 parallel_files = [ 'ipcontroller_config.py',
225 'ipengine_config.py',
226 'ipengine_config.py',
226 'ipcluster_config.py'
227 'ipcluster_config.py'
227 ]
228 ]
228 if change['new']:
229 if change['new']:
229 for cf in parallel_files:
230 for cf in parallel_files:
230 self.config_files.append(cf)
231 self.config_files.append(cf)
231 else:
232 else:
232 for cf in parallel_files:
233 for cf in parallel_files:
233 if cf in self.config_files:
234 if cf in self.config_files:
234 self.config_files.remove(cf)
235 self.config_files.remove(cf)
235
236
236 def parse_command_line(self, argv):
237 def parse_command_line(self, argv):
237 super(ProfileCreate, self).parse_command_line(argv)
238 super(ProfileCreate, self).parse_command_line(argv)
238 # accept positional arg as profile name
239 # accept positional arg as profile name
239 if self.extra_args:
240 if self.extra_args:
240 self.profile = self.extra_args[0]
241 self.profile = self.extra_args[0]
241
242
242 flags = Dict(create_flags)
243 flags = Dict(create_flags)
243
244
244 classes = [ProfileDir]
245 classes = [ProfileDir]
245
246
246 def _import_app(self, app_path):
247 def _import_app(self, app_path):
247 """import an app class"""
248 """import an app class"""
248 app = None
249 app = None
249 name = app_path.rsplit('.', 1)[-1]
250 name = app_path.rsplit('.', 1)[-1]
250 try:
251 try:
251 app = import_item(app_path)
252 app = import_item(app_path)
252 except ImportError:
253 except ImportError:
253 self.log.info("Couldn't import %s, config file will be excluded", name)
254 self.log.info("Couldn't import %s, config file will be excluded", name)
254 except Exception:
255 except Exception:
255 self.log.warning('Unexpected error importing %s', name, exc_info=True)
256 self.log.warning('Unexpected error importing %s', name, exc_info=True)
256 return app
257 return app
257
258
258 def init_config_files(self):
259 def init_config_files(self):
259 super(ProfileCreate, self).init_config_files()
260 super(ProfileCreate, self).init_config_files()
260 # use local imports, since these classes may import from here
261 # use local imports, since these classes may import from here
261 from IPython.terminal.ipapp import TerminalIPythonApp
262 from IPython.terminal.ipapp import TerminalIPythonApp
262 apps = [TerminalIPythonApp]
263 apps = [TerminalIPythonApp]
263 for app_path in (
264 for app_path in (
264 'ipykernel.kernelapp.IPKernelApp',
265 'ipykernel.kernelapp.IPKernelApp',
265 ):
266 ):
266 app = self._import_app(app_path)
267 app = self._import_app(app_path)
267 if app is not None:
268 if app is not None:
268 apps.append(app)
269 apps.append(app)
269 if self.parallel:
270 if self.parallel:
270 from ipyparallel.apps.ipcontrollerapp import IPControllerApp
271 from ipyparallel.apps.ipcontrollerapp import IPControllerApp
271 from ipyparallel.apps.ipengineapp import IPEngineApp
272 from ipyparallel.apps.ipengineapp import IPEngineApp
272 from ipyparallel.apps.ipclusterapp import IPClusterStart
273 from ipyparallel.apps.ipclusterapp import IPClusterStart
273 apps.extend([
274 apps.extend([
274 IPControllerApp,
275 IPControllerApp,
275 IPEngineApp,
276 IPEngineApp,
276 IPClusterStart,
277 IPClusterStart,
277 ])
278 ])
278 for App in apps:
279 for App in apps:
279 app = App()
280 app = App()
280 app.config.update(self.config)
281 app.config.update(self.config)
281 app.log = self.log
282 app.log = self.log
282 app.overwrite = self.overwrite
283 app.overwrite = self.overwrite
283 app.copy_config_files=True
284 app.copy_config_files=True
284 app.ipython_dir=self.ipython_dir
285 app.ipython_dir=self.ipython_dir
285 app.profile_dir=self.profile_dir
286 app.profile_dir=self.profile_dir
286 app.init_config_files()
287 app.init_config_files()
287
288
288 def stage_default_config_file(self):
289 def stage_default_config_file(self):
289 pass
290 pass
290
291
291
292
292 class ProfileApp(Application):
293 class ProfileApp(Application):
293 name = u'ipython profile'
294 name = u'ipython profile'
294 description = profile_help
295 description = profile_help
295 examples = _main_examples
296 examples = _main_examples
296
297
297 subcommands = Dict(dict(
298 subcommands = Dict(dict(
298 create = (ProfileCreate, ProfileCreate.description.splitlines()[0]),
299 create = (ProfileCreate, ProfileCreate.description.splitlines()[0]),
299 list = (ProfileList, ProfileList.description.splitlines()[0]),
300 list = (ProfileList, ProfileList.description.splitlines()[0]),
300 locate = (ProfileLocate, ProfileLocate.description.splitlines()[0]),
301 locate = (ProfileLocate, ProfileLocate.description.splitlines()[0]),
301 ))
302 ))
302
303
303 def start(self):
304 def start(self):
304 if self.subapp is None:
305 if self.subapp is None:
305 print("No subcommand specified. Must specify one of: %s"%(self.subcommands.keys()))
306 print("No subcommand specified. Must specify one of: %s"%(self.subcommands.keys()))
306 print()
307 print()
307 self.print_description()
308 self.print_description()
308 self.print_subcommands()
309 self.print_subcommands()
309 self.exit(1)
310 self.exit(1)
310 else:
311 else:
311 return self.subapp.start()
312 return self.subapp.start()
@@ -1,223 +1,223 b''
1 # encoding: utf-8
1 # encoding: utf-8
2 """An object for managing IPython profile directories."""
2 """An object for managing IPython profile directories."""
3
3
4 # Copyright (c) IPython Development Team.
4 # Copyright (c) IPython Development Team.
5 # Distributed under the terms of the Modified BSD License.
5 # Distributed under the terms of the Modified BSD License.
6
6
7 import os
7 import os
8 import shutil
8 import shutil
9 import errno
9 import errno
10
10
11 from traitlets.config.configurable import LoggingConfigurable
11 from traitlets.config.configurable import LoggingConfigurable
12 from ..paths import get_ipython_package_dir
12 from ..paths import get_ipython_package_dir
13 from ..utils.path import expand_path, ensure_dir_exists
13 from ..utils.path import expand_path, ensure_dir_exists
14 from traitlets import Unicode, Bool, observe
14 from traitlets import Unicode, Bool, observe
15
15
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17 # Module errors
17 # Module errors
18 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
19
19
20 class ProfileDirError(Exception):
20 class ProfileDirError(Exception):
21 pass
21 pass
22
22
23
23
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25 # Class for managing profile directories
25 # Class for managing profile directories
26 #-----------------------------------------------------------------------------
26 #-----------------------------------------------------------------------------
27
27
28 class ProfileDir(LoggingConfigurable):
28 class ProfileDir(LoggingConfigurable):
29 """An object to manage the profile directory and its resources.
29 """An object to manage the profile directory and its resources.
30
30
31 The profile directory is used by all IPython applications, to manage
31 The profile directory is used by all IPython applications, to manage
32 configuration, logging and security.
32 configuration, logging and security.
33
33
34 This object knows how to find, create and manage these directories. This
34 This object knows how to find, create and manage these directories. This
35 should be used by any code that wants to handle profiles.
35 should be used by any code that wants to handle profiles.
36 """
36 """
37
37
38 security_dir_name = Unicode('security')
38 security_dir_name = Unicode('security')
39 log_dir_name = Unicode('log')
39 log_dir_name = Unicode('log')
40 startup_dir_name = Unicode('startup')
40 startup_dir_name = Unicode('startup')
41 pid_dir_name = Unicode('pid')
41 pid_dir_name = Unicode('pid')
42 static_dir_name = Unicode('static')
42 static_dir_name = Unicode('static')
43 security_dir = Unicode(u'')
43 security_dir = Unicode(u'')
44 log_dir = Unicode(u'')
44 log_dir = Unicode(u'')
45 startup_dir = Unicode(u'')
45 startup_dir = Unicode(u'')
46 pid_dir = Unicode(u'')
46 pid_dir = Unicode(u'')
47 static_dir = Unicode(u'')
47 static_dir = Unicode(u'')
48
48
49 location = Unicode(u'',
49 location = Unicode(u'',
50 help="""Set the profile location directly. This overrides the logic used by the
50 help="""Set the profile location directly. This overrides the logic used by the
51 `profile` option.""",
51 `profile` option.""",
52 ).tag(config=True)
52 ).tag(config=True)
53
53
54 _location_isset = Bool(False) # flag for detecting multiply set location
54 _location_isset = Bool(False) # flag for detecting multiply set location
55 @observe('location')
55 @observe('location')
56 def _location_changed(self, change):
56 def _location_changed(self, change):
57 if self._location_isset:
57 if self._location_isset:
58 raise RuntimeError("Cannot set profile location more than once.")
58 raise RuntimeError("Cannot set profile location more than once.")
59 self._location_isset = True
59 self._location_isset = True
60 new = change['new']
60 new = change['new']
61 ensure_dir_exists(new)
61 ensure_dir_exists(new)
62
62
63 # ensure config files exist:
63 # ensure config files exist:
64 self.security_dir = os.path.join(new, self.security_dir_name)
64 self.security_dir = os.path.join(new, self.security_dir_name)
65 self.log_dir = os.path.join(new, self.log_dir_name)
65 self.log_dir = os.path.join(new, self.log_dir_name)
66 self.startup_dir = os.path.join(new, self.startup_dir_name)
66 self.startup_dir = os.path.join(new, self.startup_dir_name)
67 self.pid_dir = os.path.join(new, self.pid_dir_name)
67 self.pid_dir = os.path.join(new, self.pid_dir_name)
68 self.static_dir = os.path.join(new, self.static_dir_name)
68 self.static_dir = os.path.join(new, self.static_dir_name)
69 self.check_dirs()
69 self.check_dirs()
70
70
71 def _mkdir(self, path, mode=None):
71 def _mkdir(self, path, mode=None):
72 """ensure a directory exists at a given path
72 """ensure a directory exists at a given path
73
73
74 This is a version of os.mkdir, with the following differences:
74 This is a version of os.mkdir, with the following differences:
75
75
76 - returns True if it created the directory, False otherwise
76 - returns True if it created the directory, False otherwise
77 - ignores EEXIST, protecting against race conditions where
77 - ignores EEXIST, protecting against race conditions where
78 the dir may have been created in between the check and
78 the dir may have been created in between the check and
79 the creation
79 the creation
80 - sets permissions if requested and the dir already exists
80 - sets permissions if requested and the dir already exists
81 """
81 """
82 if os.path.exists(path):
82 if os.path.exists(path):
83 if mode and os.stat(path).st_mode != mode:
83 if mode and os.stat(path).st_mode != mode:
84 try:
84 try:
85 os.chmod(path, mode)
85 os.chmod(path, mode)
86 except OSError:
86 except OSError:
87 self.log.warning(
87 self.log.warning(
88 "Could not set permissions on %s",
88 "Could not set permissions on %s",
89 path
89 path
90 )
90 )
91 return False
91 return False
92 try:
92 try:
93 if mode:
93 if mode:
94 os.mkdir(path, mode)
94 os.mkdir(path, mode)
95 else:
95 else:
96 os.mkdir(path)
96 os.mkdir(path)
97 except OSError as e:
97 except OSError as e:
98 if e.errno == errno.EEXIST:
98 if e.errno == errno.EEXIST:
99 return False
99 return False
100 else:
100 else:
101 raise
101 raise
102
102
103 return True
103 return True
104
104
105 @observe('log_dir')
105 @observe('log_dir')
106 def check_log_dir(self, change=None):
106 def check_log_dir(self, change=None):
107 self._mkdir(self.log_dir)
107 self._mkdir(self.log_dir)
108
108
109 @observe('startup_dir')
109 @observe('startup_dir')
110 def check_startup_dir(self, change=None):
110 def check_startup_dir(self, change=None):
111 self._mkdir(self.startup_dir)
111 self._mkdir(self.startup_dir)
112
112
113 readme = os.path.join(self.startup_dir, 'README')
113 readme = os.path.join(self.startup_dir, 'README')
114 src = os.path.join(get_ipython_package_dir(), u'core', u'profile', u'README_STARTUP')
114 src = os.path.join(get_ipython_package_dir(), u'core', u'profile', u'README_STARTUP')
115
115
116 if not os.path.exists(src):
116 if not os.path.exists(src):
117 self.log.warning("Could not copy README_STARTUP to startup dir. Source file %s does not exist.", src)
117 self.log.warning("Could not copy README_STARTUP to startup dir. Source file %s does not exist.", src)
118
118
119 if os.path.exists(src) and not os.path.exists(readme):
119 if os.path.exists(src) and not os.path.exists(readme):
120 shutil.copy(src, readme)
120 shutil.copy(src, readme)
121
121
122 @observe('security_dir')
122 @observe('security_dir')
123 def check_security_dir(self, change=None):
123 def check_security_dir(self, change=None):
124 self._mkdir(self.security_dir, 0o40700)
124 self._mkdir(self.security_dir, 0o40700)
125
125
126 @observe('pid_dir')
126 @observe('pid_dir')
127 def check_pid_dir(self, change=None):
127 def check_pid_dir(self, change=None):
128 self._mkdir(self.pid_dir, 0o40700)
128 self._mkdir(self.pid_dir, 0o40700)
129
129
130 def check_dirs(self):
130 def check_dirs(self):
131 self.check_security_dir()
131 self.check_security_dir()
132 self.check_log_dir()
132 self.check_log_dir()
133 self.check_pid_dir()
133 self.check_pid_dir()
134 self.check_startup_dir()
134 self.check_startup_dir()
135
135
136 def copy_config_file(self, config_file, path=None, overwrite=False):
136 def copy_config_file(self, config_file, path=None, overwrite=False):
137 """Copy a default config file into the active profile directory.
137 """Copy a default config file into the active profile directory.
138
138
139 Default configuration files are kept in :mod:`IPython.core.profile`.
139 Default configuration files are kept in :mod:`IPython.core.profile`.
140 This function moves these from that location to the working profile
140 This function moves these from that location to the working profile
141 directory.
141 directory.
142 """
142 """
143 dst = os.path.join(self.location, config_file)
143 dst = os.path.join(self.location, config_file)
144 if os.path.isfile(dst) and not overwrite:
144 if os.path.isfile(dst) and not overwrite:
145 return False
145 return False
146 if path is None:
146 if path is None:
147 path = os.path.join(get_ipython_package_dir(), u'core', u'profile', u'default')
147 path = os.path.join(get_ipython_package_dir(), u'core', u'profile', u'default')
148 src = os.path.join(path, config_file)
148 src = os.path.join(path, config_file)
149 shutil.copy(src, dst)
149 shutil.copy(src, dst)
150 return True
150 return True
151
151
152 @classmethod
152 @classmethod
153 def create_profile_dir(cls, profile_dir, config=None):
153 def create_profile_dir(cls, profile_dir, config=None):
154 """Create a new profile directory given a full path.
154 """Create a new profile directory given a full path.
155
155
156 Parameters
156 Parameters
157 ----------
157 ----------
158 profile_dir : str
158 profile_dir : str
159 The full path to the profile directory. If it does exist, it will
159 The full path to the profile directory. If it does exist, it will
160 be used. If not, it will be created.
160 be used. If not, it will be created.
161 """
161 """
162 return cls(location=profile_dir, config=config)
162 return cls(location=profile_dir, config=config)
163
163
164 @classmethod
164 @classmethod
165 def create_profile_dir_by_name(cls, path, name=u'default', config=None):
165 def create_profile_dir_by_name(cls, path, name=u'default', config=None):
166 """Create a profile dir by profile name and path.
166 """Create a profile dir by profile name and path.
167
167
168 Parameters
168 Parameters
169 ----------
169 ----------
170 path : unicode
170 path : unicode
171 The path (directory) to put the profile directory in.
171 The path (directory) to put the profile directory in.
172 name : unicode
172 name : unicode
173 The name of the profile. The name of the profile directory will
173 The name of the profile. The name of the profile directory will
174 be "profile_<profile>".
174 be "profile_<profile>".
175 """
175 """
176 if not os.path.isdir(path):
176 if not os.path.isdir(path):
177 raise ProfileDirError('Directory not found: %s' % path)
177 raise ProfileDirError('Directory not found: %s' % path)
178 profile_dir = os.path.join(path, u'profile_' + name)
178 profile_dir = os.path.join(path, u'profile_' + name)
179 return cls(location=profile_dir, config=config)
179 return cls(location=profile_dir, config=config)
180
180
181 @classmethod
181 @classmethod
182 def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None):
182 def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None):
183 """Find an existing profile dir by profile name, return its ProfileDir.
183 """Find an existing profile dir by profile name, return its ProfileDir.
184
184
185 This searches through a sequence of paths for a profile dir. If it
185 This searches through a sequence of paths for a profile dir. If it
186 is not found, a :class:`ProfileDirError` exception will be raised.
186 is not found, a :class:`ProfileDirError` exception will be raised.
187
187
188 The search path algorithm is:
188 The search path algorithm is:
189 1. ``os.getcwd()``
189 1. ``os.getcwd()`` # removed for security reason.
190 2. ``ipython_dir``
190 2. ``ipython_dir``
191
191
192 Parameters
192 Parameters
193 ----------
193 ----------
194 ipython_dir : unicode or str
194 ipython_dir : unicode or str
195 The IPython directory to use.
195 The IPython directory to use.
196 name : unicode or str
196 name : unicode or str
197 The name of the profile. The name of the profile directory
197 The name of the profile. The name of the profile directory
198 will be "profile_<profile>".
198 will be "profile_<profile>".
199 """
199 """
200 dirname = u'profile_' + name
200 dirname = u'profile_' + name
201 paths = [os.getcwd(), ipython_dir]
201 paths = [ipython_dir]
202 for p in paths:
202 for p in paths:
203 profile_dir = os.path.join(p, dirname)
203 profile_dir = os.path.join(p, dirname)
204 if os.path.isdir(profile_dir):
204 if os.path.isdir(profile_dir):
205 return cls(location=profile_dir, config=config)
205 return cls(location=profile_dir, config=config)
206 else:
206 else:
207 raise ProfileDirError('Profile directory not found in paths: %s' % dirname)
207 raise ProfileDirError('Profile directory not found in paths: %s' % dirname)
208
208
209 @classmethod
209 @classmethod
210 def find_profile_dir(cls, profile_dir, config=None):
210 def find_profile_dir(cls, profile_dir, config=None):
211 """Find/create a profile dir and return its ProfileDir.
211 """Find/create a profile dir and return its ProfileDir.
212
212
213 This will create the profile directory if it doesn't exist.
213 This will create the profile directory if it doesn't exist.
214
214
215 Parameters
215 Parameters
216 ----------
216 ----------
217 profile_dir : unicode or str
217 profile_dir : unicode or str
218 The path of the profile directory.
218 The path of the profile directory.
219 """
219 """
220 profile_dir = expand_path(profile_dir)
220 profile_dir = expand_path(profile_dir)
221 if not os.path.isdir(profile_dir):
221 if not os.path.isdir(profile_dir):
222 raise ProfileDirError('Profile directory not found: %s' % profile_dir)
222 raise ProfileDirError('Profile directory not found: %s' % profile_dir)
223 return cls(location=profile_dir, config=config)
223 return cls(location=profile_dir, config=config)
@@ -1,1740 +1,1747 b''
1 ============
1 ============
2 7.x Series
2 7.x Series
3 ============
3 ============
4
4
5 .. _version 7.31.1:
6
7 IPython 7.31.1 (CVE-2022-21699)
8 ===============================
9
10 Fixed CVE-2022-21699, see IPython 8.0.1 release notes for informations.
11
5
12
6 .. _version 7.31:
13 .. _version 7.31:
7
14
8 IPython 7.31
15 IPython 7.31
9 ============
16 ============
10
17
11 IPython 7.31 brings a couple of backports and fixes from the 8.0 branches,
18 IPython 7.31 brings a couple of backports and fixes from the 8.0 branches,
12 it is likely one of the last releases of the 7.x series, as 8.0 will probably be released
19 it is likely one of the last releases of the 7.x series, as 8.0 will probably be released
13 between this release and what would have been 7.32.
20 between this release and what would have been 7.32.
14
21
15 Please test 8.0 beta/rc releases in addition to this release.
22 Please test 8.0 beta/rc releases in addition to this release.
16
23
17 This Releases:
24 This Releases:
18 - Backport some fixes for Python 3.10 (:ghpull:`13412`)
25 - Backport some fixes for Python 3.10 (:ghpull:`13412`)
19 - use full-alpha transparency on dvipng rendered LaTeX (:ghpull:`13372`)
26 - use full-alpha transparency on dvipng rendered LaTeX (:ghpull:`13372`)
20
27
21 Many thanks to all the contributors to this release. You can find all individual
28 Many thanks to all the contributors to this release. You can find all individual
22 contributions to this milestone `on github
29 contributions to this milestone `on github
23 <https://github.com/ipython/ipython/milestone/95>`__.
30 <https://github.com/ipython/ipython/milestone/95>`__.
24
31
25 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
32 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
26 work on IPython and related libraries.
33 work on IPython and related libraries.
27
34
28
35
29 .. _version 7.30:
36 .. _version 7.30:
30
37
31 IPython 7.30
38 IPython 7.30
32 ============
39 ============
33
40
34 IPython 7.30 fixes a couple of bugs introduce in previous releases (in
41 IPython 7.30 fixes a couple of bugs introduce in previous releases (in
35 particular with respect to path handling), and introduce a few features and
42 particular with respect to path handling), and introduce a few features and
36 improvements:
43 improvements:
37
44
38 Notably we will highlight :ghpull:`13267` "Document that ``%run`` can execute
45 Notably we will highlight :ghpull:`13267` "Document that ``%run`` can execute
39 notebooks and ipy scripts.", which is the first commit of Fernando PΓ©rez since
46 notebooks and ipy scripts.", which is the first commit of Fernando PΓ©rez since
40 mid 2016 (IPython 5.1). If you are new to IPython, Fernando created IPython in
47 mid 2016 (IPython 5.1). If you are new to IPython, Fernando created IPython in
41 2001. The other most recent contribution of Fernando to IPython itself was
48 2001. The other most recent contribution of Fernando to IPython itself was
42 May 2018, by reviewing and merging PRs. I want to note that Fernando is still
49 May 2018, by reviewing and merging PRs. I want to note that Fernando is still
43 active but mostly as a mentor and leader of the whole Jupyter organisation, but
50 active but mostly as a mentor and leader of the whole Jupyter organisation, but
44 we're still happy to see him contribute code !
51 we're still happy to see him contribute code !
45
52
46 :ghpull:`13290` "Use sphinxify (if available) in object_inspect_mime path"
53 :ghpull:`13290` "Use sphinxify (if available) in object_inspect_mime path"
47 should allow richer Repr of docstrings when using jupyterlab inspector.
54 should allow richer Repr of docstrings when using jupyterlab inspector.
48
55
49 :ghpull:`13311` make the debugger use ``ThreadPoolExecutor`` for debugger cmdloop.
56 :ghpull:`13311` make the debugger use ``ThreadPoolExecutor`` for debugger cmdloop.
50 This should fix some issues/infinite loop, but let us know if you come across
57 This should fix some issues/infinite loop, but let us know if you come across
51 any regressions. In particular this fixes issues with `kmaork/madbg <https://github.com/kmaork/madbg>`_,
58 any regressions. In particular this fixes issues with `kmaork/madbg <https://github.com/kmaork/madbg>`_,
52 a remote debugger for IPython.
59 a remote debugger for IPython.
53
60
54 Note that this is likely the ante-penultimate release of IPython 7.x as a stable
61 Note that this is likely the ante-penultimate release of IPython 7.x as a stable
55 branch, as I hope to release IPython 8.0 as well as IPython 7.31 next
62 branch, as I hope to release IPython 8.0 as well as IPython 7.31 next
56 month/early 2022.
63 month/early 2022.
57
64
58 IPython 8.0 will drop support for Python 3.7, removed nose as a dependency, and
65 IPython 8.0 will drop support for Python 3.7, removed nose as a dependency, and
59 7.x will only get critical bug fixes with 8.x becoming the new stable. This will
66 7.x will only get critical bug fixes with 8.x becoming the new stable. This will
60 not be possible without `NumFOCUS Small Development Grants
67 not be possible without `NumFOCUS Small Development Grants
61 <https://numfocus.org/programs/small-development-grants>`_ Which allowed us to
68 <https://numfocus.org/programs/small-development-grants>`_ Which allowed us to
62 hire `Nikita Kniazev <https://github.com/Kojoley>`_ who provide Python and C++
69 hire `Nikita Kniazev <https://github.com/Kojoley>`_ who provide Python and C++
63 help and contracting work.
70 help and contracting work.
64
71
65
72
66 Many thanks to all the contributors to this release. You can find all individual
73 Many thanks to all the contributors to this release. You can find all individual
67 contributions to this milestone `on github
74 contributions to this milestone `on github
68 <https://github.com/ipython/ipython/milestone/94?closed=1>`__.
75 <https://github.com/ipython/ipython/milestone/94?closed=1>`__.
69
76
70 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
77 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
71 work on IPython and related libraries.
78 work on IPython and related libraries.
72
79
73
80
74 .. _version 7.29:
81 .. _version 7.29:
75
82
76 IPython 7.29
83 IPython 7.29
77 ============
84 ============
78
85
79
86
80 IPython 7.29 brings a couple of new functionalities to IPython and a number of bugfixes.
87 IPython 7.29 brings a couple of new functionalities to IPython and a number of bugfixes.
81 It is one of the largest recent release, relatively speaking, with close to 15 Pull Requests.
88 It is one of the largest recent release, relatively speaking, with close to 15 Pull Requests.
82
89
83
90
84 - fix an issue where base64 was returned instead of bytes when showing figures :ghpull:`13162`
91 - fix an issue where base64 was returned instead of bytes when showing figures :ghpull:`13162`
85 - fix compatibility with PyQt6, PySide 6 :ghpull:`13172`. This may be of
92 - fix compatibility with PyQt6, PySide 6 :ghpull:`13172`. This may be of
86 interest if you are running on Apple Silicon as only qt6.2+ is natively
93 interest if you are running on Apple Silicon as only qt6.2+ is natively
87 compatible.
94 compatible.
88 - fix matplotlib qtagg eventloop :ghpull:`13179`
95 - fix matplotlib qtagg eventloop :ghpull:`13179`
89 - Multiple docs fixes, typos, ... etc.
96 - Multiple docs fixes, typos, ... etc.
90 - Debugger will now exit by default on SigInt :ghpull:`13218`, this will be
97 - Debugger will now exit by default on SigInt :ghpull:`13218`, this will be
91 useful in notebook/lab if you forgot to exit the debugger. "Interrupt Kernel"
98 useful in notebook/lab if you forgot to exit the debugger. "Interrupt Kernel"
92 will now exist the debugger.
99 will now exist the debugger.
93
100
94 It give Pdb the ability to skip code in decorators. If functions contain a
101 It give Pdb the ability to skip code in decorators. If functions contain a
95 special value names ``__debuggerskip__ = True|False``, the function will not be
102 special value names ``__debuggerskip__ = True|False``, the function will not be
96 stepped into, and Pdb will step into lower frames only if the value is set to
103 stepped into, and Pdb will step into lower frames only if the value is set to
97 ``False``. The exact behavior is still likely to have corner cases and will be
104 ``False``. The exact behavior is still likely to have corner cases and will be
98 refined in subsequent releases. Feedback welcome. See the debugger module
105 refined in subsequent releases. Feedback welcome. See the debugger module
99 documentation for more info. Thanks to the `D. E. Shaw
106 documentation for more info. Thanks to the `D. E. Shaw
100 group <https://deshaw.com/>`__ for funding this feature.
107 group <https://deshaw.com/>`__ for funding this feature.
101
108
102 The main branch of IPython is receiving a number of changes as we received a
109 The main branch of IPython is receiving a number of changes as we received a
103 `NumFOCUS SDG <https://numfocus.org/programs/small-development-grants>`__
110 `NumFOCUS SDG <https://numfocus.org/programs/small-development-grants>`__
104 ($4800), to help us finish replacing ``nose`` by ``pytest``, and make IPython
111 ($4800), to help us finish replacing ``nose`` by ``pytest``, and make IPython
105 future proof with an 8.0 release.
112 future proof with an 8.0 release.
106
113
107
114
108 Many thanks to all the contributors to this release. You can find all individual
115 Many thanks to all the contributors to this release. You can find all individual
109 contributions to this milestone `on github
116 contributions to this milestone `on github
110 <https://github.com/ipython/ipython/milestone/93>`__.
117 <https://github.com/ipython/ipython/milestone/93>`__.
111
118
112 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
119 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
113 work on IPython and related libraries.
120 work on IPython and related libraries.
114
121
115
122
116 .. _version 7.28:
123 .. _version 7.28:
117
124
118 IPython 7.28
125 IPython 7.28
119 ============
126 ============
120
127
121
128
122 IPython 7.28 is again a minor release that mostly bring bugfixes, and couple of
129 IPython 7.28 is again a minor release that mostly bring bugfixes, and couple of
123 improvement. Many thanks to MrMino, who again did all the work this month, and
130 improvement. Many thanks to MrMino, who again did all the work this month, and
124 made a number of documentation improvements.
131 made a number of documentation improvements.
125
132
126 Here is a non-exhaustive list of changes,
133 Here is a non-exhaustive list of changes,
127
134
128 Fixes:
135 Fixes:
129
136
130 - async with doesn't allow newlines :ghpull:`13090`
137 - async with doesn't allow newlines :ghpull:`13090`
131 - Dynamically changing to vi mode via %config magic) :ghpull:`13091`
138 - Dynamically changing to vi mode via %config magic) :ghpull:`13091`
132
139
133 Virtualenv handling fixes:
140 Virtualenv handling fixes:
134
141
135 - init_virtualenv now uses Pathlib :ghpull:`12548`
142 - init_virtualenv now uses Pathlib :ghpull:`12548`
136 - Fix Improper path comparison of virtualenv directories :ghpull:`13140`
143 - Fix Improper path comparison of virtualenv directories :ghpull:`13140`
137 - Fix virtual environment user warning for lower case pathes :ghpull:`13094`
144 - Fix virtual environment user warning for lower case pathes :ghpull:`13094`
138 - Adapt to all sorts of drive names for cygwin :ghpull:`13153`
145 - Adapt to all sorts of drive names for cygwin :ghpull:`13153`
139
146
140 New Features:
147 New Features:
141
148
142 - enable autoplay in embed YouTube player :ghpull:`13133`
149 - enable autoplay in embed YouTube player :ghpull:`13133`
143
150
144 Documentation:
151 Documentation:
145
152
146 - Fix formatting for the core.interactiveshell documentation :ghpull:`13118`
153 - Fix formatting for the core.interactiveshell documentation :ghpull:`13118`
147 - Fix broken ipyparallel's refs :ghpull:`13138`
154 - Fix broken ipyparallel's refs :ghpull:`13138`
148 - Improve formatting of %time documentation :ghpull:`13125`
155 - Improve formatting of %time documentation :ghpull:`13125`
149 - Reword the YouTubeVideo autoplay WN :ghpull:`13147`
156 - Reword the YouTubeVideo autoplay WN :ghpull:`13147`
150
157
151
158
152 Highlighted features
159 Highlighted features
153 --------------------
160 --------------------
154
161
155
162
156 ``YouTubeVideo`` autoplay and the ability to add extra attributes to ``IFrame``
163 ``YouTubeVideo`` autoplay and the ability to add extra attributes to ``IFrame``
157 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158
165
159 You can add any extra attributes to the ``<iframe>`` tag using the new
166 You can add any extra attributes to the ``<iframe>`` tag using the new
160 ``extras`` argument in the ``IFrame`` class. For example::
167 ``extras`` argument in the ``IFrame`` class. For example::
161
168
162 In [1]: from IPython.display import IFrame
169 In [1]: from IPython.display import IFrame
163
170
164 In [2]: IFrame(src="src", width=300, height=300, extras=['loading="eager"'])
171 In [2]: IFrame(src="src", width=300, height=300, extras=['loading="eager"'])
165
172
166 The above cells will result in the following HTML code being displayed in a
173 The above cells will result in the following HTML code being displayed in a
167 notebook::
174 notebook::
168
175
169 <iframe
176 <iframe
170 width="300"
177 width="300"
171 height="300"
178 height="300"
172 src="src"
179 src="src"
173 frameborder="0"
180 frameborder="0"
174 allowfullscreen
181 allowfullscreen
175 loading="eager"
182 loading="eager"
176 ></iframe>
183 ></iframe>
177
184
178 Related to the above, the ``YouTubeVideo`` class now takes an
185 Related to the above, the ``YouTubeVideo`` class now takes an
179 ``allow_autoplay`` flag, which sets up the iframe of the embedded YouTube video
186 ``allow_autoplay`` flag, which sets up the iframe of the embedded YouTube video
180 such that it allows autoplay.
187 such that it allows autoplay.
181
188
182 .. note::
189 .. note::
183 Whether this works depends on the autoplay policy of the browser rendering
190 Whether this works depends on the autoplay policy of the browser rendering
184 the HTML allowing it. It also could get blocked by some browser extensions.
191 the HTML allowing it. It also could get blocked by some browser extensions.
185
192
186 Try it out!
193 Try it out!
187 ::
194 ::
188
195
189 In [1]: from IPython.display import YouTubeVideo
196 In [1]: from IPython.display import YouTubeVideo
190
197
191 In [2]: YouTubeVideo("dQw4w9WgXcQ", allow_autoplay=True)
198 In [2]: YouTubeVideo("dQw4w9WgXcQ", allow_autoplay=True)
192
199
193
200
194
201
195 Thanks
202 Thanks
196 ------
203 ------
197
204
198 Many thanks to all the contributors to this release. You can find all individual
205 Many thanks to all the contributors to this release. You can find all individual
199 contributions to this milestone `on github
206 contributions to this milestone `on github
200 <https://github.com/ipython/ipython/milestone/92>`__.
207 <https://github.com/ipython/ipython/milestone/92>`__.
201
208
202 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
209 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
203 work on IPython and related libraries.
210 work on IPython and related libraries.
204
211
205
212
206 .. _version 7.27:
213 .. _version 7.27:
207
214
208 IPython 7.27
215 IPython 7.27
209 ============
216 ============
210
217
211 IPython 7.27 is a minor release that fixes a couple of issues and compatibility.
218 IPython 7.27 is a minor release that fixes a couple of issues and compatibility.
212
219
213 - Add support for GTK4 :ghpull:`131011`
220 - Add support for GTK4 :ghpull:`131011`
214 - Add support for Qt6 :ghpull:`13085`
221 - Add support for Qt6 :ghpull:`13085`
215 - Fix an issue with pip magic on windows :ghpull:`13093`
222 - Fix an issue with pip magic on windows :ghpull:`13093`
216
223
217 Thanks
224 Thanks
218 ------
225 ------
219
226
220 Many thanks to all the contributors to this release. You can find all individual
227 Many thanks to all the contributors to this release. You can find all individual
221 contributions to this milestone `on github
228 contributions to this milestone `on github
222 <https://github.com/ipython/ipython/milestone/91>`__.
229 <https://github.com/ipython/ipython/milestone/91>`__.
223
230
224 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
231 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
225 work on IPython and related libraries.
232 work on IPython and related libraries.
226
233
227 .. _version 7.26:
234 .. _version 7.26:
228
235
229 IPython 7.26
236 IPython 7.26
230 ============
237 ============
231
238
232 IPython 7.26 is a minor release that fixes a couple of issues, updates in API
239 IPython 7.26 is a minor release that fixes a couple of issues, updates in API
233 and Copyright/Licenses issues around various part of the codebase.
240 and Copyright/Licenses issues around various part of the codebase.
234
241
235 We'll highlight `this issue <https://github.com/ipython/ipython/issues/13039>`
242 We'll highlight `this issue <https://github.com/ipython/ipython/issues/13039>`
236 pointing out we were including and refereeing to code from Stack Overflow which
243 pointing out we were including and refereeing to code from Stack Overflow which
237 was CC-BY-SA, hence incompatible with the BSD license of IPython. This lead us
244 was CC-BY-SA, hence incompatible with the BSD license of IPython. This lead us
238 to a rewriting of the corresponding logic which in our case was done in a more
245 to a rewriting of the corresponding logic which in our case was done in a more
239 efficient way (in our case we were searching string prefixes instead of full
246 efficient way (in our case we were searching string prefixes instead of full
240 strings).
247 strings).
241
248
242 You will notice also a number of documentation improvements and cleanup.
249 You will notice also a number of documentation improvements and cleanup.
243
250
244 Of particular interest are the following Pull-requests:
251 Of particular interest are the following Pull-requests:
245
252
246
253
247 - The IPython directive now uses Sphinx logging for warnings. :ghpull:`13030`.
254 - The IPython directive now uses Sphinx logging for warnings. :ghpull:`13030`.
248 - Add expiry days option to pastebin magic and change http protocol to https.
255 - Add expiry days option to pastebin magic and change http protocol to https.
249 :ghpull:`13056`
256 :ghpull:`13056`
250 - Make Ipython.utils.timing work with jupyterlite :ghpull:`13050`.
257 - Make Ipython.utils.timing work with jupyterlite :ghpull:`13050`.
251
258
252 Pastebin magic expiry days option
259 Pastebin magic expiry days option
253 ---------------------------------
260 ---------------------------------
254
261
255 The Pastebin magic now has ``-e`` option to determine
262 The Pastebin magic now has ``-e`` option to determine
256 the number of days for paste expiration. For example
263 the number of days for paste expiration. For example
257 the paste that created with ``%pastebin -e 20 1`` magic will
264 the paste that created with ``%pastebin -e 20 1`` magic will
258 be available for next 20 days.
265 be available for next 20 days.
259
266
260
267
261
268
262
269
263
270
264 Thanks
271 Thanks
265 ------
272 ------
266
273
267 Many thanks to all the contributors to this release and in particular MrMino who
274 Many thanks to all the contributors to this release and in particular MrMino who
268 is doing most of the work those days. You can find all individual contributions
275 is doing most of the work those days. You can find all individual contributions
269 to this milestone `on github <https://github.com/ipython/ipython/milestone/90>`__.
276 to this milestone `on github <https://github.com/ipython/ipython/milestone/90>`__.
270
277
271 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
278 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
272 work on IPython and related libraries.
279 work on IPython and related libraries.
273
280
274
281
275 .. _version 7.25:
282 .. _version 7.25:
276
283
277 IPython 7.25
284 IPython 7.25
278 ============
285 ============
279
286
280 IPython 7.25 is a minor release that contains a single bugfix, which is highly
287 IPython 7.25 is a minor release that contains a single bugfix, which is highly
281 recommended for all users of ipdb, ipython debugger %debug magic and similar.
288 recommended for all users of ipdb, ipython debugger %debug magic and similar.
282
289
283 Issuing commands like ``where`` from within the debugger would reset the
290 Issuing commands like ``where`` from within the debugger would reset the
284 local variables changes made by the user. It is interesting to look at the root
291 local variables changes made by the user. It is interesting to look at the root
285 cause of the issue as accessing an attribute (``frame.f_locals``) would trigger
292 cause of the issue as accessing an attribute (``frame.f_locals``) would trigger
286 this side effects.
293 this side effects.
287
294
288 Thanks in particular to the patience from the reporters at D.E. Shaw for their
295 Thanks in particular to the patience from the reporters at D.E. Shaw for their
289 initial bug report that was due to a similar coding oversight in an extension,
296 initial bug report that was due to a similar coding oversight in an extension,
290 and who took time to debug and narrow down the problem.
297 and who took time to debug and narrow down the problem.
291
298
292 Thanks
299 Thanks
293 ------
300 ------
294
301
295 Many thanks to all the contributors to this release you can find all individual
302 Many thanks to all the contributors to this release you can find all individual
296 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/89>`__.
303 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/89>`__.
297
304
298 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
305 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
299 work on IPython and related libraries.
306 work on IPython and related libraries.
300
307
301
308
302 .. _version 7.24:
309 .. _version 7.24:
303
310
304 IPython 7.24
311 IPython 7.24
305 ============
312 ============
306
313
307 Third release of IPython for 2021, mostly containing bug fixes. A couple of not
314 Third release of IPython for 2021, mostly containing bug fixes. A couple of not
308 typical updates:
315 typical updates:
309
316
310 Misc
317 Misc
311 ----
318 ----
312
319
313
320
314 - Fix an issue where ``%recall`` would both succeeded and print an error message
321 - Fix an issue where ``%recall`` would both succeeded and print an error message
315 it failed. :ghpull:`12952`
322 it failed. :ghpull:`12952`
316 - Drop support for NumPy 1.16 – practically has no effect beyond indicating in
323 - Drop support for NumPy 1.16 – practically has no effect beyond indicating in
317 package metadata that we do not support it. :ghpull:`12937`
324 package metadata that we do not support it. :ghpull:`12937`
318
325
319 Debugger improvements
326 Debugger improvements
320 ---------------------
327 ---------------------
321
328
322 The debugger (and ``%debug`` magic) have been improved and can skip or hide frames
329 The debugger (and ``%debug`` magic) have been improved and can skip or hide frames
323 originating from files that are not writable to the user, as these are less
330 originating from files that are not writable to the user, as these are less
324 likely to be the source of errors, or be part of system files this can be a useful
331 likely to be the source of errors, or be part of system files this can be a useful
325 addition when debugging long errors.
332 addition when debugging long errors.
326
333
327 In addition to the global ``skip_hidden True|False`` command, the debugger has
334 In addition to the global ``skip_hidden True|False`` command, the debugger has
328 gained finer grained control of predicates as to whether to a frame should be
335 gained finer grained control of predicates as to whether to a frame should be
329 considered hidden. So far 3 predicates are available :
336 considered hidden. So far 3 predicates are available :
330
337
331 - ``tbhide``: frames containing the local variable ``__tracebackhide__`` set to
338 - ``tbhide``: frames containing the local variable ``__tracebackhide__`` set to
332 True.
339 True.
333 - ``readonly``: frames originating from readonly files, set to False.
340 - ``readonly``: frames originating from readonly files, set to False.
334 - ``ipython_internal``: frames that are likely to be from IPython internal
341 - ``ipython_internal``: frames that are likely to be from IPython internal
335 code, set to True.
342 code, set to True.
336
343
337 You can toggle individual predicates during a session with
344 You can toggle individual predicates during a session with
338
345
339 .. code-block::
346 .. code-block::
340
347
341 ipdb> skip_predicates readonly True
348 ipdb> skip_predicates readonly True
342
349
343 Read-only files will now be considered hidden frames.
350 Read-only files will now be considered hidden frames.
344
351
345
352
346 You can call ``skip_predicates`` without arguments to see the states of current
353 You can call ``skip_predicates`` without arguments to see the states of current
347 predicates:
354 predicates:
348
355
349 .. code-block::
356 .. code-block::
350
357
351 ipdb> skip_predicates
358 ipdb> skip_predicates
352 current predicates:
359 current predicates:
353 tbhide : True
360 tbhide : True
354 readonly : False
361 readonly : False
355 ipython_internal : True
362 ipython_internal : True
356
363
357 If all predicates are set to ``False``, ``skip_hidden`` will practically have
364 If all predicates are set to ``False``, ``skip_hidden`` will practically have
358 no effect. We attempt to warn you when all predicates are False.
365 no effect. We attempt to warn you when all predicates are False.
359
366
360 Note that the ``readonly`` predicate may increase disk access as we check for
367 Note that the ``readonly`` predicate may increase disk access as we check for
361 file access permission for all frames on many command invocation, but is usually
368 file access permission for all frames on many command invocation, but is usually
362 cached by operating systems. Let us know if you encounter any issues.
369 cached by operating systems. Let us know if you encounter any issues.
363
370
364 As the IPython debugger does not use the traitlets infrastructure for
371 As the IPython debugger does not use the traitlets infrastructure for
365 configuration, by editing your ``.pdbrc`` files and appending commands you would
372 configuration, by editing your ``.pdbrc`` files and appending commands you would
366 like to be executed just before entering the interactive prompt. For example:
373 like to be executed just before entering the interactive prompt. For example:
367
374
368
375
369 .. code::
376 .. code::
370
377
371 # file : ~/.pdbrc
378 # file : ~/.pdbrc
372 skip_predicates readonly True
379 skip_predicates readonly True
373 skip_predicates tbhide False
380 skip_predicates tbhide False
374
381
375 Will hide read only frames by default and show frames marked with
382 Will hide read only frames by default and show frames marked with
376 ``__tracebackhide__``.
383 ``__tracebackhide__``.
377
384
378
385
379
386
380
387
381 Thanks
388 Thanks
382 ------
389 ------
383
390
384 Many thanks to all the contributors to this release you can find all individual
391 Many thanks to all the contributors to this release you can find all individual
385 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/87>`__.
392 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/87>`__.
386
393
387 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
394 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
388 work on IPython and related libraries, in particular above mentioned
395 work on IPython and related libraries, in particular above mentioned
389 improvements to the debugger.
396 improvements to the debugger.
390
397
391
398
392
399
393
400
394 .. _version 7.23:
401 .. _version 7.23:
395
402
396 IPython 7.23 and 7.23.1
403 IPython 7.23 and 7.23.1
397 =======================
404 =======================
398
405
399
406
400 Third release of IPython for 2021, mostly containing bug fixes. A couple of not
407 Third release of IPython for 2021, mostly containing bug fixes. A couple of not
401 typical updates:
408 typical updates:
402
409
403 - We moved to GitHub actions away from Travis-CI, the transition may not be
410 - We moved to GitHub actions away from Travis-CI, the transition may not be
404 100% complete (not testing on nightly anymore), but as we ran out of
411 100% complete (not testing on nightly anymore), but as we ran out of
405 Travis-Ci hours on the IPython organisation that was a necessary step.
412 Travis-Ci hours on the IPython organisation that was a necessary step.
406 :ghpull:`12900`.
413 :ghpull:`12900`.
407
414
408 - We have a new dependency: ``matplotlib-inline``, which try to extract
415 - We have a new dependency: ``matplotlib-inline``, which try to extract
409 matplotlib inline backend specific behavior. It is available on PyPI and
416 matplotlib inline backend specific behavior. It is available on PyPI and
410 conda-forge thus should not be a problem to upgrade to this version. If you
417 conda-forge thus should not be a problem to upgrade to this version. If you
411 are a package maintainer that might be an extra dependency to package first.
418 are a package maintainer that might be an extra dependency to package first.
412 :ghpull:`12817` (IPython 7.23.1 fix a typo that made this change fail)
419 :ghpull:`12817` (IPython 7.23.1 fix a typo that made this change fail)
413
420
414 In the addition/new feature category, ``display()`` now have a ``clear=True``
421 In the addition/new feature category, ``display()`` now have a ``clear=True``
415 option to clear the display if any further outputs arrives, allowing users to
422 option to clear the display if any further outputs arrives, allowing users to
416 avoid having to use ``clear_output()`` directly. :ghpull:`12823`.
423 avoid having to use ``clear_output()`` directly. :ghpull:`12823`.
417
424
418 In bug fixes category, this release fix an issue when printing tracebacks
425 In bug fixes category, this release fix an issue when printing tracebacks
419 containing Unicode characters :ghpull:`12758`.
426 containing Unicode characters :ghpull:`12758`.
420
427
421 In code cleanup category :ghpull:`12932` remove usage of some deprecated
428 In code cleanup category :ghpull:`12932` remove usage of some deprecated
422 functionality for compatibility with Python 3.10.
429 functionality for compatibility with Python 3.10.
423
430
424
431
425
432
426 Thanks
433 Thanks
427 ------
434 ------
428
435
429 Many thanks to all the contributors to this release you can find all individual
436 Many thanks to all the contributors to this release you can find all individual
430 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/86>`__.
437 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/86>`__.
431 In particular MrMino for responding to almost all new issues, and triaging many
438 In particular MrMino for responding to almost all new issues, and triaging many
432 of the old ones, as well as takluyver, minrk, willingc for reacting quikly when
439 of the old ones, as well as takluyver, minrk, willingc for reacting quikly when
433 we ran out of CI Hours.
440 we ran out of CI Hours.
434
441
435 Thanks as well to organisations, QuantStack (martinRenou and SylvainCorlay) for
442 Thanks as well to organisations, QuantStack (martinRenou and SylvainCorlay) for
436 extracting matplotlib inline backend into its own package, and the `D. E. Shaw group
443 extracting matplotlib inline backend into its own package, and the `D. E. Shaw group
437 <https://deshaw.com/>`__ for sponsoring work on IPython and related libraries.
444 <https://deshaw.com/>`__ for sponsoring work on IPython and related libraries.
438
445
439
446
440 .. _version 7.22:
447 .. _version 7.22:
441
448
442 IPython 7.22
449 IPython 7.22
443 ============
450 ============
444
451
445 Second release of IPython for 2021, mostly containing bug fixes. Here is a quick
452 Second release of IPython for 2021, mostly containing bug fixes. Here is a quick
446 rundown of the few changes.
453 rundown of the few changes.
447
454
448 - Fix some ``sys.excepthook`` shenanigan when embedding with qt, recommended if
455 - Fix some ``sys.excepthook`` shenanigan when embedding with qt, recommended if
449 you – for example – use `napari <https://napari.org>`__. :ghpull:`12842`.
456 you – for example – use `napari <https://napari.org>`__. :ghpull:`12842`.
450 - Fix bug when using the new ipdb ``%context`` magic :ghpull:`12844`
457 - Fix bug when using the new ipdb ``%context`` magic :ghpull:`12844`
451 - Couples of deprecation cleanup :ghpull:`12868`
458 - Couples of deprecation cleanup :ghpull:`12868`
452 - Update for new dpast.com api if you use the ``%pastbin`` magic. :ghpull:`12712`
459 - Update for new dpast.com api if you use the ``%pastbin`` magic. :ghpull:`12712`
453 - Remove support for numpy before 1.16. :ghpull:`12836`
460 - Remove support for numpy before 1.16. :ghpull:`12836`
454
461
455
462
456 Thanks
463 Thanks
457 ------
464 ------
458
465
459 We have a new team member that you should see more often on the IPython
466 We have a new team member that you should see more often on the IPython
460 repository, BΕ‚aΕΌej Michalik (@MrMino) have been doing regular contributions to
467 repository, BΕ‚aΕΌej Michalik (@MrMino) have been doing regular contributions to
461 IPython, and spent time replying to many issues and guiding new users to the
468 IPython, and spent time replying to many issues and guiding new users to the
462 codebase; they now have triage permissions to the IPython repository and we'll
469 codebase; they now have triage permissions to the IPython repository and we'll
463 work toward giving them more permission in the future.
470 work toward giving them more permission in the future.
464
471
465 Many thanks to all the contributors to this release you can find all individual
472 Many thanks to all the contributors to this release you can find all individual
466 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/84>`__.
473 contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/84>`__.
467
474
468 Thanks as well to organisations, QuantStack for working on debugger
475 Thanks as well to organisations, QuantStack for working on debugger
469 compatibility for Xeus_python, and the `D. E. Shaw group
476 compatibility for Xeus_python, and the `D. E. Shaw group
470 <https://deshaw.com/>`__ for sponsoring work on IPython and related libraries.
477 <https://deshaw.com/>`__ for sponsoring work on IPython and related libraries.
471
478
472 .. _version 721:
479 .. _version 721:
473
480
474 IPython 7.21
481 IPython 7.21
475 ============
482 ============
476
483
477 IPython 7.21 is the first release we have back on schedule of one release every
484 IPython 7.21 is the first release we have back on schedule of one release every
478 month; it contains a number of minor fixes and improvements, notably, the new
485 month; it contains a number of minor fixes and improvements, notably, the new
479 context command for ipdb
486 context command for ipdb
480
487
481
488
482 New "context" command in ipdb
489 New "context" command in ipdb
483 -----------------------------
490 -----------------------------
484
491
485 It is now possible to change the number of lines shown in the backtrace
492 It is now possible to change the number of lines shown in the backtrace
486 information in ipdb using "context" command. :ghpull:`12826`
493 information in ipdb using "context" command. :ghpull:`12826`
487
494
488 (thanks @MrMino, there are other improvement from them on master).
495 (thanks @MrMino, there are other improvement from them on master).
489
496
490 Other notable changes in IPython 7.21
497 Other notable changes in IPython 7.21
491 -------------------------------------
498 -------------------------------------
492
499
493 - Fix some issues on new osx-arm64 :ghpull:`12804`, :ghpull:`12807`.
500 - Fix some issues on new osx-arm64 :ghpull:`12804`, :ghpull:`12807`.
494 - Compatibility with Xeus-Python for debugger protocol, :ghpull:`12809`
501 - Compatibility with Xeus-Python for debugger protocol, :ghpull:`12809`
495 - Misc docs fixes for compatibility and uniformity with Numpydoc.
502 - Misc docs fixes for compatibility and uniformity with Numpydoc.
496 :ghpull:`12824`
503 :ghpull:`12824`
497
504
498
505
499 Thanks
506 Thanks
500 ------
507 ------
501
508
502 Many thanks to all the contributors to this release you can find all individual
509 Many thanks to all the contributors to this release you can find all individual
503 contribution to this milestone `on github <https://github.com/ipython/ipython/milestone/83>`__.
510 contribution to this milestone `on github <https://github.com/ipython/ipython/milestone/83>`__.
504
511
505
512
506 .. _version 720:
513 .. _version 720:
507
514
508 IPython 7.20
515 IPython 7.20
509 ============
516 ============
510
517
511 IPython 7.20 is the accumulation of 3 month of work on IPython, spacing between
518 IPython 7.20 is the accumulation of 3 month of work on IPython, spacing between
512 IPython release have been increased from the usual once a month for various
519 IPython release have been increased from the usual once a month for various
513 reason.
520 reason.
514
521
515 - Mainly as I'm too busy and the effectively sole maintainer, and
522 - Mainly as I'm too busy and the effectively sole maintainer, and
516 - Second because not much changes happened before mid December.
523 - Second because not much changes happened before mid December.
517
524
518 The main driver for this release was the new version of Jedi 0.18 breaking API;
525 The main driver for this release was the new version of Jedi 0.18 breaking API;
519 which was taken care of in the master branch early in 2020 but not in 7.x as I
526 which was taken care of in the master branch early in 2020 but not in 7.x as I
520 though that by now 8.0 would be out.
527 though that by now 8.0 would be out.
521
528
522 The inclusion of a resolver in pip did not help and actually made things worse.
529 The inclusion of a resolver in pip did not help and actually made things worse.
523 If usually I would have simply pinned Jedi to ``<0.18``; this is not a solution
530 If usually I would have simply pinned Jedi to ``<0.18``; this is not a solution
524 anymore as now pip is free to install Jedi 0.18, and downgrade IPython.
531 anymore as now pip is free to install Jedi 0.18, and downgrade IPython.
525
532
526 I'll do my best to keep the regular release, but as the 8.0-dev branch and 7.x
533 I'll do my best to keep the regular release, but as the 8.0-dev branch and 7.x
527 are starting to diverge this is becoming difficult in particular with my limited
534 are starting to diverge this is becoming difficult in particular with my limited
528 time, so if you have any cycles to spare I'll appreciate your help to respond to
535 time, so if you have any cycles to spare I'll appreciate your help to respond to
529 issues and pushing 8.0 forward.
536 issues and pushing 8.0 forward.
530
537
531 Here are thus some of the changes for IPython 7.20.
538 Here are thus some of the changes for IPython 7.20.
532
539
533 - Support for PyQt5 >= 5.11 :ghpull:`12715`
540 - Support for PyQt5 >= 5.11 :ghpull:`12715`
534 - ``%reset`` remove imports more agressively :ghpull:`12718`
541 - ``%reset`` remove imports more agressively :ghpull:`12718`
535 - fix the ``%conda`` magic :ghpull:`12739`
542 - fix the ``%conda`` magic :ghpull:`12739`
536 - compatibility with Jedi 0.18, and bump minimum Jedi version. :ghpull:`12793`
543 - compatibility with Jedi 0.18, and bump minimum Jedi version. :ghpull:`12793`
537
544
538
545
539 .. _version 719:
546 .. _version 719:
540
547
541 IPython 7.19
548 IPython 7.19
542 ============
549 ============
543
550
544 IPython 7.19 accumulative two month of works, bug fixes and improvements, there
551 IPython 7.19 accumulative two month of works, bug fixes and improvements, there
545 was exceptionally no release last month.
552 was exceptionally no release last month.
546
553
547 - Fix to restore the ability to specify more than one extension using command
554 - Fix to restore the ability to specify more than one extension using command
548 line flags when using traitlets 5.0 :ghpull:`12543`
555 line flags when using traitlets 5.0 :ghpull:`12543`
549 - Docs docs formatting that make the install commands work on zsh
556 - Docs docs formatting that make the install commands work on zsh
550 :ghpull:`12587`
557 :ghpull:`12587`
551 - Always display the last frame in tracebacks even if hidden with
558 - Always display the last frame in tracebacks even if hidden with
552 ``__tracebackhide__`` :ghpull:`12601`
559 ``__tracebackhide__`` :ghpull:`12601`
553 - Avoid an issue where a callback can be registered multiple times.
560 - Avoid an issue where a callback can be registered multiple times.
554 :ghpull:`12625`
561 :ghpull:`12625`
555 - Avoid an issue in debugger mode where frames changes could be lost.
562 - Avoid an issue in debugger mode where frames changes could be lost.
556 :ghpull:`12627`
563 :ghpull:`12627`
557
564
558 - Never hide the frames that invoke a debugger, even if marked as hidden by
565 - Never hide the frames that invoke a debugger, even if marked as hidden by
559 ``__tracebackhide__`` :ghpull:`12631`
566 ``__tracebackhide__`` :ghpull:`12631`
560 - Fix calling the debugger in a recursive manner :ghpull:`12659`
567 - Fix calling the debugger in a recursive manner :ghpull:`12659`
561
568
562
569
563 A number of code changes have landed on master and we are getting close to
570 A number of code changes have landed on master and we are getting close to
564 enough new features and codebase improvement that a 8.0 start to make sens.
571 enough new features and codebase improvement that a 8.0 start to make sens.
565 For downstream packages, please start working on migrating downstream testing
572 For downstream packages, please start working on migrating downstream testing
566 away from iptest and using pytest, as nose will not work on Python 3.10 and we
573 away from iptest and using pytest, as nose will not work on Python 3.10 and we
567 will likely start removing it as a dependency for testing.
574 will likely start removing it as a dependency for testing.
568
575
569 .. _version 718:
576 .. _version 718:
570
577
571 IPython 7.18
578 IPython 7.18
572 ============
579 ============
573
580
574 IPython 7.18 is a minor release that mostly contains bugfixes.
581 IPython 7.18 is a minor release that mostly contains bugfixes.
575
582
576 - ``CRLF`` is now handled by magics my default; solving some issues due to copy
583 - ``CRLF`` is now handled by magics my default; solving some issues due to copy
577 pasting on windows. :ghpull:`12475`
584 pasting on windows. :ghpull:`12475`
578
585
579 - Requiring pexpect ``>=4.3`` as we are Python 3.7+ only and earlier version of
586 - Requiring pexpect ``>=4.3`` as we are Python 3.7+ only and earlier version of
580 pexpect will be incompatible. :ghpull:`12510`
587 pexpect will be incompatible. :ghpull:`12510`
581
588
582 - Minimum jedi version is now 0.16. :ghpull:`12488`
589 - Minimum jedi version is now 0.16. :ghpull:`12488`
583
590
584
591
585
592
586 .. _version 717:
593 .. _version 717:
587
594
588 IPython 7.17
595 IPython 7.17
589 ============
596 ============
590
597
591 IPython 7.17 brings a couple of new improvements to API and a couple of user
598 IPython 7.17 brings a couple of new improvements to API and a couple of user
592 facing changes to make the terminal experience more user friendly.
599 facing changes to make the terminal experience more user friendly.
593
600
594 :ghpull:`12407` introduces the ability to pass extra argument to the IPython
601 :ghpull:`12407` introduces the ability to pass extra argument to the IPython
595 debugger class; this is to help a new project from ``kmaork``
602 debugger class; this is to help a new project from ``kmaork``
596 (https://github.com/kmaork/madbg) to feature a fully remote debugger.
603 (https://github.com/kmaork/madbg) to feature a fully remote debugger.
597
604
598 :ghpull:`12410` finally remove support for 3.6, while the codebase is still
605 :ghpull:`12410` finally remove support for 3.6, while the codebase is still
599 technically compatible; IPython will not install on Python 3.6.
606 technically compatible; IPython will not install on Python 3.6.
600
607
601 lots of work on the debugger and hidden frames from ``@impact27`` in
608 lots of work on the debugger and hidden frames from ``@impact27`` in
602 :ghpull:`12437`, :ghpull:`12445`, :ghpull:`12460` and in particular
609 :ghpull:`12437`, :ghpull:`12445`, :ghpull:`12460` and in particular
603 :ghpull:`12453` which make the debug magic more robust at handling spaces.
610 :ghpull:`12453` which make the debug magic more robust at handling spaces.
604
611
605 Biggest API addition is code transformation which is done before code execution;
612 Biggest API addition is code transformation which is done before code execution;
606 IPython allows a number of hooks to catch non-valid Python syntax (magic, prompt
613 IPython allows a number of hooks to catch non-valid Python syntax (magic, prompt
607 stripping...etc). Transformers are usually called many time; typically:
614 stripping...etc). Transformers are usually called many time; typically:
608
615
609 - When trying to figure out whether the code is complete and valid (should we
616 - When trying to figure out whether the code is complete and valid (should we
610 insert a new line or execute ?)
617 insert a new line or execute ?)
611 - During actual code execution pass before giving the code to Python's
618 - During actual code execution pass before giving the code to Python's
612 ``exec``.
619 ``exec``.
613
620
614 This lead to issues when transformer might have had side effects; or do external
621 This lead to issues when transformer might have had side effects; or do external
615 queries. Starting with IPython 7.17 you can expect your transformer to be called
622 queries. Starting with IPython 7.17 you can expect your transformer to be called
616 less time.
623 less time.
617
624
618 Input transformers are now called only once in the execution path of
625 Input transformers are now called only once in the execution path of
619 `InteractiveShell`, allowing to register transformer that potentially have side
626 `InteractiveShell`, allowing to register transformer that potentially have side
620 effects (note that this is not recommended). Internal methods `should_run_async`, and
627 effects (note that this is not recommended). Internal methods `should_run_async`, and
621 `run_cell_async` now take a recommended optional `transformed_cell`, and
628 `run_cell_async` now take a recommended optional `transformed_cell`, and
622 `preprocessing_exc_tuple` parameters that will become mandatory at some point in
629 `preprocessing_exc_tuple` parameters that will become mandatory at some point in
623 the future; that is to say cells need to be explicitly transformed to be valid
630 the future; that is to say cells need to be explicitly transformed to be valid
624 Python syntax ahead of trying to run them. :ghpull:`12440`;
631 Python syntax ahead of trying to run them. :ghpull:`12440`;
625
632
626 ``input_transformers`` can now also have an attribute ``has_side_effects`` set
633 ``input_transformers`` can now also have an attribute ``has_side_effects`` set
627 to `True`, when this attribute is present; this will prevent the transformers
634 to `True`, when this attribute is present; this will prevent the transformers
628 from being ran when IPython is trying to guess whether the user input is
635 from being ran when IPython is trying to guess whether the user input is
629 complete. Note that this may means you will need to explicitly execute in some
636 complete. Note that this may means you will need to explicitly execute in some
630 case where your transformations are now not ran; but will not affect users with
637 case where your transformations are now not ran; but will not affect users with
631 no custom extensions.
638 no custom extensions.
632
639
633
640
634 API Changes
641 API Changes
635 -----------
642 -----------
636
643
637 Change of API and exposed objects automatically detected using `frappuccino
644 Change of API and exposed objects automatically detected using `frappuccino
638 <https://pypi.org/project/frappuccino/>`_
645 <https://pypi.org/project/frappuccino/>`_
639
646
640
647
641 The following items are new since 7.16.0::
648 The following items are new since 7.16.0::
642
649
643 + IPython.core.interactiveshell.InteractiveShell.get_local_scope(self, stack_depth)
650 + IPython.core.interactiveshell.InteractiveShell.get_local_scope(self, stack_depth)
644
651
645 The following signatures differ since 7.16.0::
652 The following signatures differ since 7.16.0::
646
653
647 - IPython.core.interactiveshell.InteractiveShell.run_cell_async(self, raw_cell, store_history=False, silent=False, shell_futures=True)
654 - IPython.core.interactiveshell.InteractiveShell.run_cell_async(self, raw_cell, store_history=False, silent=False, shell_futures=True)
648 + IPython.core.interactiveshell.InteractiveShell.run_cell_async(self, raw_cell, store_history=False, silent=False, shell_futures=True, *, transformed_cell=None, preprocessing_exc_tuple=None)
655 + IPython.core.interactiveshell.InteractiveShell.run_cell_async(self, raw_cell, store_history=False, silent=False, shell_futures=True, *, transformed_cell=None, preprocessing_exc_tuple=None)
649
656
650 - IPython.core.interactiveshell.InteractiveShell.should_run_async(self, raw_cell)
657 - IPython.core.interactiveshell.InteractiveShell.should_run_async(self, raw_cell)
651 + IPython.core.interactiveshell.InteractiveShell.should_run_async(self, raw_cell, *, transformed_cell=None, preprocessing_exc_tuple=None)
658 + IPython.core.interactiveshell.InteractiveShell.should_run_async(self, raw_cell, *, transformed_cell=None, preprocessing_exc_tuple=None)
652
659
653 - IPython.terminal.debugger.TerminalPdb.pt_init(self)
660 - IPython.terminal.debugger.TerminalPdb.pt_init(self)
654 + IPython.terminal.debugger.TerminalPdb.pt_init(self, pt_session_options=None)
661 + IPython.terminal.debugger.TerminalPdb.pt_init(self, pt_session_options=None)
655
662
656 This method was added::
663 This method was added::
657
664
658 + IPython.core.interactiveshell.InteractiveShell.get_local_scope
665 + IPython.core.interactiveshell.InteractiveShell.get_local_scope
659
666
660 Which is now also present on subclasses::
667 Which is now also present on subclasses::
661
668
662 + IPython.terminal.embed.InteractiveShellEmbed.get_local_scope
669 + IPython.terminal.embed.InteractiveShellEmbed.get_local_scope
663 + IPython.terminal.interactiveshell.TerminalInteractiveShell.get_local_scope
670 + IPython.terminal.interactiveshell.TerminalInteractiveShell.get_local_scope
664
671
665
672
666 .. _version 716:
673 .. _version 716:
667
674
668 IPython 7.16.1, 7.16.2
675 IPython 7.16.1, 7.16.2
669 ======================
676 ======================
670
677
671 IPython 7.16.1 was release immediately after 7.16.0 to fix a conda packaging issue.
678 IPython 7.16.1 was release immediately after 7.16.0 to fix a conda packaging issue.
672 The source is identical to 7.16.0 but the file permissions in the tar are different.
679 The source is identical to 7.16.0 but the file permissions in the tar are different.
673
680
674 IPython 7.16.2 pins jedi dependency to "<=0.17.2" which should prevent some
681 IPython 7.16.2 pins jedi dependency to "<=0.17.2" which should prevent some
675 issues for users still on python 3.6. This may not be sufficient as pip may
682 issues for users still on python 3.6. This may not be sufficient as pip may
676 still allow to downgrade IPython.
683 still allow to downgrade IPython.
677
684
678 Compatibility with Jedi > 0.17.2 was not added as this would have meant bumping
685 Compatibility with Jedi > 0.17.2 was not added as this would have meant bumping
679 the minimal version to >0.16.
686 the minimal version to >0.16.
680
687
681 IPython 7.16
688 IPython 7.16
682 ============
689 ============
683
690
684
691
685 The default traceback mode will now skip frames that are marked with
692 The default traceback mode will now skip frames that are marked with
686 ``__tracebackhide__ = True`` and show how many traceback frames have been
693 ``__tracebackhide__ = True`` and show how many traceback frames have been
687 skipped. This can be toggled by using :magic:`xmode` with the ``--show`` or
694 skipped. This can be toggled by using :magic:`xmode` with the ``--show`` or
688 ``--hide`` attribute. It will have no effect on non verbose traceback modes.
695 ``--hide`` attribute. It will have no effect on non verbose traceback modes.
689
696
690 The ipython debugger also now understands ``__tracebackhide__`` as well and will
697 The ipython debugger also now understands ``__tracebackhide__`` as well and will
691 skip hidden frames when displaying. Movement up and down the stack will skip the
698 skip hidden frames when displaying. Movement up and down the stack will skip the
692 hidden frames and will show how many frames were hidden. Internal IPython frames
699 hidden frames and will show how many frames were hidden. Internal IPython frames
693 are also now hidden by default. The behavior can be changed with the
700 are also now hidden by default. The behavior can be changed with the
694 ``skip_hidden`` while in the debugger, command and accepts "yes", "no", "true"
701 ``skip_hidden`` while in the debugger, command and accepts "yes", "no", "true"
695 and "false" case insensitive parameters.
702 and "false" case insensitive parameters.
696
703
697
704
698 Misc Noticeable changes:
705 Misc Noticeable changes:
699 ------------------------
706 ------------------------
700
707
701 - Exceptions are now (re)raised when running notebooks via the :magic:`%run`, helping to catch issues in workflows and
708 - Exceptions are now (re)raised when running notebooks via the :magic:`%run`, helping to catch issues in workflows and
702 pipelines. :ghpull:`12301`
709 pipelines. :ghpull:`12301`
703 - Fix inputhook for qt 5.15.0 :ghpull:`12355`
710 - Fix inputhook for qt 5.15.0 :ghpull:`12355`
704 - Fix wx inputhook :ghpull:`12375`
711 - Fix wx inputhook :ghpull:`12375`
705 - Add handling for malformed pathext env var (Windows) :ghpull:`12367`
712 - Add handling for malformed pathext env var (Windows) :ghpull:`12367`
706 - use $SHELL in system_piped :ghpull:`12360` for uniform behavior with
713 - use $SHELL in system_piped :ghpull:`12360` for uniform behavior with
707 ipykernel.
714 ipykernel.
708
715
709 Reproducible Build
716 Reproducible Build
710 ------------------
717 ------------------
711
718
712 IPython 7.15 reproducible build did not work, so we try again this month
719 IPython 7.15 reproducible build did not work, so we try again this month
713 :ghpull:`12358`.
720 :ghpull:`12358`.
714
721
715
722
716 API Changes
723 API Changes
717 -----------
724 -----------
718
725
719 Change of API and exposed objects automatically detected using `frappuccino
726 Change of API and exposed objects automatically detected using `frappuccino
720 <https://pypi.org/project/frappuccino/>`_ (still in beta):
727 <https://pypi.org/project/frappuccino/>`_ (still in beta):
721
728
722
729
723 The following items are new and mostly related to understanding ``__tracebackhide__``::
730 The following items are new and mostly related to understanding ``__tracebackhide__``::
724
731
725 + IPython.core.debugger.Pdb.do_down(self, arg)
732 + IPython.core.debugger.Pdb.do_down(self, arg)
726 + IPython.core.debugger.Pdb.do_skip_hidden(self, arg)
733 + IPython.core.debugger.Pdb.do_skip_hidden(self, arg)
727 + IPython.core.debugger.Pdb.do_up(self, arg)
734 + IPython.core.debugger.Pdb.do_up(self, arg)
728 + IPython.core.debugger.Pdb.hidden_frames(self, stack)
735 + IPython.core.debugger.Pdb.hidden_frames(self, stack)
729 + IPython.core.debugger.Pdb.stop_here(self, frame)
736 + IPython.core.debugger.Pdb.stop_here(self, frame)
730
737
731
738
732 The following items have been removed::
739 The following items have been removed::
733
740
734 - IPython.core.debugger.Pdb.new_do_down
741 - IPython.core.debugger.Pdb.new_do_down
735 - IPython.core.debugger.Pdb.new_do_up
742 - IPython.core.debugger.Pdb.new_do_up
736
743
737 Those were implementation details.
744 Those were implementation details.
738
745
739
746
740 .. _version 715:
747 .. _version 715:
741
748
742 IPython 7.15
749 IPython 7.15
743 ============
750 ============
744
751
745 IPython 7.15 brings a number of bug fixes and user facing improvements.
752 IPython 7.15 brings a number of bug fixes and user facing improvements.
746
753
747 Misc Noticeable changes:
754 Misc Noticeable changes:
748 ------------------------
755 ------------------------
749
756
750 - Long completion name have better elision in terminal :ghpull:`12284`
757 - Long completion name have better elision in terminal :ghpull:`12284`
751 - I've started to test on Python 3.9 :ghpull:`12307` and fix some errors.
758 - I've started to test on Python 3.9 :ghpull:`12307` and fix some errors.
752 - Hi DPI scaling of figures when using qt eventloop :ghpull:`12314`
759 - Hi DPI scaling of figures when using qt eventloop :ghpull:`12314`
753 - Document the ability to have systemwide configuration for IPython.
760 - Document the ability to have systemwide configuration for IPython.
754 :ghpull:`12328`
761 :ghpull:`12328`
755 - Fix issues with input autoformatting :ghpull:`12336`
762 - Fix issues with input autoformatting :ghpull:`12336`
756 - ``IPython.core.debugger.Pdb`` is now interruptible (:ghpull:`12168`, in 7.14
763 - ``IPython.core.debugger.Pdb`` is now interruptible (:ghpull:`12168`, in 7.14
757 but forgotten in release notes)
764 but forgotten in release notes)
758 - Video HTML attributes (:ghpull:`12212`, in 7.14 but forgotten in release
765 - Video HTML attributes (:ghpull:`12212`, in 7.14 but forgotten in release
759 notes)
766 notes)
760
767
761 Reproducible Build
768 Reproducible Build
762 ------------------
769 ------------------
763
770
764 Starting with IPython 7.15, I am attempting to provide reproducible builds,
771 Starting with IPython 7.15, I am attempting to provide reproducible builds,
765 that is to say you should be able from the source tree to generate an sdist
772 that is to say you should be able from the source tree to generate an sdist
766 and wheel that are identical byte for byte with the publish version on PyPI.
773 and wheel that are identical byte for byte with the publish version on PyPI.
767
774
768 I've only tested on a couple of machines so far and the process is relatively
775 I've only tested on a couple of machines so far and the process is relatively
769 straightforward, so this mean that IPython not only have a deterministic build
776 straightforward, so this mean that IPython not only have a deterministic build
770 process, but also I have either removed, or put under control all effects of
777 process, but also I have either removed, or put under control all effects of
771 the build environments on the final artifact. I encourage you to attempt the
778 the build environments on the final artifact. I encourage you to attempt the
772 build process on your machine as documented in :ref:`core_developer_guide`
779 build process on your machine as documented in :ref:`core_developer_guide`
773 and let me know if you do not obtain an identical artifact.
780 and let me know if you do not obtain an identical artifact.
774
781
775 While reproducible builds is critical to check that the supply chain of (open
782 While reproducible builds is critical to check that the supply chain of (open
776 source) software has not been compromised, it can also help to speedup many
783 source) software has not been compromised, it can also help to speedup many
777 of the build processes in large environment (conda, apt...) by allowing
784 of the build processes in large environment (conda, apt...) by allowing
778 better caching of intermediate build steps.
785 better caching of intermediate build steps.
779
786
780 Learn more on `<https://reproducible-builds.org/>`_. `Reflections on trusting
787 Learn more on `<https://reproducible-builds.org/>`_. `Reflections on trusting
781 trust <https://dl.acm.org/doi/10.1145/358198.358210>`_ is also one of the
788 trust <https://dl.acm.org/doi/10.1145/358198.358210>`_ is also one of the
782 cornerstone and recommended reads on this subject.
789 cornerstone and recommended reads on this subject.
783
790
784 .. note::
791 .. note::
785
792
786 The build commit from which the sdist is generated is also `signed
793 The build commit from which the sdist is generated is also `signed
787 <https://en.wikipedia.org/wiki/Digital_signature>`_, so you should be able to
794 <https://en.wikipedia.org/wiki/Digital_signature>`_, so you should be able to
788 check it has not been compromised, and the git repository is a `merkle-tree
795 check it has not been compromised, and the git repository is a `merkle-tree
789 <https://en.wikipedia.org/wiki/Merkle_tree>`_, you can check the consistency
796 <https://en.wikipedia.org/wiki/Merkle_tree>`_, you can check the consistency
790 with `git-fsck <https://git-scm.com/docs/git-fsck>`_ which you likely `want
797 with `git-fsck <https://git-scm.com/docs/git-fsck>`_ which you likely `want
791 to enable by default
798 to enable by default
792 <https://gist.github.com/mbbx6spp/14b86437e794bffb4120>`_.
799 <https://gist.github.com/mbbx6spp/14b86437e794bffb4120>`_.
793
800
794 NEP29: Last version to support Python 3.6
801 NEP29: Last version to support Python 3.6
795 -----------------------------------------
802 -----------------------------------------
796
803
797 IPython 7.15 will be the Last IPython version to officially support Python
804 IPython 7.15 will be the Last IPython version to officially support Python
798 3.6, as stated by `NumPy Enhancement Proposal 29
805 3.6, as stated by `NumPy Enhancement Proposal 29
799 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_. Starting with
806 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_. Starting with
800 next minor version of IPython I may stop testing on Python 3.6 and may stop
807 next minor version of IPython I may stop testing on Python 3.6 and may stop
801 publishing release artifacts that install on Python 3.6
808 publishing release artifacts that install on Python 3.6
802
809
803 Highlighted features
810 Highlighted features
804 --------------------
811 --------------------
805
812
806 Highlighted features are not new, but seem to not be widely known, this
813 Highlighted features are not new, but seem to not be widely known, this
807 section will help you discover in more narrative form what you can do with
814 section will help you discover in more narrative form what you can do with
808 IPython.
815 IPython.
809
816
810 Increase Tab Completion Menu Height
817 Increase Tab Completion Menu Height
811 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
818 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
812
819
813 In terminal IPython it is possible to increase the hight of the tab-completion
820 In terminal IPython it is possible to increase the hight of the tab-completion
814 menu. To do so set the value of
821 menu. To do so set the value of
815 :configtrait:`TerminalInteractiveShell.space_for_menu`, this will reserve more
822 :configtrait:`TerminalInteractiveShell.space_for_menu`, this will reserve more
816 space at the bottom of the screen for various kind of menus in IPython including
823 space at the bottom of the screen for various kind of menus in IPython including
817 tab completion and searching in history.
824 tab completion and searching in history.
818
825
819 Autoformat Code in the terminal
826 Autoformat Code in the terminal
820 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
827 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
821
828
822 If you have a preferred code formatter, you can configure IPython to
829 If you have a preferred code formatter, you can configure IPython to
823 reformat your code. Set the value of
830 reformat your code. Set the value of
824 :configtrait:`TerminalInteractiveShell.autoformatter` to for example ``'black'``
831 :configtrait:`TerminalInteractiveShell.autoformatter` to for example ``'black'``
825 and IPython will auto format your code when possible.
832 and IPython will auto format your code when possible.
826
833
827
834
828 .. _version 714:
835 .. _version 714:
829
836
830 IPython 7.14
837 IPython 7.14
831 ============
838 ============
832
839
833 IPython 7.14 is a minor release that fix a couple of bugs and prepare
840 IPython 7.14 is a minor release that fix a couple of bugs and prepare
834 compatibility with new or future versions of some libraries.
841 compatibility with new or future versions of some libraries.
835
842
836 Important changes:
843 Important changes:
837 ------------------
844 ------------------
838
845
839 - Fix compatibility with Sphinx 3+ :ghpull:`12235`
846 - Fix compatibility with Sphinx 3+ :ghpull:`12235`
840 - Remove deprecated matplotlib parameter usage, compatibility with matplotlib
847 - Remove deprecated matplotlib parameter usage, compatibility with matplotlib
841 3.3+ :`122250`
848 3.3+ :`122250`
842
849
843 Misc Changes
850 Misc Changes
844 ------------
851 ------------
845
852
846 - set ``.py`` extension when editing current buffer in vi/emacs. :ghpull:`12167`
853 - set ``.py`` extension when editing current buffer in vi/emacs. :ghpull:`12167`
847 - support for unicode identifiers in ``?``/``??`` :ghpull:`12208`
854 - support for unicode identifiers in ``?``/``??`` :ghpull:`12208`
848 - add extra options to the ``Video`` Rich objects :ghpull:`12212`
855 - add extra options to the ``Video`` Rich objects :ghpull:`12212`
849 - add pretty-printing to ``SimpleNamespace`` :ghpull:`12230`
856 - add pretty-printing to ``SimpleNamespace`` :ghpull:`12230`
850
857
851 IPython.core.debugger.Pdb is now interruptible
858 IPython.core.debugger.Pdb is now interruptible
852 ----------------------------------------------
859 ----------------------------------------------
853
860
854 A ``KeyboardInterrupt`` will now interrupt IPython's extended debugger, in order to make Jupyter able to interrupt it. (:ghpull:`12168`)
861 A ``KeyboardInterrupt`` will now interrupt IPython's extended debugger, in order to make Jupyter able to interrupt it. (:ghpull:`12168`)
855
862
856 Video HTML attributes
863 Video HTML attributes
857 ---------------------
864 ---------------------
858
865
859 Add an option to `IPython.display.Video` to change the attributes of the HTML display of the video (:ghpull:`12212`)
866 Add an option to `IPython.display.Video` to change the attributes of the HTML display of the video (:ghpull:`12212`)
860
867
861
868
862 Pending deprecated imports
869 Pending deprecated imports
863 --------------------------
870 --------------------------
864
871
865 Many object present in ``IPython.core.display`` are there for internal use only,
872 Many object present in ``IPython.core.display`` are there for internal use only,
866 and should already been imported from ``IPython.display`` by users and external
873 and should already been imported from ``IPython.display`` by users and external
867 libraries. Trying to import those from ``IPython.core.display`` is still possible
874 libraries. Trying to import those from ``IPython.core.display`` is still possible
868 but will trigger a
875 but will trigger a
869 deprecation warning in later versions of IPython and will become errors in the
876 deprecation warning in later versions of IPython and will become errors in the
870 future.
877 future.
871
878
872 This will simplify compatibility with other Python kernels (like Xeus-Python),
879 This will simplify compatibility with other Python kernels (like Xeus-Python),
873 and simplify code base.
880 and simplify code base.
874
881
875
882
876
883
877
884
878 .. _version 713:
885 .. _version 713:
879
886
880 IPython 7.13
887 IPython 7.13
881 ============
888 ============
882
889
883 IPython 7.13 is the final release of the 7.x branch since master is diverging
890 IPython 7.13 is the final release of the 7.x branch since master is diverging
884 toward an 8.0. Exiting new features have already been merged in 8.0 and will
891 toward an 8.0. Exiting new features have already been merged in 8.0 and will
885 not be available on the 7.x branch. All the changes below have been backported
892 not be available on the 7.x branch. All the changes below have been backported
886 from the master branch.
893 from the master branch.
887
894
888
895
889 - Fix inability to run PDB when inside an event loop :ghpull:`12141`
896 - Fix inability to run PDB when inside an event loop :ghpull:`12141`
890 - Fix ability to interrupt some processes on windows :ghpull:`12137`
897 - Fix ability to interrupt some processes on windows :ghpull:`12137`
891 - Fix debugger shortcuts :ghpull:`12132`
898 - Fix debugger shortcuts :ghpull:`12132`
892 - improve tab completion when inside a string by removing irrelevant elements :ghpull:`12128`
899 - improve tab completion when inside a string by removing irrelevant elements :ghpull:`12128`
893 - Fix display of filename tab completion when the path is long :ghpull:`12122`
900 - Fix display of filename tab completion when the path is long :ghpull:`12122`
894 - Many removal of Python 2 specific code path :ghpull:`12110`
901 - Many removal of Python 2 specific code path :ghpull:`12110`
895 - displaying wav files do not require NumPy anymore, and is 5x to 30x faster :ghpull:`12113`
902 - displaying wav files do not require NumPy anymore, and is 5x to 30x faster :ghpull:`12113`
896
903
897 See the list of all closed issues and pull request on `github
904 See the list of all closed issues and pull request on `github
898 <https://github.com/ipython/ipython/pulls?q=is%3Aclosed+milestone%3A7.13>`_.
905 <https://github.com/ipython/ipython/pulls?q=is%3Aclosed+milestone%3A7.13>`_.
899
906
900 .. _version 712:
907 .. _version 712:
901
908
902 IPython 7.12
909 IPython 7.12
903 ============
910 ============
904
911
905 IPython 7.12 is a minor update that mostly brings code cleanup, removal of
912 IPython 7.12 is a minor update that mostly brings code cleanup, removal of
906 longtime deprecated function and a couple update to documentation cleanup as well.
913 longtime deprecated function and a couple update to documentation cleanup as well.
907
914
908 Notable changes are the following:
915 Notable changes are the following:
909
916
910 - Exit non-zero when ipython is given a file path to run that doesn't exist :ghpull:`12074`
917 - Exit non-zero when ipython is given a file path to run that doesn't exist :ghpull:`12074`
911 - Test PR on ARM64 with Travis-CI :ghpull:`12073`
918 - Test PR on ARM64 with Travis-CI :ghpull:`12073`
912 - Update CI to work with latest Pytest :ghpull:`12086`
919 - Update CI to work with latest Pytest :ghpull:`12086`
913 - Add infrastructure to run ipykernel eventloop via trio :ghpull:`12097`
920 - Add infrastructure to run ipykernel eventloop via trio :ghpull:`12097`
914 - Support git blame ignore revs :ghpull:`12091`
921 - Support git blame ignore revs :ghpull:`12091`
915 - Start multi-line ``__repr__`` s on their own line :ghpull:`12099`
922 - Start multi-line ``__repr__`` s on their own line :ghpull:`12099`
916
923
917 .. _version 7111:
924 .. _version 7111:
918
925
919 IPython 7.11.1
926 IPython 7.11.1
920 ==============
927 ==============
921
928
922 A couple of deprecated functions (no-op) have been reintroduces in py3compat as
929 A couple of deprecated functions (no-op) have been reintroduces in py3compat as
923 Cython was still relying on them, and will be removed in a couple of versions.
930 Cython was still relying on them, and will be removed in a couple of versions.
924
931
925 .. _version 711:
932 .. _version 711:
926
933
927 IPython 7.11
934 IPython 7.11
928 ============
935 ============
929
936
930 IPython 7.11 received a couple of compatibility fixes and code cleanup.
937 IPython 7.11 received a couple of compatibility fixes and code cleanup.
931
938
932 A number of function in the ``py3compat`` have been removed; a number of types
939 A number of function in the ``py3compat`` have been removed; a number of types
933 in the IPython code base are now non-ambiguous and now always ``unicode``
940 in the IPython code base are now non-ambiguous and now always ``unicode``
934 instead of ``Union[Unicode,bytes]``; many of the relevant code path have thus
941 instead of ``Union[Unicode,bytes]``; many of the relevant code path have thus
935 been simplified/cleaned and types annotation added.
942 been simplified/cleaned and types annotation added.
936
943
937 IPython support several verbosity level from exceptions. ``xmode plain`` now
944 IPython support several verbosity level from exceptions. ``xmode plain`` now
938 support chained exceptions. :ghpull:`11999`
945 support chained exceptions. :ghpull:`11999`
939
946
940 We are starting to remove ``shell=True`` in some usages of subprocess. While not directly
947 We are starting to remove ``shell=True`` in some usages of subprocess. While not directly
941 a security issue (as IPython is made to run arbitrary code anyway) it is not good
948 a security issue (as IPython is made to run arbitrary code anyway) it is not good
942 practice and we'd like to show the example. :ghissue:`12023`. This discussion
949 practice and we'd like to show the example. :ghissue:`12023`. This discussion
943 was started by ``@mschwager`` thanks to a new auditing tool they are working on
950 was started by ``@mschwager`` thanks to a new auditing tool they are working on
944 with duo-labs (`dlint <https://github.com/duo-labs/dlint>`_).
951 with duo-labs (`dlint <https://github.com/duo-labs/dlint>`_).
945
952
946 Work around some bugs in Python 3.9 tokenizer :ghpull:`12057`
953 Work around some bugs in Python 3.9 tokenizer :ghpull:`12057`
947
954
948 IPython will now print its version after a crash. :ghpull:`11986`
955 IPython will now print its version after a crash. :ghpull:`11986`
949
956
950 This is likely the last release from the 7.x series that will see new feature.
957 This is likely the last release from the 7.x series that will see new feature.
951 The master branch will soon accept large code changes and thrilling new
958 The master branch will soon accept large code changes and thrilling new
952 features; the 7.x branch will only start to accept critical bug fixes, and
959 features; the 7.x branch will only start to accept critical bug fixes, and
953 update dependencies.
960 update dependencies.
954
961
955 .. _version 7102:
962 .. _version 7102:
956
963
957 IPython 7.10.2
964 IPython 7.10.2
958 ==============
965 ==============
959
966
960 IPython 7.10.2 fix a couple of extra incompatibility between IPython, ipdb,
967 IPython 7.10.2 fix a couple of extra incompatibility between IPython, ipdb,
961 asyncio and Prompt Toolkit 3.
968 asyncio and Prompt Toolkit 3.
962
969
963 .. _version 7101:
970 .. _version 7101:
964
971
965 IPython 7.10.1
972 IPython 7.10.1
966 ==============
973 ==============
967
974
968 IPython 7.10.1 fix a couple of incompatibilities with Prompt toolkit 3 (please
975 IPython 7.10.1 fix a couple of incompatibilities with Prompt toolkit 3 (please
969 update Prompt toolkit to 3.0.2 at least), and fixes some interaction with
976 update Prompt toolkit to 3.0.2 at least), and fixes some interaction with
970 headless IPython.
977 headless IPython.
971
978
972 .. _version 7100:
979 .. _version 7100:
973
980
974 IPython 7.10.0
981 IPython 7.10.0
975 ==============
982 ==============
976
983
977 IPython 7.10 is the first double digit minor release in the last decade, and
984 IPython 7.10 is the first double digit minor release in the last decade, and
978 first since the release of IPython 1.0, previous double digit minor release was
985 first since the release of IPython 1.0, previous double digit minor release was
979 in August 2009.
986 in August 2009.
980
987
981 We've been trying to give you regular release on the last Friday of every month
988 We've been trying to give you regular release on the last Friday of every month
982 for a guaranty of rapid access to bug fixes and new features.
989 for a guaranty of rapid access to bug fixes and new features.
983
990
984 Unlike the previous first few releases that have seen only a couple of code
991 Unlike the previous first few releases that have seen only a couple of code
985 changes, 7.10 bring a number of changes, new features and bugfixes.
992 changes, 7.10 bring a number of changes, new features and bugfixes.
986
993
987 Stop Support for Python 3.5 – Adopt NEP 29
994 Stop Support for Python 3.5 – Adopt NEP 29
988 ------------------------------------------
995 ------------------------------------------
989
996
990 IPython has decided to follow the informational `NEP 29
997 IPython has decided to follow the informational `NEP 29
991 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_ which layout a clear
998 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_ which layout a clear
992 policy as to which version of (C)Python and NumPy are supported.
999 policy as to which version of (C)Python and NumPy are supported.
993
1000
994 We thus dropped support for Python 3.5, and cleaned up a number of code path
1001 We thus dropped support for Python 3.5, and cleaned up a number of code path
995 that were Python-version dependant. If you are on 3.5 or earlier pip should
1002 that were Python-version dependant. If you are on 3.5 or earlier pip should
996 automatically give you the latest compatible version of IPython so you do not
1003 automatically give you the latest compatible version of IPython so you do not
997 need to pin to a given version.
1004 need to pin to a given version.
998
1005
999 Support for Prompt Toolkit 3.0
1006 Support for Prompt Toolkit 3.0
1000 ------------------------------
1007 ------------------------------
1001
1008
1002 Prompt Toolkit 3.0 was release a week before IPython 7.10 and introduces a few
1009 Prompt Toolkit 3.0 was release a week before IPython 7.10 and introduces a few
1003 breaking changes. We believe IPython 7.10 should be compatible with both Prompt
1010 breaking changes. We believe IPython 7.10 should be compatible with both Prompt
1004 Toolkit 2.x and 3.x, though it has not been extensively tested with 3.x so
1011 Toolkit 2.x and 3.x, though it has not been extensively tested with 3.x so
1005 please report any issues.
1012 please report any issues.
1006
1013
1007
1014
1008 Prompt Rendering Performance improvements
1015 Prompt Rendering Performance improvements
1009 -----------------------------------------
1016 -----------------------------------------
1010
1017
1011 Pull Request :ghpull:`11933` introduced an optimisation in the prompt rendering
1018 Pull Request :ghpull:`11933` introduced an optimisation in the prompt rendering
1012 logic that should decrease the resource usage of IPython when using the
1019 logic that should decrease the resource usage of IPython when using the
1013 _default_ configuration but could potentially introduce a regression of
1020 _default_ configuration but could potentially introduce a regression of
1014 functionalities if you are using a custom prompt.
1021 functionalities if you are using a custom prompt.
1015
1022
1016 We know assume if you haven't changed the default keybindings that the prompt
1023 We know assume if you haven't changed the default keybindings that the prompt
1017 **will not change** during the duration of your input – which is for example
1024 **will not change** during the duration of your input – which is for example
1018 not true when using vi insert mode that switches between `[ins]` and `[nor]`
1025 not true when using vi insert mode that switches between `[ins]` and `[nor]`
1019 for the current mode.
1026 for the current mode.
1020
1027
1021 If you are experiencing any issue let us know.
1028 If you are experiencing any issue let us know.
1022
1029
1023 Code autoformatting
1030 Code autoformatting
1024 -------------------
1031 -------------------
1025
1032
1026 The IPython terminal can now auto format your code just before entering a new
1033 The IPython terminal can now auto format your code just before entering a new
1027 line or executing a command. To do so use the
1034 line or executing a command. To do so use the
1028 ``--TerminalInteractiveShell.autoformatter`` option and set it to ``'black'``;
1035 ``--TerminalInteractiveShell.autoformatter`` option and set it to ``'black'``;
1029 if black is installed IPython will use black to format your code when possible.
1036 if black is installed IPython will use black to format your code when possible.
1030
1037
1031 IPython cannot always properly format your code; in particular it will
1038 IPython cannot always properly format your code; in particular it will
1032 auto formatting with *black* will only work if:
1039 auto formatting with *black* will only work if:
1033
1040
1034 - Your code does not contains magics or special python syntax.
1041 - Your code does not contains magics or special python syntax.
1035
1042
1036 - There is no code after your cursor.
1043 - There is no code after your cursor.
1037
1044
1038 The Black API is also still in motion; so this may not work with all versions of
1045 The Black API is also still in motion; so this may not work with all versions of
1039 black.
1046 black.
1040
1047
1041 It should be possible to register custom formatter, though the API is till in
1048 It should be possible to register custom formatter, though the API is till in
1042 flux.
1049 flux.
1043
1050
1044 Arbitrary Mimetypes Handing in Terminal (Aka inline images in terminal)
1051 Arbitrary Mimetypes Handing in Terminal (Aka inline images in terminal)
1045 -----------------------------------------------------------------------
1052 -----------------------------------------------------------------------
1046
1053
1047 When using IPython terminal it is now possible to register function to handle
1054 When using IPython terminal it is now possible to register function to handle
1048 arbitrary mimetypes. While rendering non-text based representation was possible in
1055 arbitrary mimetypes. While rendering non-text based representation was possible in
1049 many jupyter frontend; it was not possible in terminal IPython, as usually
1056 many jupyter frontend; it was not possible in terminal IPython, as usually
1050 terminal are limited to displaying text. As many terminal these days provide
1057 terminal are limited to displaying text. As many terminal these days provide
1051 escape sequences to display non-text; bringing this loved feature to IPython CLI
1058 escape sequences to display non-text; bringing this loved feature to IPython CLI
1052 made a lot of sens. This functionality will not only allow inline images; but
1059 made a lot of sens. This functionality will not only allow inline images; but
1053 allow opening of external program; for example ``mplayer`` to "display" sound
1060 allow opening of external program; for example ``mplayer`` to "display" sound
1054 files.
1061 files.
1055
1062
1056 So far only the hooks necessary for this are in place, but no default mime
1063 So far only the hooks necessary for this are in place, but no default mime
1057 renderers added; so inline images will only be available via extensions. We will
1064 renderers added; so inline images will only be available via extensions. We will
1058 progressively enable these features by default in the next few releases, and
1065 progressively enable these features by default in the next few releases, and
1059 contribution is welcomed.
1066 contribution is welcomed.
1060
1067
1061 We welcome any feedback on the API. See :ref:`shell_mimerenderer` for more
1068 We welcome any feedback on the API. See :ref:`shell_mimerenderer` for more
1062 informations.
1069 informations.
1063
1070
1064 This is originally based on work form in :ghpull:`10610` from @stephanh42
1071 This is originally based on work form in :ghpull:`10610` from @stephanh42
1065 started over two years ago, and still a lot need to be done.
1072 started over two years ago, and still a lot need to be done.
1066
1073
1067 MISC
1074 MISC
1068 ----
1075 ----
1069
1076
1070 - Completions can define their own ordering :ghpull:`11855`
1077 - Completions can define their own ordering :ghpull:`11855`
1071 - Enable Plotting in the same cell than the one that import matplotlib
1078 - Enable Plotting in the same cell than the one that import matplotlib
1072 :ghpull:`11916`
1079 :ghpull:`11916`
1073 - Allow to store and restore multiple variables at once :ghpull:`11930`
1080 - Allow to store and restore multiple variables at once :ghpull:`11930`
1074
1081
1075 You can see `all pull-requests <https://github.com/ipython/ipython/pulls?q=is%3Apr+milestone%3A7.10+is%3Aclosed>`_ for this release.
1082 You can see `all pull-requests <https://github.com/ipython/ipython/pulls?q=is%3Apr+milestone%3A7.10+is%3Aclosed>`_ for this release.
1076
1083
1077 API Changes
1084 API Changes
1078 -----------
1085 -----------
1079
1086
1080 Change of API and exposed objects automatically detected using `frappuccino <https://pypi.org/project/frappuccino/>`_ (still in beta):
1087 Change of API and exposed objects automatically detected using `frappuccino <https://pypi.org/project/frappuccino/>`_ (still in beta):
1081
1088
1082 The following items are new in IPython 7.10::
1089 The following items are new in IPython 7.10::
1083
1090
1084 + IPython.terminal.shortcuts.reformat_text_before_cursor(buffer, document, shell)
1091 + IPython.terminal.shortcuts.reformat_text_before_cursor(buffer, document, shell)
1085 + IPython.terminal.interactiveshell.PTK3
1092 + IPython.terminal.interactiveshell.PTK3
1086 + IPython.terminal.interactiveshell.black_reformat_handler(text_before_cursor)
1093 + IPython.terminal.interactiveshell.black_reformat_handler(text_before_cursor)
1087 + IPython.terminal.prompts.RichPromptDisplayHook.write_format_data(self, format_dict, md_dict='None')
1094 + IPython.terminal.prompts.RichPromptDisplayHook.write_format_data(self, format_dict, md_dict='None')
1088
1095
1089 The following items have been removed in 7.10::
1096 The following items have been removed in 7.10::
1090
1097
1091 - IPython.lib.pretty.DICT_IS_ORDERED
1098 - IPython.lib.pretty.DICT_IS_ORDERED
1092
1099
1093 The following signatures differ between versions::
1100 The following signatures differ between versions::
1094
1101
1095 - IPython.extensions.storemagic.restore_aliases(ip)
1102 - IPython.extensions.storemagic.restore_aliases(ip)
1096 + IPython.extensions.storemagic.restore_aliases(ip, alias='None')
1103 + IPython.extensions.storemagic.restore_aliases(ip, alias='None')
1097
1104
1098 Special Thanks
1105 Special Thanks
1099 --------------
1106 --------------
1100
1107
1101 - @stephanh42 who started the work on inline images in terminal 2 years ago
1108 - @stephanh42 who started the work on inline images in terminal 2 years ago
1102 - @augustogoulart who spent a lot of time triaging issues and responding to
1109 - @augustogoulart who spent a lot of time triaging issues and responding to
1103 users.
1110 users.
1104 - @con-f-use who is my (@Carreau) first sponsor on GitHub, as a reminder if you
1111 - @con-f-use who is my (@Carreau) first sponsor on GitHub, as a reminder if you
1105 like IPython, Jupyter and many other library of the SciPy stack you can
1112 like IPython, Jupyter and many other library of the SciPy stack you can
1106 donate to numfocus.org non profit
1113 donate to numfocus.org non profit
1107
1114
1108 .. _version 790:
1115 .. _version 790:
1109
1116
1110 IPython 7.9.0
1117 IPython 7.9.0
1111 =============
1118 =============
1112
1119
1113 IPython 7.9 is a small release with a couple of improvement and bug fixes.
1120 IPython 7.9 is a small release with a couple of improvement and bug fixes.
1114
1121
1115 - Xterm terminal title should be restored on exit :ghpull:`11910`
1122 - Xterm terminal title should be restored on exit :ghpull:`11910`
1116 - special variables ``_``,``__``, ``___`` are not set anymore when cache size
1123 - special variables ``_``,``__``, ``___`` are not set anymore when cache size
1117 is 0 or less. :ghpull:`11877`
1124 is 0 or less. :ghpull:`11877`
1118 - Autoreload should have regained some speed by using a new heuristic logic to
1125 - Autoreload should have regained some speed by using a new heuristic logic to
1119 find all objects needing reload. This should avoid large objects traversal
1126 find all objects needing reload. This should avoid large objects traversal
1120 like pandas dataframes. :ghpull:`11876`
1127 like pandas dataframes. :ghpull:`11876`
1121 - Get ready for Python 4. :ghpull:`11874`
1128 - Get ready for Python 4. :ghpull:`11874`
1122 - `%env` Magic now has heuristic to hide potentially sensitive values :ghpull:`11896`
1129 - `%env` Magic now has heuristic to hide potentially sensitive values :ghpull:`11896`
1123
1130
1124 This is a small release despite a number of Pull Request Pending that need to
1131 This is a small release despite a number of Pull Request Pending that need to
1125 be reviewed/worked on. Many of the core developers have been busy outside of
1132 be reviewed/worked on. Many of the core developers have been busy outside of
1126 IPython/Jupyter and we thanks all contributor for their patience; we'll work on
1133 IPython/Jupyter and we thanks all contributor for their patience; we'll work on
1127 these as soon as we have time.
1134 these as soon as we have time.
1128
1135
1129
1136
1130 .. _version780:
1137 .. _version780:
1131
1138
1132 IPython 7.8.0
1139 IPython 7.8.0
1133 =============
1140 =============
1134
1141
1135 IPython 7.8.0 contain a few bugfix and 2 new APIs:
1142 IPython 7.8.0 contain a few bugfix and 2 new APIs:
1136
1143
1137 - Enable changing the font color for LaTeX rendering :ghpull:`11840`
1144 - Enable changing the font color for LaTeX rendering :ghpull:`11840`
1138 - and Re-Expose some PDB API (see below)
1145 - and Re-Expose some PDB API (see below)
1139
1146
1140 Expose Pdb API
1147 Expose Pdb API
1141 --------------
1148 --------------
1142
1149
1143 Expose the built-in ``pdb.Pdb`` API. ``Pdb`` constructor arguments are generically
1150 Expose the built-in ``pdb.Pdb`` API. ``Pdb`` constructor arguments are generically
1144 exposed, regardless of python version.
1151 exposed, regardless of python version.
1145 Newly exposed arguments:
1152 Newly exposed arguments:
1146
1153
1147 - ``skip`` - Python 3.1+
1154 - ``skip`` - Python 3.1+
1148 - ``nosiginnt`` - Python 3.2+
1155 - ``nosiginnt`` - Python 3.2+
1149 - ``readrc`` - Python 3.6+
1156 - ``readrc`` - Python 3.6+
1150
1157
1151 Try it out::
1158 Try it out::
1152
1159
1153 from IPython.terminal.debugger import TerminalPdb
1160 from IPython.terminal.debugger import TerminalPdb
1154 pdb = TerminalPdb(skip=["skipthismodule"])
1161 pdb = TerminalPdb(skip=["skipthismodule"])
1155
1162
1156
1163
1157 See :ghpull:`11840`
1164 See :ghpull:`11840`
1158
1165
1159 .. _version770:
1166 .. _version770:
1160
1167
1161 IPython 7.7.0
1168 IPython 7.7.0
1162 =============
1169 =============
1163
1170
1164 IPython 7.7.0 contain multiple bug fixes and documentation updates; Here are a
1171 IPython 7.7.0 contain multiple bug fixes and documentation updates; Here are a
1165 few of the outstanding issue fixed:
1172 few of the outstanding issue fixed:
1166
1173
1167 - Fix a bug introduced in 7.6 where the ``%matplotlib`` magic would fail on
1174 - Fix a bug introduced in 7.6 where the ``%matplotlib`` magic would fail on
1168 previously acceptable arguments :ghpull:`11814`.
1175 previously acceptable arguments :ghpull:`11814`.
1169 - Fix the manage location on freebsd :ghpull:`11808`.
1176 - Fix the manage location on freebsd :ghpull:`11808`.
1170 - Fix error message about aliases after ``%reset`` call in ipykernel
1177 - Fix error message about aliases after ``%reset`` call in ipykernel
1171 :ghpull:`11806`
1178 :ghpull:`11806`
1172 - Fix Duplication completions in emacs :ghpull:`11803`
1179 - Fix Duplication completions in emacs :ghpull:`11803`
1173
1180
1174 We are planning to adopt `NEP29 <https://github.com/numpy/numpy/pull/14086>`_
1181 We are planning to adopt `NEP29 <https://github.com/numpy/numpy/pull/14086>`_
1175 (still currently in draft) which may make this minor version of IPython the
1182 (still currently in draft) which may make this minor version of IPython the
1176 last one to support Python 3.5 and will make the code base more aggressive
1183 last one to support Python 3.5 and will make the code base more aggressive
1177 toward removing compatibility with older versions of Python.
1184 toward removing compatibility with older versions of Python.
1178
1185
1179 GitHub now support to give only "Triage" permissions to users; if you'd like to
1186 GitHub now support to give only "Triage" permissions to users; if you'd like to
1180 help close stale issues and labels issues please reach to us with your GitHub
1187 help close stale issues and labels issues please reach to us with your GitHub
1181 Username and we'll add you to the triage team. It is a great way to start
1188 Username and we'll add you to the triage team. It is a great way to start
1182 contributing and a path toward getting commit rights.
1189 contributing and a path toward getting commit rights.
1183
1190
1184 .. _version761:
1191 .. _version761:
1185
1192
1186 IPython 7.6.1
1193 IPython 7.6.1
1187 =============
1194 =============
1188
1195
1189 IPython 7.6.1 contain a critical bugfix in the ``%timeit`` magic, which would
1196 IPython 7.6.1 contain a critical bugfix in the ``%timeit`` magic, which would
1190 crash on some inputs as a side effect of :ghpull:`11716`. See :ghpull:`11812`
1197 crash on some inputs as a side effect of :ghpull:`11716`. See :ghpull:`11812`
1191
1198
1192
1199
1193 .. _whatsnew760:
1200 .. _whatsnew760:
1194
1201
1195 IPython 7.6.0
1202 IPython 7.6.0
1196 =============
1203 =============
1197
1204
1198 IPython 7.6.0 contains a couple of bug fixes and number of small features
1205 IPython 7.6.0 contains a couple of bug fixes and number of small features
1199 additions as well as some compatibility with the current development version of
1206 additions as well as some compatibility with the current development version of
1200 Python 3.8.
1207 Python 3.8.
1201
1208
1202 - Add a ``-l`` option to :magic:`psearch` to list the available search
1209 - Add a ``-l`` option to :magic:`psearch` to list the available search
1203 types. :ghpull:`11672`
1210 types. :ghpull:`11672`
1204 - Support ``PathLike`` for ``DisplayObject`` and ``Image``. :ghpull:`11764`
1211 - Support ``PathLike`` for ``DisplayObject`` and ``Image``. :ghpull:`11764`
1205 - Configurability of timeout in the test suite for slow platforms.
1212 - Configurability of timeout in the test suite for slow platforms.
1206 :ghpull:`11756`
1213 :ghpull:`11756`
1207 - Accept any casing for matplotlib backend. :ghpull:`121748`
1214 - Accept any casing for matplotlib backend. :ghpull:`121748`
1208 - Properly skip test that requires numpy to be installed :ghpull:`11723`
1215 - Properly skip test that requires numpy to be installed :ghpull:`11723`
1209 - More support for Python 3.8 and positional only arguments (pep570)
1216 - More support for Python 3.8 and positional only arguments (pep570)
1210 :ghpull:`11720`
1217 :ghpull:`11720`
1211 - Unicode names for the completion are loaded lazily on first use which
1218 - Unicode names for the completion are loaded lazily on first use which
1212 should decrease startup time. :ghpull:`11693`
1219 should decrease startup time. :ghpull:`11693`
1213 - Autoreload now update the types of reloaded objects; this for example allow
1220 - Autoreload now update the types of reloaded objects; this for example allow
1214 pickling of reloaded objects. :ghpull:`11644`
1221 pickling of reloaded objects. :ghpull:`11644`
1215 - Fix a bug where ``%%time`` magic would suppress cell output. :ghpull:`11716`
1222 - Fix a bug where ``%%time`` magic would suppress cell output. :ghpull:`11716`
1216
1223
1217
1224
1218 Prepare migration to pytest (instead of nose) for testing
1225 Prepare migration to pytest (instead of nose) for testing
1219 ---------------------------------------------------------
1226 ---------------------------------------------------------
1220
1227
1221 Most of the work between 7.5 and 7.6 was to prepare the migration from our
1228 Most of the work between 7.5 and 7.6 was to prepare the migration from our
1222 testing framework to pytest. Most of the test suite should now work by simply
1229 testing framework to pytest. Most of the test suite should now work by simply
1223 issuing ``pytest`` from the root of the repository.
1230 issuing ``pytest`` from the root of the repository.
1224
1231
1225 The migration to pytest is just at its beginning. Many of our test still rely
1232 The migration to pytest is just at its beginning. Many of our test still rely
1226 on IPython-specific plugins for nose using pytest (doctest using IPython syntax
1233 on IPython-specific plugins for nose using pytest (doctest using IPython syntax
1227 is one example of this where test appear as "passing", while no code has been
1234 is one example of this where test appear as "passing", while no code has been
1228 ran). Many test also need to be updated like ``yield-test`` to be properly
1235 ran). Many test also need to be updated like ``yield-test`` to be properly
1229 parametrized tests.
1236 parametrized tests.
1230
1237
1231 Migration to pytest allowed me to discover a number of issues in our test
1238 Migration to pytest allowed me to discover a number of issues in our test
1232 suite; which was hiding a number of subtle issues – or not actually running
1239 suite; which was hiding a number of subtle issues – or not actually running
1233 some of the tests in our test suite – I have thus corrected many of those; like
1240 some of the tests in our test suite – I have thus corrected many of those; like
1234 improperly closed resources; or used of deprecated features. I also made use of
1241 improperly closed resources; or used of deprecated features. I also made use of
1235 the ``pytest --durations=...`` to find some of our slowest test and speed them
1242 the ``pytest --durations=...`` to find some of our slowest test and speed them
1236 up (our test suite can now be up to 10% faster). Pytest as also a variety of
1243 up (our test suite can now be up to 10% faster). Pytest as also a variety of
1237 plugins and flags which will make the code quality of IPython and the testing
1244 plugins and flags which will make the code quality of IPython and the testing
1238 experience better.
1245 experience better.
1239
1246
1240 Misc
1247 Misc
1241 ----
1248 ----
1242
1249
1243 We skipped the release of 7.6 at the end of May, but will attempt to get back
1250 We skipped the release of 7.6 at the end of May, but will attempt to get back
1244 on schedule. We are starting to think about making introducing backward
1251 on schedule. We are starting to think about making introducing backward
1245 incompatible change and start the 8.0 series.
1252 incompatible change and start the 8.0 series.
1246
1253
1247 Special Thanks to Gabriel (@gpotter2 on GitHub), who among other took care many
1254 Special Thanks to Gabriel (@gpotter2 on GitHub), who among other took care many
1248 of the remaining task for 7.4 and 7.5, like updating the website.
1255 of the remaining task for 7.4 and 7.5, like updating the website.
1249
1256
1250 .. _whatsnew750:
1257 .. _whatsnew750:
1251
1258
1252 IPython 7.5.0
1259 IPython 7.5.0
1253 =============
1260 =============
1254
1261
1255 IPython 7.5.0 consist mostly of bug-fixes, and documentation updates, with one
1262 IPython 7.5.0 consist mostly of bug-fixes, and documentation updates, with one
1256 minor new feature. The `Audio` display element can now be assigned an element
1263 minor new feature. The `Audio` display element can now be assigned an element
1257 id when displayed in browser. See :ghpull:`11670`
1264 id when displayed in browser. See :ghpull:`11670`
1258
1265
1259 The major outstanding bug fix correct a change of behavior that was introduce
1266 The major outstanding bug fix correct a change of behavior that was introduce
1260 in 7.4.0 where some cell magics would not be able to access or modify global
1267 in 7.4.0 where some cell magics would not be able to access or modify global
1261 scope when using the ``@needs_local_scope`` decorator. This was typically
1268 scope when using the ``@needs_local_scope`` decorator. This was typically
1262 encountered with the ``%%time`` and ``%%timeit`` magics. See :ghissue:`11659`
1269 encountered with the ``%%time`` and ``%%timeit`` magics. See :ghissue:`11659`
1263 and :ghpull:`11698`.
1270 and :ghpull:`11698`.
1264
1271
1265 .. _whatsnew740:
1272 .. _whatsnew740:
1266
1273
1267 IPython 7.4.0
1274 IPython 7.4.0
1268 =============
1275 =============
1269
1276
1270 Unicode name completions
1277 Unicode name completions
1271 ------------------------
1278 ------------------------
1272
1279
1273 Previously, we provided completion for a unicode name with its relative symbol.
1280 Previously, we provided completion for a unicode name with its relative symbol.
1274 With this, now IPython provides complete suggestions to unicode name symbols.
1281 With this, now IPython provides complete suggestions to unicode name symbols.
1275
1282
1276 As on the PR, if user types ``\LAT<tab>``, IPython provides a list of
1283 As on the PR, if user types ``\LAT<tab>``, IPython provides a list of
1277 possible completions. In this case, it would be something like::
1284 possible completions. In this case, it would be something like::
1278
1285
1279 'LATIN CAPITAL LETTER A',
1286 'LATIN CAPITAL LETTER A',
1280 'LATIN CAPITAL LETTER B',
1287 'LATIN CAPITAL LETTER B',
1281 'LATIN CAPITAL LETTER C',
1288 'LATIN CAPITAL LETTER C',
1282 'LATIN CAPITAL LETTER D',
1289 'LATIN CAPITAL LETTER D',
1283 ....
1290 ....
1284
1291
1285 This help to type unicode character that do not have short latex aliases, and
1292 This help to type unicode character that do not have short latex aliases, and
1286 have long unicode names. for example ``Ν°``, ``\GREEK CAPITAL LETTER HETA``.
1293 have long unicode names. for example ``Ν°``, ``\GREEK CAPITAL LETTER HETA``.
1287
1294
1288 This feature was contributed by Luciana Marques :ghpull:`11583`.
1295 This feature was contributed by Luciana Marques :ghpull:`11583`.
1289
1296
1290 Make audio normalization optional
1297 Make audio normalization optional
1291 ---------------------------------
1298 ---------------------------------
1292
1299
1293 Added 'normalize' argument to `IPython.display.Audio`. This argument applies
1300 Added 'normalize' argument to `IPython.display.Audio`. This argument applies
1294 when audio data is given as an array of samples. The default of `normalize=True`
1301 when audio data is given as an array of samples. The default of `normalize=True`
1295 preserves prior behavior of normalizing the audio to the maximum possible range.
1302 preserves prior behavior of normalizing the audio to the maximum possible range.
1296 Setting to `False` disables normalization.
1303 Setting to `False` disables normalization.
1297
1304
1298
1305
1299 Miscellaneous
1306 Miscellaneous
1300 -------------
1307 -------------
1301
1308
1302 - Fix improper acceptation of ``return`` outside of functions. :ghpull:`11641`.
1309 - Fix improper acceptation of ``return`` outside of functions. :ghpull:`11641`.
1303 - Fixed PyQt 5.11 backwards incompatibility causing sip import failure.
1310 - Fixed PyQt 5.11 backwards incompatibility causing sip import failure.
1304 :ghpull:`11613`.
1311 :ghpull:`11613`.
1305 - Fix Bug where ``type?`` would crash IPython. :ghpull:`1608`.
1312 - Fix Bug where ``type?`` would crash IPython. :ghpull:`1608`.
1306 - Allow to apply ``@needs_local_scope`` to cell magics for convenience.
1313 - Allow to apply ``@needs_local_scope`` to cell magics for convenience.
1307 :ghpull:`11542`.
1314 :ghpull:`11542`.
1308
1315
1309 .. _whatsnew730:
1316 .. _whatsnew730:
1310
1317
1311 IPython 7.3.0
1318 IPython 7.3.0
1312 =============
1319 =============
1313
1320
1314 .. _whatsnew720:
1321 .. _whatsnew720:
1315
1322
1316 IPython 7.3.0 bring several bug fixes and small improvements that you will
1323 IPython 7.3.0 bring several bug fixes and small improvements that you will
1317 described bellow.
1324 described bellow.
1318
1325
1319 The biggest change to this release is the implementation of the ``%conda`` and
1326 The biggest change to this release is the implementation of the ``%conda`` and
1320 ``%pip`` magics, that will attempt to install packages in the **current
1327 ``%pip`` magics, that will attempt to install packages in the **current
1321 environment**. You may still need to restart your interpreter or kernel for the
1328 environment**. You may still need to restart your interpreter or kernel for the
1322 change to be taken into account, but it should simplify installation of packages
1329 change to be taken into account, but it should simplify installation of packages
1323 into remote environment. Installing using pip/conda from the command line is
1330 into remote environment. Installing using pip/conda from the command line is
1324 still the prefer method.
1331 still the prefer method.
1325
1332
1326 The ``%pip`` magic was already present, but was only printing a warning; now it
1333 The ``%pip`` magic was already present, but was only printing a warning; now it
1327 will actually forward commands to pip.
1334 will actually forward commands to pip.
1328
1335
1329 Misc bug fixes and improvements:
1336 Misc bug fixes and improvements:
1330
1337
1331 - Compatibility with Python 3.8.
1338 - Compatibility with Python 3.8.
1332 - Do not expand shell variable in execution magics, and added the
1339 - Do not expand shell variable in execution magics, and added the
1333 ``no_var_expand`` decorator for magic requiring a similar functionality
1340 ``no_var_expand`` decorator for magic requiring a similar functionality
1334 :ghpull:`11516`
1341 :ghpull:`11516`
1335 - Add ``%pip`` and ``%conda`` magic :ghpull:`11524`
1342 - Add ``%pip`` and ``%conda`` magic :ghpull:`11524`
1336 - Re-initialize posix aliases after a ``%reset`` :ghpull:`11528`
1343 - Re-initialize posix aliases after a ``%reset`` :ghpull:`11528`
1337 - Allow the IPython command line to run ``*.ipynb`` files :ghpull:`11529`
1344 - Allow the IPython command line to run ``*.ipynb`` files :ghpull:`11529`
1338
1345
1339 IPython 7.2.0
1346 IPython 7.2.0
1340 =============
1347 =============
1341
1348
1342 IPython 7.2.0 brings minor bugfixes, improvements, and new configuration options:
1349 IPython 7.2.0 brings minor bugfixes, improvements, and new configuration options:
1343
1350
1344 - Fix a bug preventing PySide2 GUI integration from working :ghpull:`11464`
1351 - Fix a bug preventing PySide2 GUI integration from working :ghpull:`11464`
1345 - Run CI on Mac OS ! :ghpull:`11471`
1352 - Run CI on Mac OS ! :ghpull:`11471`
1346 - Fix IPython "Demo" mode. :ghpull:`11498`
1353 - Fix IPython "Demo" mode. :ghpull:`11498`
1347 - Fix ``%run`` magic with path in name :ghpull:`11499`
1354 - Fix ``%run`` magic with path in name :ghpull:`11499`
1348 - Fix: add CWD to sys.path *after* stdlib :ghpull:`11502`
1355 - Fix: add CWD to sys.path *after* stdlib :ghpull:`11502`
1349 - Better rendering of signatures, especially long ones. :ghpull:`11505`
1356 - Better rendering of signatures, especially long ones. :ghpull:`11505`
1350 - Re-enable jedi by default if it's installed :ghpull:`11506`
1357 - Re-enable jedi by default if it's installed :ghpull:`11506`
1351 - Add New ``minimal`` exception reporting mode (useful for educational purpose). See :ghpull:`11509`
1358 - Add New ``minimal`` exception reporting mode (useful for educational purpose). See :ghpull:`11509`
1352
1359
1353
1360
1354 Added ability to show subclasses when using pinfo and other utilities
1361 Added ability to show subclasses when using pinfo and other utilities
1355 ---------------------------------------------------------------------
1362 ---------------------------------------------------------------------
1356
1363
1357 When using ``?``/``??`` on a class, IPython will now list the first 10 subclasses.
1364 When using ``?``/``??`` on a class, IPython will now list the first 10 subclasses.
1358
1365
1359 Special Thanks to Chris Mentzel of the Moore Foundation for this feature. Chris
1366 Special Thanks to Chris Mentzel of the Moore Foundation for this feature. Chris
1360 is one of the people who played a critical role in IPython/Jupyter getting
1367 is one of the people who played a critical role in IPython/Jupyter getting
1361 funding.
1368 funding.
1362
1369
1363 We are grateful for all the help Chris has given us over the years,
1370 We are grateful for all the help Chris has given us over the years,
1364 and we're now proud to have code contributed by Chris in IPython.
1371 and we're now proud to have code contributed by Chris in IPython.
1365
1372
1366 OSMagics.cd_force_quiet configuration option
1373 OSMagics.cd_force_quiet configuration option
1367 --------------------------------------------
1374 --------------------------------------------
1368
1375
1369 You can set this option to force the %cd magic to behave as if ``-q`` was passed:
1376 You can set this option to force the %cd magic to behave as if ``-q`` was passed:
1370 ::
1377 ::
1371
1378
1372 In [1]: cd /
1379 In [1]: cd /
1373 /
1380 /
1374
1381
1375 In [2]: %config OSMagics.cd_force_quiet = True
1382 In [2]: %config OSMagics.cd_force_quiet = True
1376
1383
1377 In [3]: cd /tmp
1384 In [3]: cd /tmp
1378
1385
1379 In [4]:
1386 In [4]:
1380
1387
1381 See :ghpull:`11491`
1388 See :ghpull:`11491`
1382
1389
1383 In vi editing mode, whether the prompt includes the current vi mode can now be configured
1390 In vi editing mode, whether the prompt includes the current vi mode can now be configured
1384 -----------------------------------------------------------------------------------------
1391 -----------------------------------------------------------------------------------------
1385
1392
1386 Set the ``TerminalInteractiveShell.prompt_includes_vi_mode`` to a boolean value
1393 Set the ``TerminalInteractiveShell.prompt_includes_vi_mode`` to a boolean value
1387 (default: True) to control this feature. See :ghpull:`11492`
1394 (default: True) to control this feature. See :ghpull:`11492`
1388
1395
1389 .. _whatsnew710:
1396 .. _whatsnew710:
1390
1397
1391 IPython 7.1.0
1398 IPython 7.1.0
1392 =============
1399 =============
1393
1400
1394 IPython 7.1.0 is the first minor release after 7.0.0 and mostly brings fixes to
1401 IPython 7.1.0 is the first minor release after 7.0.0 and mostly brings fixes to
1395 new features, internal refactoring, and fixes for regressions that happened during the 6.x->7.x
1402 new features, internal refactoring, and fixes for regressions that happened during the 6.x->7.x
1396 transition. It also brings **Compatibility with Python 3.7.1**, as we're
1403 transition. It also brings **Compatibility with Python 3.7.1**, as we're
1397 unwillingly relying on a bug in CPython.
1404 unwillingly relying on a bug in CPython.
1398
1405
1399 New Core Dev:
1406 New Core Dev:
1400
1407
1401 - We welcome Jonathan Slenders to the commiters. Jonathan has done a fantastic
1408 - We welcome Jonathan Slenders to the commiters. Jonathan has done a fantastic
1402 work on prompt_toolkit, and we'd like to recognise his impact by giving him
1409 work on prompt_toolkit, and we'd like to recognise his impact by giving him
1403 commit rights. :ghissue:`11397`
1410 commit rights. :ghissue:`11397`
1404
1411
1405 Notable Changes
1412 Notable Changes
1406
1413
1407 - Major update of "latex to unicode" tab completion map (see below)
1414 - Major update of "latex to unicode" tab completion map (see below)
1408
1415
1409 Notable New Features:
1416 Notable New Features:
1410
1417
1411 - Restore functionality and documentation of the **sphinx directive**, which
1418 - Restore functionality and documentation of the **sphinx directive**, which
1412 is now stricter (fail on error by daefault), has new configuration options,
1419 is now stricter (fail on error by daefault), has new configuration options,
1413 has a brand new documentation page :ref:`ipython_directive` (which needs
1420 has a brand new documentation page :ref:`ipython_directive` (which needs
1414 some cleanup). It is also now *tested* so we hope to have less regressions.
1421 some cleanup). It is also now *tested* so we hope to have less regressions.
1415 :ghpull:`11402`
1422 :ghpull:`11402`
1416
1423
1417 - ``IPython.display.Video`` now supports ``width`` and ``height`` arguments,
1424 - ``IPython.display.Video`` now supports ``width`` and ``height`` arguments,
1418 allowing a custom width and height to be set instead of using the video's
1425 allowing a custom width and height to be set instead of using the video's
1419 width and height. :ghpull:`11353`
1426 width and height. :ghpull:`11353`
1420
1427
1421 - Warn when using ``HTML('<iframe>')`` instead of ``IFrame`` :ghpull:`11350`
1428 - Warn when using ``HTML('<iframe>')`` instead of ``IFrame`` :ghpull:`11350`
1422
1429
1423 - Allow Dynamic switching of editing mode between vi/emacs and show
1430 - Allow Dynamic switching of editing mode between vi/emacs and show
1424 normal/input mode in prompt when using vi. :ghpull:`11390`. Use ``%config
1431 normal/input mode in prompt when using vi. :ghpull:`11390`. Use ``%config
1425 TerminalInteractiveShell.editing_mode = 'vi'`` or ``%config
1432 TerminalInteractiveShell.editing_mode = 'vi'`` or ``%config
1426 TerminalInteractiveShell.editing_mode = 'emacs'`` to dynamically switch
1433 TerminalInteractiveShell.editing_mode = 'emacs'`` to dynamically switch
1427 between modes.
1434 between modes.
1428
1435
1429
1436
1430 Notable Fixes:
1437 Notable Fixes:
1431
1438
1432 - Fix entering of **multi-line blocks in terminal** IPython, and various
1439 - Fix entering of **multi-line blocks in terminal** IPython, and various
1433 crashes in the new input transformation machinery :ghpull:`11354`,
1440 crashes in the new input transformation machinery :ghpull:`11354`,
1434 :ghpull:`11356`, :ghpull:`11358`. These also fix a **Compatibility bug
1441 :ghpull:`11356`, :ghpull:`11358`. These also fix a **Compatibility bug
1435 with Python 3.7.1**.
1442 with Python 3.7.1**.
1436
1443
1437 - Fix moving through generator stack in ipdb :ghpull:`11266`
1444 - Fix moving through generator stack in ipdb :ghpull:`11266`
1438
1445
1439 - %Magic command arguments now support quoting. :ghpull:`11330`
1446 - %Magic command arguments now support quoting. :ghpull:`11330`
1440
1447
1441 - Re-add ``rprint`` and ``rprinte`` aliases. :ghpull:`11331`
1448 - Re-add ``rprint`` and ``rprinte`` aliases. :ghpull:`11331`
1442
1449
1443 - Remove implicit dependency on ``ipython_genutils`` :ghpull:`11317`
1450 - Remove implicit dependency on ``ipython_genutils`` :ghpull:`11317`
1444
1451
1445 - Make ``nonlocal`` raise ``SyntaxError`` instead of silently failing in async
1452 - Make ``nonlocal`` raise ``SyntaxError`` instead of silently failing in async
1446 mode. :ghpull:`11382`
1453 mode. :ghpull:`11382`
1447
1454
1448 - Fix mishandling of magics and ``= !`` assignment just after a dedent in
1455 - Fix mishandling of magics and ``= !`` assignment just after a dedent in
1449 nested code blocks :ghpull:`11418`
1456 nested code blocks :ghpull:`11418`
1450
1457
1451 - Fix instructions for custom shortcuts :ghpull:`11426`
1458 - Fix instructions for custom shortcuts :ghpull:`11426`
1452
1459
1453
1460
1454 Notable Internals improvements:
1461 Notable Internals improvements:
1455
1462
1456 - Use of ``os.scandir`` (Python 3 only) to speed up some file system operations.
1463 - Use of ``os.scandir`` (Python 3 only) to speed up some file system operations.
1457 :ghpull:`11365`
1464 :ghpull:`11365`
1458
1465
1459 - use ``perf_counter`` instead of ``clock`` for more precise
1466 - use ``perf_counter`` instead of ``clock`` for more precise
1460 timing results with ``%time`` :ghpull:`11376`
1467 timing results with ``%time`` :ghpull:`11376`
1461
1468
1462 Many thanks to all the contributors and in particular to ``bartskowron`` and
1469 Many thanks to all the contributors and in particular to ``bartskowron`` and
1463 ``tonyfast`` who handled some pretty complicated bugs in the input machinery. We
1470 ``tonyfast`` who handled some pretty complicated bugs in the input machinery. We
1464 had a number of first time contributors and maybe hacktoberfest participants that
1471 had a number of first time contributors and maybe hacktoberfest participants that
1465 made significant contributions and helped us free some time to focus on more
1472 made significant contributions and helped us free some time to focus on more
1466 complicated bugs.
1473 complicated bugs.
1467
1474
1468 You
1475 You
1469 can see all the closed issues and Merged PR, new features and fixes `here
1476 can see all the closed issues and Merged PR, new features and fixes `here
1470 <https://github.com/ipython/ipython/issues?utf8=%E2%9C%93&q=+is%3Aclosed+milestone%3A7.1+>`_.
1477 <https://github.com/ipython/ipython/issues?utf8=%E2%9C%93&q=+is%3Aclosed+milestone%3A7.1+>`_.
1471
1478
1472 Unicode Completion update
1479 Unicode Completion update
1473 -------------------------
1480 -------------------------
1474
1481
1475 In IPython 7.1 the Unicode completion map has been updated and synchronized with
1482 In IPython 7.1 the Unicode completion map has been updated and synchronized with
1476 the Julia language.
1483 the Julia language.
1477
1484
1478 Added and removed character characters:
1485 Added and removed character characters:
1479
1486
1480 ``\jmath`` (``Θ·``), ``\\underleftrightarrow`` (U+034D, combining) have been
1487 ``\jmath`` (``Θ·``), ``\\underleftrightarrow`` (U+034D, combining) have been
1481 added, while ``\\textasciicaron`` have been removed
1488 added, while ``\\textasciicaron`` have been removed
1482
1489
1483 Some sequences have seen their prefix removed:
1490 Some sequences have seen their prefix removed:
1484
1491
1485 - 6 characters ``\text...<tab>`` should now be inputed with ``\...<tab>`` directly,
1492 - 6 characters ``\text...<tab>`` should now be inputed with ``\...<tab>`` directly,
1486 - 45 characters ``\Elz...<tab>`` should now be inputed with ``\...<tab>`` directly,
1493 - 45 characters ``\Elz...<tab>`` should now be inputed with ``\...<tab>`` directly,
1487 - 65 characters ``\B...<tab>`` should now be inputed with ``\...<tab>`` directly,
1494 - 65 characters ``\B...<tab>`` should now be inputed with ``\...<tab>`` directly,
1488 - 450 characters ``\m...<tab>`` should now be inputed with ``\...<tab>`` directly,
1495 - 450 characters ``\m...<tab>`` should now be inputed with ``\...<tab>`` directly,
1489
1496
1490 Some sequences have seen their prefix shortened:
1497 Some sequences have seen their prefix shortened:
1491
1498
1492 - 5 characters ``\mitBbb...<tab>`` should now be inputed with ``\bbi...<tab>`` directly,
1499 - 5 characters ``\mitBbb...<tab>`` should now be inputed with ``\bbi...<tab>`` directly,
1493 - 52 characters ``\mit...<tab>`` should now be inputed with ``\i...<tab>`` directly,
1500 - 52 characters ``\mit...<tab>`` should now be inputed with ``\i...<tab>`` directly,
1494 - 216 characters ``\mbfit...<tab>`` should now be inputed with ``\bi...<tab>`` directly,
1501 - 216 characters ``\mbfit...<tab>`` should now be inputed with ``\bi...<tab>`` directly,
1495 - 222 characters ``\mbf...<tab>`` should now be inputed with ``\b...<tab>`` directly,
1502 - 222 characters ``\mbf...<tab>`` should now be inputed with ``\b...<tab>`` directly,
1496
1503
1497 A couple of characters had their sequence simplified:
1504 A couple of characters had their sequence simplified:
1498
1505
1499 - ``Γ°``, type ``\dh<tab>``, instead of ``\eth<tab>``
1506 - ``Γ°``, type ``\dh<tab>``, instead of ``\eth<tab>``
1500 - ``Δ§``, type ``\hbar<tab>``, instead of ``\Elzxh<tab>``
1507 - ``Δ§``, type ``\hbar<tab>``, instead of ``\Elzxh<tab>``
1501 - ``ΙΈ``, type ``\ltphi<tab>``, instead of ``\textphi<tab>``
1508 - ``ΙΈ``, type ``\ltphi<tab>``, instead of ``\textphi<tab>``
1502 - ``Ο΄``, type ``\varTheta<tab>``, instead of ``\textTheta<tab>``
1509 - ``Ο΄``, type ``\varTheta<tab>``, instead of ``\textTheta<tab>``
1503 - ``ℇ``, type ``\eulermascheroni<tab>``, instead of ``\Eulerconst<tab>``
1510 - ``ℇ``, type ``\eulermascheroni<tab>``, instead of ``\Eulerconst<tab>``
1504 - ``β„Ž``, type ``\planck<tab>``, instead of ``\Planckconst<tab>``
1511 - ``β„Ž``, type ``\planck<tab>``, instead of ``\Planckconst<tab>``
1505
1512
1506 - U+0336 (COMBINING LONG STROKE OVERLAY), type ``\strike<tab>``, instead of ``\Elzbar<tab>``.
1513 - U+0336 (COMBINING LONG STROKE OVERLAY), type ``\strike<tab>``, instead of ``\Elzbar<tab>``.
1507
1514
1508 A couple of sequences have been updated:
1515 A couple of sequences have been updated:
1509
1516
1510 - ``\varepsilon`` now gives ``Ι›`` (GREEK SMALL LETTER EPSILON) instead of ``Ξ΅`` (GREEK LUNATE EPSILON SYMBOL),
1517 - ``\varepsilon`` now gives ``Ι›`` (GREEK SMALL LETTER EPSILON) instead of ``Ξ΅`` (GREEK LUNATE EPSILON SYMBOL),
1511 - ``\underbar`` now gives U+0331 (COMBINING MACRON BELOW) instead of U+0332 (COMBINING LOW LINE).
1518 - ``\underbar`` now gives U+0331 (COMBINING MACRON BELOW) instead of U+0332 (COMBINING LOW LINE).
1512
1519
1513
1520
1514 .. _whatsnew700:
1521 .. _whatsnew700:
1515
1522
1516 IPython 7.0.0
1523 IPython 7.0.0
1517 =============
1524 =============
1518
1525
1519 Released Thursday September 27th, 2018
1526 Released Thursday September 27th, 2018
1520
1527
1521 IPython 7 includes major feature improvements.
1528 IPython 7 includes major feature improvements.
1522 This is also the second major version of IPython to support only
1529 This is also the second major version of IPython to support only
1523 Python 3 – starting at Python 3.4. Python 2 is still community-supported
1530 Python 3 – starting at Python 3.4. Python 2 is still community-supported
1524 on the bugfix only 5.x branch, but we remind you that Python 2 "end of life"
1531 on the bugfix only 5.x branch, but we remind you that Python 2 "end of life"
1525 is on Jan 1st 2020.
1532 is on Jan 1st 2020.
1526
1533
1527 We were able to backport bug fixes to the 5.x branch thanks to our backport bot which
1534 We were able to backport bug fixes to the 5.x branch thanks to our backport bot which
1528 backported more than `70 Pull-Requests
1535 backported more than `70 Pull-Requests
1529 <https://github.com/ipython/ipython/pulls?page=3&q=is%3Apr+sort%3Aupdated-desc+author%3Aapp%2Fmeeseeksdev++5.x&utf8=%E2%9C%93>`_, but there are still many PRs that required manual work. This is an area of the project where you can easily contribute by looking for `PRs that still need manual backport <https://github.com/ipython/ipython/issues?q=label%3A%22Still+Needs+Manual+Backport%22+is%3Aclosed+sort%3Aupdated-desc>`_
1536 <https://github.com/ipython/ipython/pulls?page=3&q=is%3Apr+sort%3Aupdated-desc+author%3Aapp%2Fmeeseeksdev++5.x&utf8=%E2%9C%93>`_, but there are still many PRs that required manual work. This is an area of the project where you can easily contribute by looking for `PRs that still need manual backport <https://github.com/ipython/ipython/issues?q=label%3A%22Still+Needs+Manual+Backport%22+is%3Aclosed+sort%3Aupdated-desc>`_
1530
1537
1531 The IPython 6.x branch will likely not see any further release unless critical
1538 The IPython 6.x branch will likely not see any further release unless critical
1532 bugs are found.
1539 bugs are found.
1533
1540
1534 Make sure you have pip > 9.0 before upgrading. You should be able to update by running:
1541 Make sure you have pip > 9.0 before upgrading. You should be able to update by running:
1535
1542
1536 .. code::
1543 .. code::
1537
1544
1538 pip install ipython --upgrade
1545 pip install ipython --upgrade
1539
1546
1540 .. only:: ipydev
1547 .. only:: ipydev
1541
1548
1542 If you are trying to install or update an ``alpha``, ``beta``, or ``rc``
1549 If you are trying to install or update an ``alpha``, ``beta``, or ``rc``
1543 version, use pip ``--pre`` flag.
1550 version, use pip ``--pre`` flag.
1544
1551
1545 .. code::
1552 .. code::
1546
1553
1547 pip install ipython --upgrade --pre
1554 pip install ipython --upgrade --pre
1548
1555
1549
1556
1550 Or, if you have conda installed:
1557 Or, if you have conda installed:
1551
1558
1552 .. code::
1559 .. code::
1553
1560
1554 conda install ipython
1561 conda install ipython
1555
1562
1556
1563
1557
1564
1558 Prompt Toolkit 2.0
1565 Prompt Toolkit 2.0
1559 ------------------
1566 ------------------
1560
1567
1561 IPython 7.0+ now uses ``prompt_toolkit 2.0``. If you still need to use an earlier
1568 IPython 7.0+ now uses ``prompt_toolkit 2.0``. If you still need to use an earlier
1562 ``prompt_toolkit`` version, you may need to pin IPython to ``<7.0``.
1569 ``prompt_toolkit`` version, you may need to pin IPython to ``<7.0``.
1563
1570
1564 Autowait: Asynchronous REPL
1571 Autowait: Asynchronous REPL
1565 ---------------------------
1572 ---------------------------
1566
1573
1567 Staring with IPython 7.0 on Python 3.6+, IPython can automatically ``await``
1574 Staring with IPython 7.0 on Python 3.6+, IPython can automatically ``await``
1568 top level code. You should not need to access an event loop or runner
1575 top level code. You should not need to access an event loop or runner
1569 yourself. To learn more, read the :ref:`autoawait` section of our docs, see
1576 yourself. To learn more, read the :ref:`autoawait` section of our docs, see
1570 :ghpull:`11265`, or try the following code::
1577 :ghpull:`11265`, or try the following code::
1571
1578
1572 Python 3.6.0
1579 Python 3.6.0
1573 Type 'copyright', 'credits' or 'license' for more information
1580 Type 'copyright', 'credits' or 'license' for more information
1574 IPython 7.0.0 -- An enhanced Interactive Python. Type '?' for help.
1581 IPython 7.0.0 -- An enhanced Interactive Python. Type '?' for help.
1575
1582
1576 In [1]: import aiohttp
1583 In [1]: import aiohttp
1577 ...: result = aiohttp.get('https://api.github.com')
1584 ...: result = aiohttp.get('https://api.github.com')
1578
1585
1579 In [2]: response = await result
1586 In [2]: response = await result
1580 <pause for a few 100s ms>
1587 <pause for a few 100s ms>
1581
1588
1582 In [3]: await response.json()
1589 In [3]: await response.json()
1583 Out[3]:
1590 Out[3]:
1584 {'authorizations_url': 'https://api.github.com/authorizations',
1591 {'authorizations_url': 'https://api.github.com/authorizations',
1585 'code_search_url': 'https://api.github.com/search/code?q={query}{&page,per_page,sort,order}',
1592 'code_search_url': 'https://api.github.com/search/code?q={query}{&page,per_page,sort,order}',
1586 ...
1593 ...
1587 }
1594 }
1588
1595
1589 .. note::
1596 .. note::
1590
1597
1591 Async integration is experimental code, behavior may change or be removed
1598 Async integration is experimental code, behavior may change or be removed
1592 between Python and IPython versions without warnings.
1599 between Python and IPython versions without warnings.
1593
1600
1594 Integration is by default with `asyncio`, but other libraries can be configured --
1601 Integration is by default with `asyncio`, but other libraries can be configured --
1595 like ``curio`` or ``trio`` -- to improve concurrency in the REPL::
1602 like ``curio`` or ``trio`` -- to improve concurrency in the REPL::
1596
1603
1597 In [1]: %autoawait trio
1604 In [1]: %autoawait trio
1598
1605
1599 In [2]: import trio
1606 In [2]: import trio
1600
1607
1601 In [3]: async def child(i):
1608 In [3]: async def child(i):
1602 ...: print(" child %s goes to sleep"%i)
1609 ...: print(" child %s goes to sleep"%i)
1603 ...: await trio.sleep(2)
1610 ...: await trio.sleep(2)
1604 ...: print(" child %s wakes up"%i)
1611 ...: print(" child %s wakes up"%i)
1605
1612
1606 In [4]: print('parent start')
1613 In [4]: print('parent start')
1607 ...: async with trio.open_nursery() as n:
1614 ...: async with trio.open_nursery() as n:
1608 ...: for i in range(3):
1615 ...: for i in range(3):
1609 ...: n.spawn(child, i)
1616 ...: n.spawn(child, i)
1610 ...: print('parent end')
1617 ...: print('parent end')
1611 parent start
1618 parent start
1612 child 2 goes to sleep
1619 child 2 goes to sleep
1613 child 0 goes to sleep
1620 child 0 goes to sleep
1614 child 1 goes to sleep
1621 child 1 goes to sleep
1615 <about 2 seconds pause>
1622 <about 2 seconds pause>
1616 child 2 wakes up
1623 child 2 wakes up
1617 child 1 wakes up
1624 child 1 wakes up
1618 child 0 wakes up
1625 child 0 wakes up
1619 parent end
1626 parent end
1620
1627
1621 See :ref:`autoawait` for more information.
1628 See :ref:`autoawait` for more information.
1622
1629
1623
1630
1624 Asynchronous code in a Notebook interface or any other frontend using the
1631 Asynchronous code in a Notebook interface or any other frontend using the
1625 Jupyter Protocol will require further updates to the IPykernel package.
1632 Jupyter Protocol will require further updates to the IPykernel package.
1626
1633
1627 Non-Asynchronous code
1634 Non-Asynchronous code
1628 ~~~~~~~~~~~~~~~~~~~~~
1635 ~~~~~~~~~~~~~~~~~~~~~
1629
1636
1630 As the internal API of IPython is now asynchronous, IPython needs to run under
1637 As the internal API of IPython is now asynchronous, IPython needs to run under
1631 an event loop. In order to allow many workflows, (like using the :magic:`%run`
1638 an event loop. In order to allow many workflows, (like using the :magic:`%run`
1632 magic, or copy-pasting code that explicitly starts/stop event loop), when
1639 magic, or copy-pasting code that explicitly starts/stop event loop), when
1633 top-level code is detected as not being asynchronous, IPython code is advanced
1640 top-level code is detected as not being asynchronous, IPython code is advanced
1634 via a pseudo-synchronous runner, and may not advance pending tasks.
1641 via a pseudo-synchronous runner, and may not advance pending tasks.
1635
1642
1636 Change to Nested Embed
1643 Change to Nested Embed
1637 ~~~~~~~~~~~~~~~~~~~~~~
1644 ~~~~~~~~~~~~~~~~~~~~~~
1638
1645
1639 The introduction of the ability to run async code had some effect on the
1646 The introduction of the ability to run async code had some effect on the
1640 ``IPython.embed()`` API. By default, embed will not allow you to run asynchronous
1647 ``IPython.embed()`` API. By default, embed will not allow you to run asynchronous
1641 code unless an event loop is specified.
1648 code unless an event loop is specified.
1642
1649
1643 Effects on Magics
1650 Effects on Magics
1644 ~~~~~~~~~~~~~~~~~
1651 ~~~~~~~~~~~~~~~~~
1645
1652
1646 Some magics will not work with async until they're updated.
1653 Some magics will not work with async until they're updated.
1647 Contributions welcome.
1654 Contributions welcome.
1648
1655
1649 Expected Future changes
1656 Expected Future changes
1650 ~~~~~~~~~~~~~~~~~~~~~~~
1657 ~~~~~~~~~~~~~~~~~~~~~~~
1651
1658
1652 We expect more internal but public IPython functions to become ``async``, and
1659 We expect more internal but public IPython functions to become ``async``, and
1653 will likely end up having a persistent event loop while IPython is running.
1660 will likely end up having a persistent event loop while IPython is running.
1654
1661
1655 Thanks
1662 Thanks
1656 ~~~~~~
1663 ~~~~~~
1657
1664
1658 This release took more than a year in the making.
1665 This release took more than a year in the making.
1659 The code was rebased a number of
1666 The code was rebased a number of
1660 times; leading to commit authorship that may have been lost in the final
1667 times; leading to commit authorship that may have been lost in the final
1661 Pull-Request. Huge thanks to many people for contribution, discussion, code,
1668 Pull-Request. Huge thanks to many people for contribution, discussion, code,
1662 documentation, use-cases: dalejung, danielballan, ellisonbg, fperez, gnestor,
1669 documentation, use-cases: dalejung, danielballan, ellisonbg, fperez, gnestor,
1663 minrk, njsmith, pganssle, tacaswell, takluyver , vidartf ... And many others.
1670 minrk, njsmith, pganssle, tacaswell, takluyver , vidartf ... And many others.
1664
1671
1665
1672
1666 Autoreload Improvement
1673 Autoreload Improvement
1667 ----------------------
1674 ----------------------
1668
1675
1669 The magic :magic:`%autoreload 2 <autoreload>` now captures new methods added to
1676 The magic :magic:`%autoreload 2 <autoreload>` now captures new methods added to
1670 classes. Earlier, only methods existing as of the initial import were being
1677 classes. Earlier, only methods existing as of the initial import were being
1671 tracked and updated.
1678 tracked and updated.
1672
1679
1673 This new feature helps dual environment development - Jupyter+IDE - where the
1680 This new feature helps dual environment development - Jupyter+IDE - where the
1674 code gradually moves from notebook cells to package files as it gets
1681 code gradually moves from notebook cells to package files as it gets
1675 structured.
1682 structured.
1676
1683
1677 **Example**: An instance of the class ``MyClass`` will be able to access the
1684 **Example**: An instance of the class ``MyClass`` will be able to access the
1678 method ``cube()`` after it is uncommented and the file ``file1.py`` is saved on
1685 method ``cube()`` after it is uncommented and the file ``file1.py`` is saved on
1679 disk.
1686 disk.
1680
1687
1681
1688
1682 .. code::
1689 .. code::
1683
1690
1684 # notebook
1691 # notebook
1685
1692
1686 from mymodule import MyClass
1693 from mymodule import MyClass
1687 first = MyClass(5)
1694 first = MyClass(5)
1688
1695
1689 .. code::
1696 .. code::
1690
1697
1691 # mymodule/file1.py
1698 # mymodule/file1.py
1692
1699
1693 class MyClass:
1700 class MyClass:
1694
1701
1695 def __init__(self, a=10):
1702 def __init__(self, a=10):
1696 self.a = a
1703 self.a = a
1697
1704
1698 def square(self):
1705 def square(self):
1699 print('compute square')
1706 print('compute square')
1700 return self.a*self.a
1707 return self.a*self.a
1701
1708
1702 # def cube(self):
1709 # def cube(self):
1703 # print('compute cube')
1710 # print('compute cube')
1704 # return self.a*self.a*self.a
1711 # return self.a*self.a*self.a
1705
1712
1706
1713
1707
1714
1708
1715
1709 Misc
1716 Misc
1710 ----
1717 ----
1711
1718
1712 The autoindent feature that was deprecated in 5.x was re-enabled and
1719 The autoindent feature that was deprecated in 5.x was re-enabled and
1713 un-deprecated in :ghpull:`11257`
1720 un-deprecated in :ghpull:`11257`
1714
1721
1715 Make :magic:`%run -n -i ... <run>` work correctly. Earlier, if :magic:`%run` was
1722 Make :magic:`%run -n -i ... <run>` work correctly. Earlier, if :magic:`%run` was
1716 passed both arguments, ``-n`` would be silently ignored. See :ghpull:`10308`
1723 passed both arguments, ``-n`` would be silently ignored. See :ghpull:`10308`
1717
1724
1718
1725
1719 The :cellmagic:`%%script` (as well as :cellmagic:`%%bash`,
1726 The :cellmagic:`%%script` (as well as :cellmagic:`%%bash`,
1720 :cellmagic:`%%ruby`... ) cell magics now raise by default if the return code of
1727 :cellmagic:`%%ruby`... ) cell magics now raise by default if the return code of
1721 the given code is non-zero (thus halting execution of further cells in a
1728 the given code is non-zero (thus halting execution of further cells in a
1722 notebook). The behavior can be disable by passing the ``--no-raise-error`` flag.
1729 notebook). The behavior can be disable by passing the ``--no-raise-error`` flag.
1723
1730
1724
1731
1725 Deprecations
1732 Deprecations
1726 ------------
1733 ------------
1727
1734
1728 A couple of unused functions and methods have been deprecated and will be removed
1735 A couple of unused functions and methods have been deprecated and will be removed
1729 in future versions:
1736 in future versions:
1730
1737
1731 - ``IPython.utils.io.raw_print_err``
1738 - ``IPython.utils.io.raw_print_err``
1732 - ``IPython.utils.io.raw_print``
1739 - ``IPython.utils.io.raw_print``
1733
1740
1734
1741
1735 Backwards incompatible changes
1742 Backwards incompatible changes
1736 ------------------------------
1743 ------------------------------
1737
1744
1738 * The API for transforming input before it is parsed as Python code has been
1745 * The API for transforming input before it is parsed as Python code has been
1739 completely redesigned: any custom input transformations will need to be
1746 completely redesigned: any custom input transformations will need to be
1740 rewritten. See :doc:`/config/inputtransforms` for details of the new API.
1747 rewritten. See :doc:`/config/inputtransforms` for details of the new API.
General Comments 0
You need to be logged in to leave comments. Login now