A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/098584.html below:

converting string to dict ?

converting string to dict ?Michael Hudson mwh21 at cam.ac.uk
Wed Apr 11 13:10:34 EDT 2001
"Andrew Dalke" <dalke at acm.org> writes:

> /F wrote:
> >>>> eval("{'name': 'Cleopatra'}", {"__builtins__": {}})
> >{'name': 'Cleopatra'}
> >
> >the __builtins__ stuff is optional, but provides some protection
> >from evil data providers:
> 
> Note that it isn't full protection.  Consider
> 
>   eval("[0] * (2 ** 31)")

Nah.

>>> eval("[0] * (2 ** 31)")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<string>", line 0, in ?
OverflowError: integer exponentiation
>>> eval("[0] * (2 ** 30)")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<string>", line 0, in ?
MemoryError

eval("[0] * (2 ** 25)") seems to be about right for my machine (not
that I let it finish).

Cheers,
M.

-- 
  Get out your salt shakers folks, this one's going to take more
  than one grain.                 -- Ator in an Ars Technica news item

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4