Changes between Version 1 and Version 2 of Ticket #14304, comment 30
- Timestamp:
- 01/10/14 07:45:52 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #14304, comment 30
v1 v2 2 2 > 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. 3 3 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.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 `except` blocks are executed. 5 5 6 6 If you want to be absolutely correct, every single allocation should be wrapped individually in `sig_on()`/`sig_off()`. Example for 2 allocations: