Hi,
I am posting again, for 5.3, the message I posted for 5.2
I am developing a sage package which relies on a C library. The C library
returns expressions (polynomials) as strings.
I am looking for 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 in releases 4.7 and 4.8. Other users told me it worked in
5.1.
Starting from 5.2, and now in 5.3, I am getting NameError(s) for the
variables which occur in the strings.
The same phenomenon is observed on at least two different platforms.
It seems that, in a compiled code, the eval function does not recognize
variables (the problem does not show up under the interpreter).
Did I miss a change of specification of eval ? Is this a bug ?
Or am I using the wrong method ?
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:
boulier@ciney:~$
tmp/sage-5.3-linux-64bit-ubuntu_10.04.4_lts-x86_64-Linux/sage
----------------------------------------------------------------------
| Sage Version 5.3, Release Date: 2012-09-08 |
| 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/<ipython console> in <module>()
/home/boulier/tmp/sage-5.3-linux-64bit-ubuntu_10.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.3-linux-64bit-ubuntu_10.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
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.