Changes between Initial Version and Version 7 of Ticket #28444


Ignore:
Timestamp:
09/02/19 18:28:58 (2 years ago)
Author:
SimonKing
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28444

    • Property Keywords meataxe added
  • Ticket #28444 – Description

    initial v7  
    1 The following happens in Sage with Python-3, when trying to unpickle the attached file `State.sobj`:
     1EDIT: I replaced the original ticket description by something that I wrote in a comment, because now I have a much smaller example, and moreover pickles of the same object created with Python-3 and with Python-2, so that one can compare.
     2
     3
     4The following examples require the optional meataxe package, but I am not sure yet if meataxe is to blame or Python-3 (I hope it is the former, because I guess it would be more easy to fix).
     5
     6attachment:Py2.sobj​ and attachment:Py3.sobj​ result in the following behaviour in Python-3
    27{{{
    3 sage: class unpickle_old_mtx:
    4 ....:     def __call__(self, *args, **kwds):
    5 ....:         return None
    6 ....:     
    7 sage: register_unpickle_override('pGroupCohomology.mtx', 'MTX_unpickle_class', unpickle_old_mtx)
    8 sage: X = load('/home/king/Projekte/coho/tests/State.sobj')
     8sage: load('/home/king/Projekte/coho/tests/Py2.sobj')
    99---------------------------------------------------------------------------
    1010UnicodeDecodeError                        Traceback (most recent call last)
    11 <ipython-input-3-74e7e91f9969> in <module>()
    12 ----> 1 X = load('/home/king/Projekte/coho/tests/State.sobj')
     11<ipython-input-3-5705b555470a> in <module>()
     12----> 1 load('/home/king/Projekte/coho/tests/Py2.sobj')
    1313
    1414/home/king/Sage/git/py3/local/lib/python3.7/site-packages/sage/misc/persist.pyx in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2824)()
     
    3434
    3535UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0: ordinal not in range(128)
     36sage: load('/home/king/Projekte/coho/tests/Py3.sobj')
     37[1 0 0 0 0 0 0 0]
     38[0 0 0 1 1 1 1 1]
    3639}}}
    37 
    38 Doing the same in Sage-with-Python-2, one gets
     40and in Python-2
    3941{{{
    40 sage: class unpickle_old_mtx:
    41 ....:     def __call__(self, *args, **kwds):
    42 ....:         return None
    43 ....:     
    44 sage: register_unpickle_override('pGroupCohomology.mtx', 'MTX_unpickle_class', unpickle_old_mtx)
    45 sage: X = load('/home/king/Projekte/coho/tests/State.sobj')
    46 sage: X
    47 ([[1,
    48    [(2, 1),
    49     [None,
    50      [None,
    51       '/home/king/SPKG/database/8gp3/sgp/8gp3sg1_1',
    52       '/home/king/SPKG/database/8gp3/sgp/8gp3sg1_2']]]],
    53   [2,
    54    [(4, 2),
    55     [None,
    56      [None,
    57       '/home/king/SPKG/database/8gp3/sgp/8gp3sg2_1',
    58       '/home/king/SPKG/database/8gp3/sgp/8gp3sg2_2']]]],
    59   [3,
    60    [(4, 2),
    61     [None,
    62      [None,
    63       '/home/king/SPKG/database/8gp3/sgp/8gp3sg3_1',
    64       '/home/king/SPKG/database/8gp3/sgp/8gp3sg3_2']]]]],
    65  [2, 1, 1],
    66  1,
    67  1,
    68  '8gp3/',
    69  ['b_1_0*b_1_1'],
    70  '8gp3/dat/',
    71  [((4, 2), '/home/king/.sage/pGroupCohomology/db/4gp2/H4gp2'),
    72   ((2, 1), '/home/king/.sage/pGroupCohomology/db/2gp1/H2gp1')],
    73  '8gp3/dat/',
    74  [],
    75  '8gp3/sgp/',
    76  2,
    77  [2, 3],
    78  [2, 2],
    79  2,
    80  2,
    81  ['b_1_0*b_1_1'],
    82  [[2, 'c_2_2', None, 1, 0],
    83   [1, 'b_1_0', None, 0, 0],
    84   [1, 'b_1_1', None, 0, 0]],
    85  [[0, [['1', ['1']]]],
    86   [1, [['b_1_0', ['b_1_0']], ['b_1_1', ['b_1_1']]]],
    87   [2,
    88    [['c_2_2', ['c_2_2']],
    89     ['b_1_0', ['b_1_0^2']],
    90     ['b_1_1', ['b_1_0*b_1_1', 'b_1_1^2']]]]],
    91  {},
    92  0.24,
    93  True,
    94  'Monomials',
    95  2,
    96  None,
    97  '',
    98  0,
    99  '8gp3',
    100  '8gp3/dat/R8gp3.sobj',
    101  1,
    102  ['0'],
    103  ['b_1_0 + b_1_1'],
    104  None,
    105  [('_max_module_deg', 0),
    106   ('sgpDickson', [((4, 2), [[1, 'c_1_1', None]])]),
    107   ('useFactorization', True),
    108   ('useElimination', False),
    109   ('GroupDescr', 'Dihedral group of order 8'),
    110   ('_key', ((8, 3), '/home/king/SPKG/database/8gp3/dat/State')),
    111   ('auto', 4),
    112   ('Restriction_2', ['c_1_0*c_1_1+c_1_0^2', 'c_1_1', '0']),
    113   ('GroupName', 'D8'),
    114   ('DicksonExp', 3),
    115   ('_parameters_do_exist', True),
    116   ('KeepBases', None),
    117   ('completeGroebner', True),
    118   ('_SymondsTestdata', ['c_2_2', 'b_1_1', 'b_1_0']),
    119   ('_parameters_for_criterion', ['c_2_2', 'b_1_1', 'b_1_0']),
    120   ('root', '/home/king/SPKG/database/'),
    121   ('Restriction_3', ['c_1_0*c_1_1+c_1_0^2', '0', 'c_1_1']),
    122   ('_method', 'Symonds')],
    123  [(('dependent_parameters',), [['c_2_2', 'b_1_1', 'b_1_0'], 2])])
     42sage: load('/home/king/Projekte/coho/tests/Py2.sobj')
     43[1 0 0 0 0 0 0 0]
     44[0 0 0 1 1 1 1 1]
     45sage: load('/home/king/Projekte/coho/tests/Py3.sobj')
     46[1 0 0 0 0 0 0 0]
     47[0 0 0 1 1 1 1 1]
     48sage: __ == _
     49True
    12450}}}
    125 
    126 I believe that a backwards incompatible change of pickling is a blocker for Python-3 support.
     51So, the Python-3 pickle can be unpickled in Python-2, but not the other way around. What is the problem?