Changes between Version 1 and Version 2 of Ticket #14304, comment 30


Ignore:
Timestamp:
01/10/14 07:45:52 (6 years ago)
Author:
jdemeyer
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #14304, comment 30

    v1 v2  
    22> So, does anyone have suggestions on how to rewrite the ugly nested try blocks in `PowComputer_flint_unram.__cinit__`?  Julian and I couldn't think of a better way to do it that would never have a memory leak or a double free.
    33
    4 I had a look at the code and the current code actually is never going to work. The C-level functions like `fmpz_poly_init` and `mpz_init` never raise exceptions. So, the `try`/`except` is pointless. As far as I can tell, there are two kinds of exceptions which can happen: a `MemoryError` in MPIR or a `KeyboardInterrupt`. In both cases, the exception will be raised by `sig_on()` and none of the `finally` blocks are executed.
     4I had a look at the code and the current code actually is never going to work. The C-level functions like `fmpz_poly_init` and `mpz_init` never raise exceptions. So, the `try`/`except` is pointless. As far as I can tell, there are two kinds of exceptions which can happen: a `MemoryError` in MPIR or a `KeyboardInterrupt`. In both cases, the exception will be raised by `sig_on()` and none of the `except` blocks are executed.
    55
    66If you want to be absolutely correct, every single allocation should be wrapped individually in `sig_on()`/`sig_off()`. Example for 2 allocations: