Hi,
I am developing a sage package which relies on a C library. The C library
returns expressions (polynomials) as strings.
I am looking to a simple way to convert these strings as Sage objects.
So far, I have been using expressions such as:
eval (preparse (the_string))
It used to work up to release 5.1. Starting from 5.2, I am getting
NameError(s) for the variables which occur in the strings.
Another user, on another platform, observed the same phenomenon.
It seems that, in a compiled code, the eval function does not recognize
variables (the problem does not show up under the interpreter).
Here is a simplified function which produces the error:
def toto (self, list L):
cdef bytes L_as_string
cdef list eqns
L_as_string = bytes(L)
eqns = eval (L_as_string)
return eqns
At runtime:
The Cython code of DifferentialAlgebra is installed in:
/home/boulier/tmp/sage-5.2-linux-64bit-ubuntu_8.04.4_lts-x86_64-Linux/devel/sage-blad/sage/libs/blad
boulier@ciney:~/tmp/sage-5.2-linux-64bit-ubuntu_8.04.4_lts-x86_64-Linux$
~/tmp/sage-5.2-linux-64bit-ubuntu_8.04.4_lts-x86_64-Linux/sage
----------------------------------------------------------------------
| Sage Version 5.2, Release Date: 2012-07-25 |
| Type "notebook()" for the browser-based notebook interface. |
| Type "help()" for help. |
----------------------------------------------------------------------
Loading Sage library. Current Mercurial branch is: blad
sage: from sage.libs.blad.DifferentialAlgebra import DifferentialRing
sage: a,b = var ('a,b')
sage: y = function ('y')
sage: R = DifferentialRing (derivations = [a,b], blocks = [y])
sage: R.toto ([a])
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/home/boulier/tmp/sage-5.2-linux-64bit-ubuntu_8.04.4_lts-x86_64-Linux/<ipython
console> in <module>()
/home/boulier/tmp/sage-5.2-linux-64bit-ubuntu_8.04.4_lts-x86_64-Linux/local/lib/python2.7/site-packages/sage/libs/blad/DifferentialAlgebra.so
in sage.libs.blad.DifferentialAlgebra.DifferentialRing.toto
(sage/libs/blad/DifferentialAlgebra.c:8999)()
/home/boulier/tmp/sage-5.2-linux-64bit-ubuntu_8.04.4_lts-x86_64-Linux/local/lib/python2.7/site-packages/sage/libs/blad/DifferentialAlgebra.so
in <module>()
NameError: name 'a' is not defined
Did I miss a change of specification of eval ? Is this a bug ?
All the best,
François
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/sage-devel?hl=en.