Skip to content

Commit

Permalink
Merge pull request #111 from fplll/int-type-bugfix
Browse files Browse the repository at this point in the history
do not ignore exceptions from check_{int/float}_type
  • Loading branch information
lducas committed Dec 19, 2017
2 parents b1004c2 + e0d6677 commit 04d9283
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/fpylll/util.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ from .fplll.fplll cimport FloatType, Z_NR, PrunerMetric, IntType
from .fplll.fplll cimport BKZParam as BKZParam_c
from .fplll.fplll cimport PrunerMetric

cdef FloatType check_float_type(object float_type)
cdef IntType check_int_type(object int_type)
cdef object check_float_type(object float_type)
cdef object check_int_type(object int_type)
cdef int preprocess_indices(int &i, int &j, int m, int n) except -1
cdef int check_precision(int precision) except -1
cdef int check_eta(float eta) except -1
Expand Down
8 changes: 5 additions & 3 deletions src/fpylll/util.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ cdef extern from "util_helper.h":
float_aliases = {'d': 'double',
'ld': 'long double'}

cdef FloatType check_float_type(object float_type):
# We return `object` to permit exceptions

cdef object check_float_type(object float_type):

float_type = float_aliases.get(float_type, float_type)

Expand All @@ -50,7 +52,7 @@ cdef FloatType check_float_type(object float_type):

raise ValueError("Float type '%s' unknown." % float_type)

cdef IntType check_int_type(object int_type):
cdef object check_int_type(object int_type):

if int_type == "default" or int_type is None:
return ZT_MPZ
Expand All @@ -59,7 +61,7 @@ cdef IntType check_int_type(object int_type):
if int_type == "long":
return ZT_LONG

raise ValueError("Float type '%s' unknown." % int_type)
raise ValueError("Integer type '%s' unknown." % int_type)

cdef PrunerMetric check_pruner_metric(object metric):
if metric == "probability" or metric == PRUNER_METRIC_PROBABILITY_OF_SHORTEST:
Expand Down

0 comments on commit 04d9283

Please sign in to comment.