unicode gives me nightmares. Taking django out of the picture for a moment: >>> unicode('foo', 'utf-8') u'foo' >>> unicode(u'foo', 'utf-8') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: decoding Unicode is not supported
So I would assume when you run it inside django you're already using a unicode string. Do you need to pass the encoding argument ('utf-8') to unicode? On Tue, Aug 3, 2010 at 3:30 PM, sohesado <gnubun...@gmail.com> wrote: > Hi > > I'm currently developing a django project and i've encountered a > problem regarding Unicode string manipulation. > > There is a backend python module in my project that perform's mainly > shutil (shell utilities) tasks. > > I get an TypeError: "decoding Unicode is not supported" exception > while running the following method > > > --------------------------------------------------------------------------------------------------------- > def create_base(name, reg): > path = unicode(ROOT + name, 'utf-8') <<<< error at this line > shutil.copytree(ROOT + 'matrix', path) > shutil.copystat(ROOT + 'matrix', path) > > f = codecs.open(path + '/conf/local.php', "w", "UTF-8") > tmp = unicode("<?php\n$conf['title'] = " + name + ";\n", 'utf-8') > f.write(tmp) > if not reg: > f.write("$conf['disableactions'] = 'register';\n") > > ------------------------------------------------------------------------------------------------------- > > The weird thing that puzzles me is that when i test the module in a > python shell , the method runs flawlessly which yields me to the > assumption that it's a django thing. > By the way i use apache+mod-python as a web-server > > I can't get adequate information regarding this type of exception. I'm > stuck , please help. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.