##// END OF EJS Templates
Revert 3.7 AST fix...
Matthias Bussonnier -
Show More
@@ -22,7 +22,7 b' script:'
22 - cd /tmp && iptest --coverage xml && cd -
22 - cd /tmp && iptest --coverage xml && cd -
23 # On the latest Python only, make sure that the docs build.
23 # On the latest Python only, make sure that the docs build.
24 - |
24 - |
25 if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then
25 if [[ "$TRAVIS_PYTHON_VERSION" == "3.7" ]]; then
26 pip install -r docs/requirements.txt
26 pip install -r docs/requirements.txt
27 python tools/fixup_whats_new_pr.py
27 python tools/fixup_whats_new_pr.py
28 make -C docs/ html SPHINXOPTS="-W"
28 make -C docs/ html SPHINXOPTS="-W"
@@ -35,6 +35,7 b' after_success:'
35 matrix:
35 matrix:
36 include:
36 include:
37 - { python: "3.7", dist: xenial, sudo: true }
37 - { python: "3.7", dist: xenial, sudo: true }
38 - { python: "3.7-dev", dist: xenial, sudo: true }
38 - { python: "nightly", dist: xenial, sudo: true }
39 - { python: "nightly", dist: xenial, sudo: true }
39 allow_failures:
40 allow_failures:
40 - python: nightly
41 - python: nightly
@@ -92,30 +92,13 b' class CachingCompiler(codeop.Compile):'
92 linecache.checkcache = check_linecache_ipython
92 linecache.checkcache = check_linecache_ipython
93
93
94
94
95 def _fix_module_ds(self, module):
96 """
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
99 `docstring` attribute of the `Module` ast node.
100
101 This breaks IPython, as if this string is the only expression, IPython
102 will not return it as the result of the current cell.
103 """
104 from ast import Str, Expr, Module, fix_missing_locations
105 docstring = getattr(module, 'docstring', None)
106 if not docstring:
107 return module
108 new_body=[Expr(Str(docstring, lineno=1, col_offset=0), lineno=1, col_offset=0)]
109 new_body.extend(module.body)
110 return fix_missing_locations(Module(new_body))
111
112 def ast_parse(self, source, filename='<unknown>', symbol='exec'):
95 def ast_parse(self, source, filename='<unknown>', symbol='exec'):
113 """Parse code to an AST with the current compiler flags active.
96 """Parse code to an AST with the current compiler flags active.
114
97
115 Arguments are exactly the same as ast.parse (in the standard library),
98 Arguments are exactly the same as ast.parse (in the standard library),
116 and are passed to the built-in compile function."""
99 and are passed to the built-in compile function."""
117 return self._fix_module_ds(compile(source, filename, symbol, self.flags | PyCF_ONLY_AST, 1))
100 return compile(source, filename, symbol, self.flags | PyCF_ONLY_AST, 1)
118
101
119 def reset_compiler_flags(self):
102 def reset_compiler_flags(self):
120 """Reset compiler flags to default state."""
103 """Reset compiler flags to default state."""
121 # This value is copied from codeop.Compile.__init__, so if that ever
104 # This value is copied from codeop.Compile.__init__, so if that ever
General Comments 0
You need to be logged in to leave comments. Login now