| 292 | # If the '__index__' method raises a type error, then |
| 293 | # '__int__' should be used with a deprecation warning. |
| 294 | class BadIndex(object): |
| 295 | def __index__(self): |
| 296 | raise TypeError |
| 297 | |
| 298 | def __int__(self): |
| 299 | return 42 |
| 300 | |
| 301 | self.assertRaises((TypeError, struct.error), |
| 302 | struct.pack, self.format, |