From ec98b0cde8e67392e08e5417bf3dc059c68ed52c Mon Sep 17 00:00:00 2001 From: Martinez Date: Wed, 10 Jun 2015 19:58:02 +0200 Subject: [PATCH] fix over.core.types.map.__init__ --- core/cython_types.pyx | 8 ++++---- core/python_types.py | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/cython_types.pyx b/core/cython_types.pyx index a0fe419..a881016 100644 --- a/core/cython_types.pyx +++ b/core/cython_types.pyx @@ -41,13 +41,13 @@ class map: Initialize the map. The source is a sequence of (key, value) tuples. - - TODO fixme bug - >>> map(((1, 2, 3, 4), ('a', 'b', 'c', 'd'))) ''' if source: - self.keys, self.vals = zip(*source) + if len(source[0]) == len(source[1]): + self.keys, self.vals = source + else: + raise ValueError('over.core.types.map initialized with two sequences of different lengths') else: self.keys = [] self.vals = [] diff --git a/core/python_types.py b/core/python_types.py index 3fdd7ed..2a4cdeb 100644 --- a/core/python_types.py +++ b/core/python_types.py @@ -41,15 +41,13 @@ class map: Initialize the map. The source is a sequence of (key, value) tuples. - - TODO fixme bug - >>> map(((1, 2, 3, 4), ('a', 'b', 'c', 'd'))) ''' - #print(repr(source)) - if source: - self.keys, self.vals = zip(*source) + if len(source[0]) == len(source[1]): + self.keys, self.vals = source + else: + raise ValueError('over.core.types.map initialized with two sequences of different lengths') else: self.keys = [] self.vals = []