summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2019-08-16 13:21:04 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2019-08-16 13:21:04 -0400
commit2e58957f9acb5a1c44bc91b827d440851cd5857e (patch)
tree91a56cb04dd3b9bb30a2cb71d24c7de5e5821189
parent6f1c642c1b76c32997a95b0d9dd70abfe16e9ee6 (diff)
downloadpyisda-2e58957f9acb5a1c44bc91b827d440851cd5857e.tar.gz
prevent segfault
-rw-r--r--pyisda/credit_index.pyx4
1 files changed, 3 insertions, 1 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index b59e19c..31044b9 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -89,7 +89,9 @@ cdef class CurveList:
for i in range(self._weights.size()):
self._weights[i] /= total_weight
- def __getitem__(self, tuple name):
+ def __getitem__(self, tuple name not None):
+ if len(name) != 3:
+ raise TypeError("`name` needs to be a string, Seniority, DocClause triplet")
cdef:
string ticker_cpp = name[0]
CurveName.Seniority seniority = <CurveName.Seniority>(<int>name[1])