##// END OF EJS Templates
Merge pull request #11271 from luzpaz/misc-typo-and-whitespaces...
Matthias Bussonnier -
r24495:0de2f49c merge
parent child Browse files
Show More
@@ -40,7 +40,7 b' import time'
40 40 # Constants
41 41 #-----------------------------------------------------------------------------
42 42
43 # Roughtly equal to PyCF_MASK | PyCF_MASK_OBSOLETE as defined in pythonrun.h,
43 # Roughly equal to PyCF_MASK | PyCF_MASK_OBSOLETE as defined in pythonrun.h,
44 44 # this is used as a bitmask to extract future-related code flags.
45 45 PyCF_MASK = functools.reduce(operator.or_,
46 46 (getattr(__future__, fname).compiler_flag
@@ -52,7 +52,7 b' PyCF_MASK = functools.reduce(operator.or_,'
52 52
53 53 def code_name(code, number=0):
54 54 """ Compute a (probably) unique name for code for caching.
55
55
56 56 This now expects code to be unicode.
57 57 """
58 58 hash_digest = hashlib.sha1(code.encode("utf-8")).hexdigest()
@@ -71,7 +71,7 b' class CachingCompiler(codeop.Compile):'
71 71
72 72 def __init__(self):
73 73 codeop.Compile.__init__(self)
74
74
75 75 # This is ugly, but it must be done this way to allow multiple
76 76 # simultaneous ipython instances to coexist. Since Python itself
77 77 # directly accesses the data structures in the linecache module, and
@@ -95,7 +95,7 b' class CachingCompiler(codeop.Compile):'
95 95 def _fix_module_ds(self, module):
96 96 """
97 97 Starting in python 3.7 the AST for mule have changed, and if
98 the first expressions encountered is a string it is attached to the
98 the first expressions encountered is a string it is attached to the
99 99 `docstring` attribute of the `Module` ast node.
100 100
101 101 This breaks IPython, as if this string is the only expression, IPython
@@ -108,14 +108,14 b' class CachingCompiler(codeop.Compile):'
108 108 new_body=[Expr(Str(docstring, lineno=1, col_offset=0), lineno=1, col_offset=0)]
109 109 new_body.extend(module.body)
110 110 return fix_missing_locations(Module(new_body))
111
111
112 112 def ast_parse(self, source, filename='<unknown>', symbol='exec'):
113 113 """Parse code to an AST with the current compiler flags active.
114
114
115 115 Arguments are exactly the same as ast.parse (in the standard library),
116 116 and are passed to the built-in compile function."""
117 117 return self._fix_module_ds(compile(source, filename, symbol, self.flags | PyCF_ONLY_AST, 1))
118
118
119 119 def reset_compiler_flags(self):
120 120 """Reset compiler flags to default state."""
121 121 # This value is copied from codeop.Compile.__init__, so if that ever
@@ -127,10 +127,10 b' class CachingCompiler(codeop.Compile):'
127 127 """Flags currently active in the compilation process.
128 128 """
129 129 return self.flags
130
130
131 131 def cache(self, code, number=0):
132 132 """Make a name for a block of code, and cache the code.
133
133
134 134 Parameters
135 135 ----------
136 136 code : str
@@ -138,7 +138,7 b' class CachingCompiler(codeop.Compile):'
138 138 number : int
139 139 A number which forms part of the code's name. Used for the execution
140 140 counter.
141
141
142 142 Returns
143 143 -------
144 144 The name of the cached code (as a string). Pass this as the filename
@@ -174,7 +174,7 b' class CommandChainDispatcher:'
174 174 def shutdown_hook(self):
175 175 """ default shutdown hook
176 176
177 Typically, shotdown hooks should raise TryNext so all shutdown ops are done
177 Typically, shutdown hooks should raise TryNext so all shutdown ops are done
178 178 """
179 179
180 180 #print "default shutdown hook ok" # dbg
@@ -82,7 +82,7 b' class PrefilterManager(Configurable):'
82 82 prefilter consumes lines of input and produces transformed lines of
83 83 input.
84 84
85 The iplementation consists of two phases:
85 The implementation consists of two phases:
86 86
87 87 1. Transformers
88 88 2. Checkers and handlers
@@ -104,7 +104,7 b" _re_pattern_type = type(re.compile(''))"
104 104
105 105 def _safe_getattr(obj, attr, default=None):
106 106 """Safe version of getattr.
107
107
108 108 Same as getattr, but will return ``default`` on any Exception,
109 109 rather than raising.
110 110 """
@@ -246,7 +246,7 b' class PrettyPrinter(_PrettyPrinterBase):'
246 246 self.buffer.append(Breakable(sep, width, self))
247 247 self.buffer_width += width
248 248 self._break_outer_groups()
249
249
250 250 def break_(self):
251 251 """
252 252 Explicitly insert a newline into the output, maintaining correct indentation.
@@ -256,7 +256,7 b' class PrettyPrinter(_PrettyPrinterBase):'
256 256 self.output.write(' ' * self.indentation)
257 257 self.output_width = self.indentation
258 258 self.buffer_width = 0
259
259
260 260
261 261 def begin_group(self, indent=0, open=''):
262 262 """
@@ -282,7 +282,7 b' class PrettyPrinter(_PrettyPrinterBase):'
282 282 self.group_stack.append(group)
283 283 self.group_queue.enq(group)
284 284 self.indentation += indent
285
285
286 286 def _enumerate(self, seq):
287 287 """like enumerate, but with an upper limit on the number of items"""
288 288 for idx, x in enumerate(seq):
@@ -292,7 +292,7 b' class PrettyPrinter(_PrettyPrinterBase):'
292 292 self.text('...')
293 293 return
294 294 yield idx, x
295
295
296 296 def end_group(self, dedent=0, close=''):
297 297 """End a group. See `begin_group` for more details."""
298 298 self.indentation -= dedent
@@ -765,7 +765,7 b' if _env_type is not dict:'
765 765
766 766 try:
767 767 # In PyPy, types.DictProxyType is dict, setting the dictproxy printer
768 # using dict.setdefault avoids overwritting the dict printer
768 # using dict.setdefault avoids overwriting the dict printer
769 769 _type_pprinters.setdefault(types.DictProxyType,
770 770 _dict_pprinter_factory('dict_proxy({', '})'))
771 771 _type_pprinters[types.ClassType] = _type_pprint
@@ -19,9 +19,9 b' def doctest_run():'
19 19 In [13]: run simplevars.py
20 20 x is: 1
21 21 """
22
22
23 23 def doctest_runvars():
24 """Test that variables defined in scripts get loaded correcly via %run.
24 """Test that variables defined in scripts get loaded correclty via %run.
25 25
26 26 In [13]: run simplevars.py
27 27 x is: 1
@@ -49,7 +49,7 b' def extract_vars(*names,**kw):'
49 49 """
50 50
51 51 depth = kw.get('depth',0)
52
52
53 53 callerNS = sys._getframe(depth+1).f_locals
54 54 return dict((k,callerNS[k]) for k in names)
55 55
@@ -58,7 +58,7 b' def extract_vars_above(*names):'
58 58 """Extract a set of variables by name from another frame.
59 59
60 60 Similar to extractVars(), but with a specified depth of 1, so that names
61 are exctracted exactly from above the caller.
61 are extracted exactly from above the caller.
62 62
63 63 This is simply a convenience function so that the very common case (for us)
64 64 of skipping exactly 1 frame doesn't have to construct a special dict for
@@ -93,4 +93,3 b' def extract_module_locals(depth=0):'
93 93 global_ns = f.f_globals
94 94 module = sys.modules[global_ns['__name__']]
95 95 return (module, f.f_locals)
96
General Comments 0
You need to be logged in to leave comments. Login now