About encoding issues

Jan Hudec bulb at ucw.cz
Sun Apr 23 17:32:08 BST 2006


Hello,

Hearing about encoding issues and seeing some myself I thought about whether
it is possible to disable automatic conversion between string and unicode.
And alas it is. One can do:

sys.setdefaultencoding('undefined')

from which moment on all automatic conversion attemtps raise an error.
That is unless one's /etc/python2.4/site.py contains:

    if hasattr(sys, "setdefaultencoding"):
        del sys.setdefaultencoding

(which I commented out here -- I wonder who invented that)
Therefore I tried to do:

=== modified file 'a/bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	
+++ b/bzrlib/tests/__init__.py	
@@ -887,6 +887,7 @@
 def run_suite(suite, name='test', verbose=False, pattern=".*",
               stop_on_failure=False, keep_output=False,
               transport=None):
+    sys.setdefaultencoding('undefined')
     TestCaseInTempDir._TEST_NAME = name
     if verbose:
         verbosity = 2

and see what happens. Unfortunately the errors it gave were pretty useless:

Traceback (most recent call last):
  File "/usr/lib/python2.4/logging/__init__.py", line 739, in emit
  File "/usr/lib/python2.4/encodings/undefined.py", line 22, in decode
    raise UnicodeError, "undefined encoding"
UnicodeError: undefined encoding

But if someone could look into it and managed to get proper backtraces out of
it, I think it would catch many of the encoding problems.

-- 
						 Jan 'Bulb' Hudec <bulb at ucw.cz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060423/fdc8f64c/attachment.pgp 


More information about the bazaar mailing list