Deprecated function alias in Cython file?

97 views
Skip to first unread message

Rob Beezer

unread,
Dec 19, 2010, 4:42:25 PM12/19/10
to sage-devel
I'm trying to use deprecated_function_alias() from sage/misc/misc.py
in a *.pyx file, specifically, matrix2.pyx.

Should this be possible? I don't see anywhere in the source where
this is used in a *.pyx file.

Sage rebuilds fine, but complains on startup while importing. Tail of
the errors reported follows below. Maybe I just need to do the
deprecation the old-fashioned way, but I'd prefer to use the
standardized function designed for this purpose.

Rob

~~~~~~~~~~~~~~~~~~~~~~~~~~~
(Line 46674 of the C file corresponds to the following (new) line in
matrix2.pyx:
adjoint = deprecated_function_alias(adjugate, 'Sage Version
4.6.2')
)

/sage/dev/local/bin/matrix2.pyx in init sage.matrix.matrix2 (sage/
matrix/matrix2.c:46674)()

/sage/dev/local/lib/python2.6/site-packages/sage/misc/misc.pyc in
deprecated_function_alias(func, version)
2103 - Florent Hivert (2009-11-23), with the help of Mike
Hansen.
2104 """
-> 2105 return DeprecatedFunctionAlias(func, version)
2106
2107 def deprecated_callable_import(module_name, globs, locs,
fromlist, message=None):

/sage/dev/local/lib/python2.6/site-packages/sage/misc/misc.pyc in
__init__(self, func, version)
2003 """
2004 self.__doc__ = func.__doc__
-> 2005 self.__dict__.update(func.__dict__)
2006 self.func = func
2007 self.version = version

AttributeError: 'method_descriptor' object has no attribute '__dict__'

David Roe

unread,
Dec 19, 2010, 6:43:26 PM12/19/10
to sage-...@googlegroups.com
Cython classes by default don't have a __dict__ (which is why you're
seeing the error below). Maybe the deprecated_function_alias should
be modified to allow for deprecated aliases in cython classes.
David

> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>

Florent Hivert

unread,
Jan 22, 2011, 6:35:24 AM1/22/11
to sage-...@googlegroups.com
Hi Rob

On Sun, Dec 19, 2010 at 06:43:26PM -0500, David Roe wrote:
> Cython classes by default don't have a __dict__ (which is why you're
> seeing the error below). Maybe the deprecated_function_alias should
> be modified to allow for deprecated aliases in cython classes.
> David
>
> On Sun, Dec 19, 2010 at 16:42, Rob Beezer <goo...@beezer.cotse.net> wrote:
> > I'm trying to use deprecated_function_alias() from sage/misc/misc.py
> > in a *.pyx file, specifically, matrix2.pyx.
> >
> > Should this be possible? �I don't see anywhere in the source where
> > this is used in a *.pyx file.
> >
> > Sage rebuilds fine, but complains on startup while importing. �Tail of
> > the errors reported follows below. �Maybe I just need to do the
> > deprecation the old-fashioned way, but I'd prefer to use the
> > standardized function designed for this purpose.

I'm the culprit.

> > � 2004 � � � � self.__doc__ = func.__doc__


> > -> 2005 � � � � self.__dict__.update(func.__dict__)
> > � 2006 � � � � self.func = func

The offending line should probably be guarded by a
try:
...
except:
or even removed: it is not tested and I don't see any use of it in sage. Is
there one ?

Cheersm

Florent

Reply all
Reply to author
Forward
0 new messages