[Pyobjc-dev] Bug in objc.synthesize
Brought to you by:
ronaldoussoren
From: Dirk S. <dir...@ma...> - 2009-07-12 14:01:42
|
Hi all, We've been trying to use the objc.synthesize method in our project, but ran into some issues with it. After peeking in pyobjc-core for a bit, I think I might have found a bug. At line 186 and beyond (def synthesize), in: > http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-core/Lib/objc/_descriptors.py , the generated setter strings use name.capitalize() to go from 'ivar' to 'setIvar_'. This works as expected on variable names with only lowercase characters, but has an undesired effect on names with camelCase in them. examples: name = 'string' resulting setter method name = 'setString_' name = 'searchString' resulting setter method name = 'setSearchstring_' expected setter method name = 'setSearchString_' If we replace: > name=name.capitalize() with: > name = '%s%s' % (name[0].upper(), name[1:]) It should be fixed, but using the [1:] indexset means that an IndexError will be thrown for names with zero length. (Though that doesn't sound like a big deal to me, we might want to provide a better description than 'index out of range' when that happens). I can't build from trunk right now, so it's a bit of a hassle for me to actually test this fix, hence this email instead of a patch. @Ronald: Please let me know if you want to hear about specific problems building on 10.5 right now, (or if you'd like me to submit patches with fixes for those problems, let me know how you prefer those patches to be formatted). Thanks :) - Dirk |