@@ -264,7 +264,24 @@ def attributeRoundTrip(self, file_ending):
264264 self .assertEqual (series .get_attribute ("char" ), "c" )
265265 self .assertEqual (series .get_attribute ("pystring" ), "howdy!" )
266266 self .assertEqual (series .get_attribute ("pystring2" ), "howdy, too!" )
267- self .assertEqual (bytes (series .get_attribute ("pystring3" )),
267+ if file_ending == 'h5' :
268+ # A byte string b"hello" is always (really?) a vector of unsigned
269+ # chars.
270+ # HDF5 does not distinguish a platform char type, only explicitly
271+ # signed or unsigned chars. Depending on the signed-ness of char
272+ # on the current platform, the unsigned char from the byte string
273+ # might then be interpreted as a char, not as an unsigned char.
274+ # This means that the roundtrip might not work on platforms with
275+ # unsigned char.
276+ try :
277+ as_bytes = bytes (series .get_attribute ("pystring3" ))
278+ self .assertEqual (as_bytes , b"howdy, again!" )
279+ except TypeError :
280+ self .assertEqual (
281+ series .get_attribute ("pystring3" ),
282+ [c for c in "howdy, again!" ])
283+ else :
284+ self .assertEqual (bytes (series .get_attribute ("pystring3" )),
268285 b"howdy, again!" )
269286 self .assertEqual (series .get_attribute ("pyint" ), 13 )
270287 self .assertAlmostEqual (series .get_attribute ("pyfloat" ), 3.1416 )
0 commit comments