Amaury Forgeot d'Arc <amaur...@gmail.com> added the comment:

Agreed. There was a similar issue in python2.6 with list comprehensions.
The issue is that both threads run the code with the same globals dictionary, 
and top-level code use the same dict for locals and globals.

This is already fixed in 2.7 and 3.2, temporary variables are no more used.

Meanwhile, I can see two workarounds:
- Run the code in a python function; the _[1] variable will be local to the 
function, and distinct for each thread.
- Use PyRun_String(), and pass a different dictionary for each thread::

    PyObject *d, *v;
    d = PyDict_New();
    v = PyRun_String(command, Py_file_input, d, d);
    Py_XDECREF(v);
    Py_XDECREF(d);

But the 3.2 fix cannot be ported to 3.1: it needs a new opcode.

----------
nosy: +amaury.forgeotdarc
resolution:  -> out of date
status: open -> pending

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10393>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to