##// END OF EJS Templates
Merge pull request #9240 from parleur/warn...
Matthias Bussonnier -
r22098:5cb34103 merge
parent child Browse files
Show More
@@ -29,7 +29,7 b' from IPython.core.error import UsageError'
29
29
30 from IPython.utils.py3compat import string_types
30 from IPython.utils.py3compat import string_types
31 from traitlets import List, Instance
31 from traitlets import List, Instance
32 from IPython.utils.warn import error
32 from logging import error
33
33
34 #-----------------------------------------------------------------------------
34 #-----------------------------------------------------------------------------
35 # Utilities
35 # Utilities
@@ -18,7 +18,7 b' from traitlets.config.configurable import Configurable'
18 from IPython.utils import io
18 from IPython.utils import io
19 from IPython.utils.py3compat import builtin_mod, cast_unicode_py2
19 from IPython.utils.py3compat import builtin_mod, cast_unicode_py2
20 from traitlets import Instance, Float
20 from traitlets import Instance, Float
21 from IPython.utils.warn import warn
21 from warnings import warn
22
22
23 # TODO: Move the various attributes (cache_size, [others now moved]). Some
23 # TODO: Move the various attributes (cache_size, [others now moved]). Some
24 # of these are also attributes of InteractiveShell. They should be on ONE object
24 # of these are also attributes of InteractiveShell. They should be on ONE object
@@ -293,4 +293,3 b' class DisplayHook(Configurable):'
293 # IronPython blocks here forever
293 # IronPython blocks here forever
294 if sys.platform != "cli":
294 if sys.platform != "cli":
295 gc.collect()
295 gc.collect()
296
@@ -35,7 +35,7 b' from IPython.utils import py3compat'
35 from traitlets import (
35 from traitlets import (
36 Any, Bool, Dict, Instance, Integer, List, Unicode, TraitError,
36 Any, Bool, Dict, Instance, Integer, List, Unicode, TraitError,
37 )
37 )
38 from IPython.utils.warn import warn
38 from warnings import warn
39
39
40 #-----------------------------------------------------------------------------
40 #-----------------------------------------------------------------------------
41 # Classes and functions
41 # Classes and functions
@@ -879,5 +879,3 b' def _format_lineno(session, line):'
879 if session == 0:
879 if session == 0:
880 return str(line)
880 return str(line)
881 return "%s#%s" % (session, line)
881 return "%s#%s" % (session, line)
882
883
@@ -77,7 +77,8 b' from IPython.utils.text import (format_screen, LSString, SList,'
77 DollarFormatter)
77 DollarFormatter)
78 from traitlets import (Integer, Bool, CBool, CaselessStrEnum, Enum,
78 from traitlets import (Integer, Bool, CBool, CaselessStrEnum, Enum,
79 List, Dict, Unicode, Instance, Type)
79 List, Dict, Unicode, Instance, Type)
80 from IPython.utils.warn import warn, error
80 from warnings import warn
81 from logging import error
81 import IPython.core.hooks
82 import IPython.core.hooks
82
83
83 #-----------------------------------------------------------------------------
84 #-----------------------------------------------------------------------------
@@ -33,7 +33,7 b' from IPython.utils.process import arg_split'
33 from IPython.utils.py3compat import string_types, iteritems
33 from IPython.utils.py3compat import string_types, iteritems
34 from IPython.utils.text import dedent
34 from IPython.utils.text import dedent
35 from traitlets import Bool, Dict, Instance
35 from traitlets import Bool, Dict, Instance
36 from IPython.utils.warn import error
36 from logging import error
37
37
38 #-----------------------------------------------------------------------------
38 #-----------------------------------------------------------------------------
39 # Globals
39 # Globals
@@ -1,6 +1,7 b''
1 """Implementation of magic functions that control various automatic behaviors.
1 """Implementation of magic functions that control various automatic behaviors.
2 """
2 """
3 from __future__ import print_function
3 from __future__ import print_function
4 from __future__ import absolute_import
4 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
5 # Copyright (c) 2012 The IPython Development Team.
6 # Copyright (c) 2012 The IPython Development Team.
6 #
7 #
@@ -16,7 +17,7 b' from __future__ import print_function'
16 # Our own packages
17 # Our own packages
17 from IPython.core.magic import Bunch, Magics, magics_class, line_magic
18 from IPython.core.magic import Bunch, Magics, magics_class, line_magic
18 from IPython.testing.skipdoctest import skip_doctest
19 from IPython.testing.skipdoctest import skip_doctest
19 from IPython.utils.warn import error
20 from logging import error
20
21
21 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
22 # Magic implementation classes
23 # Magic implementation classes
@@ -1,6 +1,7 b''
1 """Implementation of basic magic functions."""
1 """Implementation of basic magic functions."""
2
2
3 from __future__ import print_function
3 from __future__ import print_function
4 from __future__ import absolute_import
4
5
5 import io
6 import io
6 import sys
7 import sys
@@ -14,7 +15,8 b' from IPython.testing.skipdoctest import skip_doctest'
14 from IPython.utils.ipstruct import Struct
15 from IPython.utils.ipstruct import Struct
15 from IPython.utils.path import unquote_filename
16 from IPython.utils.path import unquote_filename
16 from IPython.utils.py3compat import unicode_type
17 from IPython.utils.py3compat import unicode_type
17 from IPython.utils.warn import warn, error
18 from warnings import warn
19 from logging import error
18
20
19
21
20 class MagicsDisplay(object):
22 class MagicsDisplay(object):
@@ -1,6 +1,7 b''
1 """Implementation of code management magic functions.
1 """Implementation of code management magic functions.
2 """
2 """
3 from __future__ import print_function
3 from __future__ import print_function
4 from __future__ import absolute_import
4 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
5 # Copyright (c) 2012 The IPython Development Team.
6 # Copyright (c) 2012 The IPython Development Team.
6 #
7 #
@@ -32,7 +33,8 b' from IPython.utils import py3compat'
32 from IPython.utils.py3compat import string_types
33 from IPython.utils.py3compat import string_types
33 from IPython.utils.contexts import preserve_keys
34 from IPython.utils.contexts import preserve_keys
34 from IPython.utils.path import get_py_filename, unquote_filename
35 from IPython.utils.path import get_py_filename, unquote_filename
35 from IPython.utils.warn import warn, error
36 from warnings import warn
37 from logging import error
36 from IPython.utils.text import get_text_list
38 from IPython.utils.text import get_text_list
37
39
38 #-----------------------------------------------------------------------------
40 #-----------------------------------------------------------------------------
@@ -1,6 +1,7 b''
1 """Implementation of configuration-related magic functions.
1 """Implementation of configuration-related magic functions.
2 """
2 """
3 from __future__ import print_function
3 from __future__ import print_function
4 from __future__ import absolute_import
4 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
5 # Copyright (c) 2012 The IPython Development Team.
6 # Copyright (c) 2012 The IPython Development Team.
6 #
7 #
@@ -19,7 +20,7 b' import re'
19 # Our own packages
20 # Our own packages
20 from IPython.core.error import UsageError
21 from IPython.core.error import UsageError
21 from IPython.core.magic import Magics, magics_class, line_magic
22 from IPython.core.magic import Magics, magics_class, line_magic
22 from IPython.utils.warn import error
23 from logging import error
23
24
24 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
25 # Magic implementation classes
26 # Magic implementation classes
@@ -5,6 +5,7 b''
5 # Distributed under the terms of the Modified BSD License.
5 # Distributed under the terms of the Modified BSD License.
6
6
7 from __future__ import print_function
7 from __future__ import print_function
8 from __future__ import absolute_import
8
9
9 import ast
10 import ast
10 import bdb
11 import bdb
@@ -43,7 +44,8 b' from IPython.utils.ipstruct import Struct'
43 from IPython.utils.module_paths import find_mod
44 from IPython.utils.module_paths import find_mod
44 from IPython.utils.path import get_py_filename, unquote_filename, shellglob
45 from IPython.utils.path import get_py_filename, unquote_filename, shellglob
45 from IPython.utils.timing import clock, clock2
46 from IPython.utils.timing import clock, clock2
46 from IPython.utils.warn import warn, error
47 from warnings import warn
48 from logging import error
47
49
48 if PY3:
50 if PY3:
49 from io import StringIO
51 from io import StringIO
@@ -18,7 +18,7 b' import sys'
18
18
19 # Our own packages
19 # Our own packages
20 from IPython.core.magic import Magics, magics_class, line_magic
20 from IPython.core.magic import Magics, magics_class, line_magic
21 from IPython.utils.warn import warn
21 from warnings import warn
22 from IPython.utils.py3compat import str_to_unicode
22 from IPython.utils.py3compat import str_to_unicode
23
23
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
@@ -18,7 +18,7 b' from traitlets.config.application import Application'
18 from IPython.core import magic_arguments
18 from IPython.core import magic_arguments
19 from IPython.core.magic import Magics, magics_class, line_magic
19 from IPython.core.magic import Magics, magics_class, line_magic
20 from IPython.testing.skipdoctest import skip_doctest
20 from IPython.testing.skipdoctest import skip_doctest
21 from IPython.utils.warn import warn
21 from warnings import warn
22 from IPython.core.pylabtools import backends
22 from IPython.core.pylabtools import backends
23
23
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
@@ -118,7 +118,7 b' from IPython.utils import path as util_path'
118 from IPython.utils import py3compat
118 from IPython.utils import py3compat
119 from IPython.utils import ulinecache
119 from IPython.utils import ulinecache
120 from IPython.utils.data import uniq_stable
120 from IPython.utils.data import uniq_stable
121 from IPython.utils.warn import info, error
121 from logging import info, error
122
122
123 # Globals
123 # Globals
124 # amount of space to put line numbers before verbose tracebacks
124 # amount of space to put line numbers before verbose tracebacks
@@ -36,7 +36,7 b' import threading'
36
36
37 from IPython import get_ipython
37 from IPython import get_ipython
38 from IPython.core.ultratb import AutoFormattedTB
38 from IPython.core.ultratb import AutoFormattedTB
39 from IPython.utils.warn import error
39 from logging import error
40 from IPython.utils.py3compat import string_types
40 from IPython.utils.py3compat import string_types
41
41
42
42
@@ -17,7 +17,7 b' import platform'
17 import sys
17 import sys
18 from distutils.version import LooseVersion as V
18 from distutils.version import LooseVersion as V
19
19
20 from IPython.utils.warn import warn
20 from warnings import warn
21
21
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23 # Constants
23 # Constants
@@ -22,7 +22,8 b' from IPython.utils.encoding import get_stream_enc'
22 from IPython.utils import py3compat
22 from IPython.utils import py3compat
23 from IPython.utils.terminal import toggle_set_term_title, set_term_title
23 from IPython.utils.terminal import toggle_set_term_title, set_term_title
24 from IPython.utils.process import abbrev_cwd
24 from IPython.utils.process import abbrev_cwd
25 from IPython.utils.warn import warn, error
25 from warnings import warn
26 from logging import error
26 from IPython.utils.text import num_ini_spaces, SList, strip_email_quotes
27 from IPython.utils.text import num_ini_spaces, SList, strip_email_quotes
27 from traitlets import Integer, CBool, Unicode
28 from traitlets import Integer, CBool, Unicode
28
29
@@ -212,7 +212,7 b" test_group_names.append('autoreload')"
212
212
213 def check_exclusions_exist():
213 def check_exclusions_exist():
214 from IPython.paths import get_ipython_package_dir
214 from IPython.paths import get_ipython_package_dir
215 from IPython.utils.warn import warn
215 from warnings import warn
216 parent = os.path.dirname(get_ipython_package_dir())
216 parent = os.path.dirname(get_ipython_package_dir())
217 for sec in test_sections:
217 for sec in test_sections:
218 for pattern in sec.exclusions:
218 for pattern in sec.exclusions:
@@ -439,4 +439,3 b' def run_iptest():'
439
439
440 if __name__ == '__main__':
440 if __name__ == '__main__':
441 run_iptest()
441 run_iptest()
442
@@ -12,6 +12,9 b' import sys'
12
12
13 from IPython.utils import io
13 from IPython.utils import io
14
14
15 import warnings
16
17 warnings.warn("The module IPython.utils.warn is deprecated, use the standard warnings module instead", DeprecationWarning)
15
18
16 def warn(msg,level=2,exit_val=1):
19 def warn(msg,level=2,exit_val=1):
17 """Standard warning printer. Gives formatting consistency.
20 """Standard warning printer. Gives formatting consistency.
@@ -29,7 +32,8 b' def warn(msg,level=2,exit_val=1):'
29
32
30 -exit_val (1): exit value returned by sys.exit() for a level 4
33 -exit_val (1): exit value returned by sys.exit() for a level 4
31 warning. Ignored for all other levels."""
34 warning. Ignored for all other levels."""
32
35
36 warnings.warn("The module IPython.utils.warn is deprecated, use the standard warnings module instead", DeprecationWarning)
33 if level>0:
37 if level>0:
34 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
38 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
35 print(header[level], msg, sep='', file=io.stderr)
39 print(header[level], msg, sep='', file=io.stderr)
@@ -54,4 +58,3 b' def fatal(msg,exit_val=1):'
54 """Equivalent to warn(msg,exit_val=exit_val,level=4)."""
58 """Equivalent to warn(msg,exit_val=exit_val,level=4)."""
55
59
56 warn(msg,exit_val=exit_val,level=4)
60 warn(msg,exit_val=exit_val,level=4)
57
General Comments 0
You need to be logged in to leave comments. Login now