On Monday, August 28, 2017 at 3:45:23 AM UTC-7, Nicolas M. Thiéry wrote:
>
>         sage: from __future__ import unicode_literals 
>         sage: QQ['x,y'] 
>         ... 
>         ValueError: variable name 'x,y' is not alphanumeric 
>

PolynomialRing(QQ,'x,y') 

and

PolynomialRing(QQ,u'x,y') 

both work just fine, whereas

PolynomialRing(QQ,name="x,y")

does not. So I expect that QQ[...] does some analysis on its argument to 
decide if it needs to pass a "name" or a "names" argument. However, finding 
out where that code might live seems to be nigh impossible thanks to the 
category stuff:

sage: QQ.__getitem__??
       ...
        try:
            meth = super(Parent, self).__getitem__
        except AttributeError:
            # needed when self is a Cython object
            try:
                meth = self.getattr_from_category('__getitem__')
            except AttributeError:
                return self.list()[n]
        return meth(n)

so finding where this code needs to be made more robust for str/unicode is 
very difficult.
MAINTAINABILITY REQUEST: make methods better introspectable in the face of 
the category mro extensions.

It might be in sage.cagtegories.rings.py:999

            def normalize_arg(arg):
                if isinstance(arg, (tuple, list)):
                    # Allowing arbitrary iterables would create confusion, 
but we
                    # may want to support a few more.
                    return tuple(arg)
                elif isinstance(arg, str):
                    return tuple(arg.split(','))
                else:
                    return (arg,)

We need a typecheck there that handles str and unicode the same.

(incidentally, because str == unicode in Py3, this issue would not occur in 
Py3)

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to