#16275: Hom: introduce a check argument to simplify the unpickling detection 
logic
-------------------------------------+-------------------------------------
       Reporter:  nthiery            |        Owner:
           Type:  enhancement        |       Status:  new
       Priority:  major              |    Milestone:  sage-6.2
      Component:  categories         |   Resolution:
       Keywords:  homset, pickling   |    Merged in:
        Authors:  Nicolas M. ThiƩry  |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  
u/nthiery/hom__introduce_a_check_argument_to_simplify_the_unpickling_detection_logic|
  ae3ca8080a8412891722695d1e24e1dfe374d787
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by SimonKing):

 I have added it to the picklejar, but now I don't know how to post the
 change. It seems that the picklejar is not under version control.

 Anyway, I think we need to catch errors properly, and raise a more
 informative error. What happens with the pickle is this:
 {{{
 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/structure/sage_object.so in sage.structure.sage_object.load
 (sage/structure/sage_object.c:9774)()

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/structure/sage_object.so in sage.structure.sage_object.loads
 (sage/structure/sage_object.c:11522)()

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/categories/homset.pyc in Hom(X, Y, category, check)
     374                 raise TypeError("Argument category (= {}) must be
 a category.".format(category))
     375             for O in [X, Y]:
 --> 376                 if O not in category:
     377                     raise TypeError("{} is not in {}".format(O,
 category))
     378

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/categories/category.pyc in __contains__(self, x)
     722         """
     723         try:
 --> 724             c = x.category()
     725         except AttributeError:
     726             return False

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/modules/module.so in sage.modules.module.Module_old.category
 (sage/modules/module.c:1604)()

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/misc/classcall_metaclass.so in
 sage.misc.classcall_metaclass.ClasscallMetaclass.__call__
 (sage/misc/classcall_metaclass.c:1282)()

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/categories/modules.pyc in __classcall_private__(cls,
 base_ring, dispatch)
     106             if base_ring in _Fields:
     107                 return VectorSpaces(base_ring, check=False)
 --> 108         result = super(Modules, cls).__classcall__(cls, base_ring)
     109         result._reduction[2]['dispatch'] = False
     110         return result

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/categories/category.pyc in __classcall__(cls, *args,
 **options)
     462         if isinstance(cls, DynamicMetaclass):
     463             cls = cls.__base__
 --> 464         return super(Category, cls).__classcall__(cls, *args,
 **options)
     465
     466     def __init__(self, s=None):

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/misc/cachefunc.so in
 sage.misc.cachefunc.WeakCachedFunction.__call__
 (sage/misc/cachefunc.c:6486)()

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/structure/unique_representation.pyc in __classcall__(cls,
 *args, **options)
    1019             True
    1020         """
 -> 1021         instance = typecall(cls, *args, **options)
    1022         assert isinstance( instance, cls )
    1023         if instance.__class__.__reduce__ ==
 CachedRepresentation.__reduce__:

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/misc/classcall_metaclass.so in
 sage.misc.classcall_metaclass.typecall
 (sage/misc/classcall_metaclass.c:1665)()

 /home/king/Sage/git/sage/local/lib/python2.7/site-
 packages/sage/categories/category_types.pyc in __init__(self, base, name)
     324     def __init__(self, base, name=None):
     325         from sage.categories.rings import Rings
 --> 326         assert base in Rings(), "base must be a ring"
     327         Category_over_base.__init__(self, base, name)
     328

 <type 'str'>: (<type 'exceptions.AttributeError'>,
 AttributeError('ModularSymbolsAmbient_wt2_g0_with_category' object has no
 attribute '_HeckeModule_generic__level',))
 }}}
 So, Nicolas' nicely formatted error is not seen, and a rather mysterious
 error about a missing attribute appears.

 Again, my suggestion is to catch this error and see if it comes from
 incomplete initialisation.

--
Ticket URL: <http://trac.sagemath.org/ticket/16275#comment:12>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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 http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to