paster shell and new ipython0.10 problem

29 views
Skip to first unread message

Martin Stein

unread,
Aug 13, 2009, 8:59:22 AM8/13/09
to pylons-...@googlegroups.com
Hi all,

On August 6th a new version of ipython (0.10) was released. When I use paster shell with that version, I get a strange error:

In [1]: for i in range(4):
<ERROR: 'dict' object has no attribute 'len'>

It seems that for-iteration over lists is broken. In normal ipython (without paster shell) it works; when I go back to ipython0.9.1 it works in paster shell, too.

Can anybody reproduce this problem or has maybe found a solution?

Thanks,
Martin

Gael Pasgrimaud

unread,
Aug 13, 2009, 12:22:40 PM8/13/09
to pylons-...@googlegroups.com
Same problem here. But [i for i in range(3)] works

> Thanks,
> Martin
>
> >
>

Gael Pasgrimaud

unread,
Aug 13, 2009, 12:38:17 PM8/13/09
to pylons-...@googlegroups.com
On Thu, Aug 13, 2009 at 6:22 PM, Gael Pasgrimaud<ga...@gawel.org> wrote:
> On Thu, Aug 13, 2009 at 2:59 PM, Martin Stein<mstei...@googlemail.com> wrote:
>> Hi all,
>>
>> On August 6th a new version of ipython (0.10) was released. When I use
>> paster shell with that version, I get a strange error:
>>
>> In [1]: for i in range(4):
>> <ERROR: 'dict' object has no attribute 'len'>
>>
>> It seems that for-iteration over lists is broken. In normal ipython (without
>> paster shell) it works; when I go back to ipython0.9.1 it works in paster
>> shell, too.
>>

Seems thats all iterations are broken. if 4 in range(10): also failed.

I've also write a small script to see if this came from the embed shell.

# -*- coding: utf-8 -*-
from IPython.Shell import IPShellEmbed

shell = IPShellEmbed(argv=[])
shell.set_banner(shell.IP.BANNER)
shell(local_ns={}, global_ns={})

And well, no. This work fine. Seems it's related to the pylons command.

Gael Pasgrimaud

unread,
Aug 13, 2009, 1:02:29 PM8/13/09
to pylons-...@googlegroups.com, pylons...@googlegroups.com
Seems that the exec statement add a __builtins__ key to the locs
dictionnary and IPython don't like it.

Adding locs.pop('__builtins__') before shell initialization fix the problem:

In pylons/command.py at line ~=512:

shell.set_banner(shell.IP.BANNER + '\n\n' + banner)
if '__builtins__' in locs:
del locs['__builtins__']
try:
shell(local_ns=locs, global_ns={})
finally:
paste.registry.restorer.restoration_end()

This don't break the command with IPython 0.9
Reply all
Reply to author
Forward
0 new messages