@@ -906,7 +906,7 @@ def create_inner(self, **propvalues):
906906 self .classname , key ))
907907
908908 if value is not None and isinstance (prop , hyperdb .Link ):
909- if type (value ) != type ( '' ):
909+ if not isinstance (value , str ):
910910 raise ValueError ('link value must be String' )
911911 link_class = self .properties [key ].classname
912912 # if it isn't a number, it's a key
@@ -930,15 +930,15 @@ def create_inner(self, **propvalues):
930930 elif isinstance (prop , hyperdb .Multilink ):
931931 if value is None :
932932 value = []
933- if not hasattr (value , '__iter__' ) or type (value ) == type ( '' ):
933+ if not hasattr (value , '__iter__' ) or isinstance (value , str ):
934934 raise TypeError (
935935 'new property "%s" not an iterable of ids' % key )
936936
937937 # clean up and validate the list of links
938938 link_class = self .properties [key ].classname
939939 l = []
940940 for entry in value :
941- if type (entry ) != type ( '' ):
941+ if not isinstance (entry , str ):
942942 raise ValueError ('"%s" multilink value (%r) '
943943 'must contain Strings' % (key , value ))
944944 # if it isn't a number, it's a key
@@ -965,7 +965,7 @@ def create_inner(self, **propvalues):
965965 (self .classname , newid , key ))
966966
967967 elif isinstance (prop , hyperdb .String ):
968- if type (value ) != type ( '' ) and type ( value ) != type ( u'' ):
968+ if not isinstance (value , ( str , unicode ) ):
969969 raise TypeError ('new property "%s" not a string' % key )
970970 if prop .indexme :
971971 self .db .indexer .add_text (
@@ -1256,14 +1256,14 @@ def set_inner(self, nodeid, **propvalues):
12561256 elif isinstance (prop , hyperdb .Multilink ):
12571257 if value is None :
12581258 value = []
1259- if not hasattr (value , '__iter__' ) or type (value ) == type ( '' ):
1259+ if not hasattr (value , '__iter__' ) or isinstance (value , str ):
12601260 raise TypeError ('new property "%s" not an iterable of'
12611261 ' ids' % propname )
12621262 link_class = self .properties [propname ].classname
12631263 l = []
12641264 for entry in value :
12651265 # if it isn't a number, it's a key
1266- if type (entry ) != type ( '' ):
1266+ if not isinstance (entry , str ):
12671267 raise ValueError ('new property "%s" link value '
12681268 'must be a string' % propname )
12691269 if not num_re .match (entry ):
0 commit comments