laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/41672?usp=email )

Change subject: ts_51_011.EF_SMSP: Use integer division during encode
......................................................................

ts_51_011.EF_SMSP: Use integer division during encode

Otherwise we might compute float values and fail encoding like this:

> construct.core.FormatFieldError: Error in path (building) -> tp_vp_minutes
> struct '>B' error during building, given value 169.0

Change-Id: I989669434c7ddee9595ee81a0822f9966907a844
---
M pySim/ts_51_011.py
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, approved




diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py
index e46a3e0..92b4486 100644
--- a/pySim/ts_51_011.py
+++ b/pySim/ts_51_011.py
@@ -267,11 +267,11 @@
                 raise ValueError
         def _encode(self, obj, context, path):
             if obj <= 12*60:
-                return obj/5 - 1
+                return obj // 5 - 1
             elif obj <= 24*60:
                 return 143 + ((obj - (12 * 60)) // 30)
             elif obj <= 30 * 24 * 60:
-                return 166 + (obj / (24 * 60))
+                return 166 + (obj // (24 * 60))
             elif obj <= 63 * 7 * 24 * 60:
                 return 192 + (obj // (7 * 24 * 60))
             else:

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41672?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I989669434c7ddee9595ee81a0822f9966907a844
Gerrit-Change-Number: 41672
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>

Reply via email to