Hello!
2009/5/30 <alexsh(a)svn.wikimedia.org>:
> Revision: 6927
> Author: alexsh
> Date: 2009-05-30 02:37:59 +0000 (Sat, 30 May 2009)
>
> Log Message:
> -----------
> Fix UnicodeDecodeError in message print out
It would be helpful to see the stacktrace here, because the fixes
you're doing are not... straightforward :)
> Modified: trunk/pywikipedia/clean_sandbox.py
> ===================================================================
> --- trunk/pywikipedia/clean_sandbox.py 2009-05-29 18:56:04 UTC (rev 6926)
> +++ trunk/pywikipedia/clean_sandbox.py 2009-05-30 02:37:59 UTC (rev 6927)
> @@ -122,7 +122,7 @@
> wikipedia.output(u'\nDone.')
> return
> else:
> - wikipedia.output(u'\nSleeping %s hours, now %s' % (self.hours, now))
> + wikipedia.output('\nSleeping %s hours, now %s' % (self.hours, now) )
> time.sleep(self.hours * 60 * 60)
I don't understand how this change can solve a UnicodeDecodeError.
At most, a UnicodeEncodeError could be thrown before? Also, it's
better to use Unicode when possible instead of relying on bytestring:
output() has no way to determine what encoding should be used for
decoding
If this change solves something, there should be a better way to solve
your problem :)
What bug are you fixing exactly?
>
> Modified: trunk/pywikipedia/welcome.py
> ===================================================================
> --- trunk/pywikipedia/welcome.py 2009-05-29 18:56:04 UTC (rev 6926)
> +++ trunk/pywikipedia/welcome.py 2009-05-30 02:37:59 UTC (rev 6927)
> @@ -827,7 +827,7 @@
> if offset_variable != 0:
> URL += "&offset=%d" % offset_variable
> log = wsite.getUrl(URL)
> - wikipedia.output(u'Loading latest %s new users from %s...\n' % (limit, wsite.hostname()))
> + wikipedia.output(u'Loading latest %s new users from %s:%s...\n' % (limit, wikipedia.default_family,wikipedia.default_code))
> # Determine which signature to use
> if random:
> try:
Again, I don't see the point. Are you solving some encoding problem
here, or changing output format? Or both?
* If there's an encoding problem, something has to be fixed in another
place (can you provide the stacktrace maybe?)
* If you're changing output format... I'm fine with it, but please
don't commit unrelated changes without comments... Also, simply using
u'%s' % wsite should work the same, because Site objects have a
__repr__ method
Thank you!
--
Nicolas Dumazet — NicDumZ [ nɪk.d̪ymz ]