[issue9136] RuntimeError when profiling Decimal

Mark Dickinson report at bugs.python.org
Thu Jul 1 11:41:10 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

Okay, I can reproduce by adding a 'time.sleep(0.01)' delay into the body of the 'for name, val in locals().items():' loop.  I then get (with py3k):

dickinsm at alberti:~/Source/py3k> ./python
Python 3.2a0 (py3k:82413M, Jul  1 2010, 10:21:02)
[GCC 4.2.1 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import decimal, profile
>>> def show_bug(): decimal.Decimal(1.2)**(-2**31)
...
>>> profile.run('show_bug()')
Traceback (most recent call last):
  File "/home/dickinsm/Source/py3k/Lib/decimal.py", line 447, in getcontext
    return _local.__decimal_context__
AttributeError: '_thread._local' object has no attribute '__decimal_context__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dickinsm/Source/py3k/Lib/profile.py", line 70, in run
    prof = prof.run(statement)
  File "/home/dickinsm/Source/py3k/Lib/profile.py", line 442, in run
    return self.runctx(cmd, dict, dict)
  File "/home/dickinsm/Source/py3k/Lib/profile.py", line 448, in runctx
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "<stdin>", line 1, in show_bug
  File "/home/dickinsm/Source/py3k/Lib/decimal.py", line 2222, in __pow__
    context = getcontext()
  File "/home/dickinsm/Source/py3k/Lib/decimal.py", line 449, in getcontext
    context = Context()
  File "/home/dickinsm/Source/py3k/Lib/decimal.py", line 3822, in __init__
    for name, val in locals().items():
RuntimeError: dictionary changed size during iteration

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9136>
_______________________________________


More information about the Python-bugs-list mailing list