• Kirill Smelkov's avatar
    bigarray: Translate OverflowError when computing slice indices to MemoryError · fcbb26e6
    Kirill Smelkov authored
    OverflowError when computing slice indices practically means we'll
    cannot allocate so much address space at next step:
    
        In [1]: s = slice(None)
    
        In [2]: s.indices(1<<62)
        Out[2]: (0, 4611686018427387904, 1)
    
        In [3]: s.indices(1<<63)
        ---------------------------------------------------------------------------
        OverflowError                             Traceback (most recent call last)
        <ipython-input-4-5aa549641bc6> in <module>()
        ----> 1 s.indices(1<<63)
    
        OverflowError: cannot fit 'long' into an index-sized integer
    
    So translate this OverflowError into MemoryError (preserving message
    details), because we'll need such "no so much address space" cases to
    show up as MemoryError in a sooner patch.
    fcbb26e6
__init__.py 12.5 KB