Identify automatic str/unicode coercions

Martin Pool mbp at canonical.com
Wed Jun 11 13:01:50 BST 2008


On Wed, Jun 11, 2008 at 9:55 PM, Andrew Bennetts <andrew at canonical.com> wrote:
> Martin von Gagern wrote:
>> Andrew Bennetts wrote:
>>> An simpler option is set the default encoding to "undefined", and run the test
>>> suite.  "undefined" raises an error on any implicit conversion:
>>>
>>> Unfortunately, this currently breaks a lot of things, including the
>>> running of the test suite :)
>>
>> Yes, I read that as well, but there are a number of downsides to
>> aborting on each and every automatic conversion, even besides the fact
>> that the test suite won't work:
>> 1. You'd have to fix things in a given order
>> 2. You couldn't skip issues where you are not yet sure about the correct
>> encoding
>> 3. You coudn't skip cases where you needn't worry as the string's a constant
>> 4. The farther along you have proceeded, the more of the test suite
>> you'll need to run before you see the next issue
>> 5. You can't weight issues by occurrence
>>
>> As the difficult part for me was not writing the custom encoding but
>> rather setting the default encoding without site.py interfering, I see
>> little to gain and much to loose by using "undefined" for bazaar
>> development.
>
> Well, the advantage of using "undefined" is you could use it to systematically
> find and fix every case in bzrlib with the usual selftest-fix-selftest-fix
> cycle.  Given that the test runner doesn't even start running the tests though
> it would be a fairly large undertaking, so I can see the advantage of your
> approach.

I guess you could register an encoder which uses the Python warnings
library, which would give you a chance to reduce them to one message
per line, selectively ignore some, and still get hard errors if
desired.  Mind you shaking everything out of the test runner might be
a good place to start as the code is fairly straightforward and it
would tell you whether it was feasible to tackle the wider project.

Thanks for trying it Martin!

-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list