• Kirill Smelkov's avatar
    ZBigArray: Compatibility fix to read arrays from DB that were previously saved without order info · 2ca0f076
    Kirill Smelkov authored
    Commit ab9ca2df (bigarray: Add support for FORTRAN ordering) added
    ability to define array order, but there I made a mistake of not caring
    about how previously-saved to DB arrays would be read back.
    
    The thing is BigArray gained new data member ._order which is
    automatically saved to DB thanks to ZBigArray inheriting from
    Persistent; on load-from-db path we just read object state from DB,
    which for ZBigArray is dict, and restore object attributes from it.
    
    But for previously-saved data, obviously, there is no 'order' entry and thus
    this way restored objects are restored not in full to current code expectations
    and it can boom e.g. this way:
    
        zarray.resize((new_one,old_shape[1]))
      Module wendelin.bigarray, line 190, in resize
        self._init0(new_shape, self.dtype, order=self._order)
      AttributeError: 'ZBigArray' object has no attribute '_order'
    
    Solution to fix is: on restore-from-DB path, see if a data member is not
    present on restored object, and if it has default value in BigArray set it to
    that.
    
    ( code to get function defaults is from
      http://stackoverflow.com/questions/12627118/get-a-function-arguments-default-value )
    
    /cc @Tyagov, @klaus
    2ca0f076
Name
Last commit
Last update
..
tests Loading commit data...
__init__.py Loading commit data...
array_zodb.py Loading commit data...