Skip to content

Commit

Permalink
Fix regression in embed() from pull-request ipython#2096.
Browse files Browse the repository at this point in the history
With certain sets of arguments `compile_flags` might be left as `None`. This
caused IPython to internally raise a TypeError when it tried to do a
bitwise or between `shell.compile.flags` and `PyCF_ONLY_AST` in
`CachingCompiler.ast_parse`.

The regression was introduced in:
  b70ac12 embed(): Default to the future compile flags of the calling frame.
  • Loading branch information
bfroehle committed Aug 3, 2012
1 parent dfcd243 commit 89b4dd7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions IPython/frontend/terminal/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ class DummyMod(object):
module.__dict__ = global_ns

# Get locals and globals from caller
if (local_ns is None or module is None) and self.default_user_namespaces:
if ((local_ns is None or module is None or compile_flags is None)
and self.default_user_namespaces):
call_frame = sys._getframe(stack_depth).f_back

if local_ns is None:
Expand Down Expand Up @@ -233,7 +234,8 @@ class DummyMod(object):
self.init_user_ns()

# Compiler flags
self.compile.flags = compile_flags
if compile_flags is not None:
self.compile.flags = compile_flags

# Patch for global embedding to make sure that things don't overwrite
# user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
Expand Down

0 comments on commit 89b4dd7

Please sign in to comment.