Hye-Shik Chang wrote: > On Thu, Jun 03, 2004 at 03:18:47PM +0200, Walter D?rwald wrote: > >> [...] >>Yes, but UserString.UserString can be used to wrap both str and >>unicode objects. > > Aah. Sorry. I've overlooked extensive use of UserString. :) > > Could you review my patch?: > http://people.freebsd.org/~perky/userstring-width.diff I don't think it's necessary to define iswide() and width() only when self.data is a unicode object (in fact, self.data might change from str to unicode during the lifetime of the UserString object). Simply define # the following methods are defined for unicode objects only: def iswide(self): return self.data.iswide() def width(self): return self.data.width() When a str object is wrapped, an AttributeError will be raised anyway, it shouldn't be a problem that this error is not raised by UserString itself. You could add comments to the method like this: def iswide(self): return self.data.iswide() # unicode only def width(self): return self.data.width() # unicode only that will show up in a stacktrace and give a hint to the user. It's good that the tests are in string_tests.py now, but you should reuse this test class in test_unicode.py too. Bye, Walter Dörwald
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4