str() used instead of unicode() in virtualaddresseditor.py???

21 views
Skip to first unread message

Sebastian Stetter

unread,
Sep 15, 2015, 12:37:10 PM9/15/15
to Project Camelot
Hey guys!
I am having trouble with umlauts (äöü...) and the virtualadresseditor.
Whenever I use one of these characters in a virtual address, my app crashes wit an UnicodeEncodeError.

The reason seams to be, that the function emit_editing_finished() in virtuayladdress.py is using str() instead of unicode() (as the other functions do) to cast the output of self.combo.currentText() and self.editor.text().
Can you confirm this is a bug?

   
def emit_editing_finished(self):
       
self.value = []
       
self.value.append(str(self.combo.currentText()))
       
self.value.append(str(self.editor.text()))
       
self.set_value(self.value)
       
# emiting editingFinished without a value for the mechanism itself will lead to
       
# integrity errors
       
if self.value[1]:
           
self.editingFinished.emit()

There might be other functions using str() instead of unicode() as well...

Thanks,
Sebastian

jochem.o...@conceptive.be

unread,
Sep 19, 2015, 4:15:23 AM9/19/15
to Project Camelot
Hello Sebastian,


On Tuesday, September 15, 2015 at 6:37:10 PM UTC+2, Sebastian Stetter wrote:
The reason seams to be, that the function emit_editing_finished() in virtuayladdress.py is using str() instead of unicode() (as the other functions do) to cast the output of self.combo.currentText() and self.editor.text().

Sounds legit.


Because in Python 3 the unicode method we know from Python 2 was renamed to str (with the old str method from 2 entirely removed), you can’t just replace str() calls by calls to unicode() as this wouldn’t work in Python 3. Instead, camelot uses the text_type method from the six module.

See for instance: https://bitbucket.org/conceptive/camelot/src/ac0f46f64a540fe3f0dbe0f101a558be6a42ed19/camelot/view/controls/editors/virtualaddresseditor.py?at=default&fileviewer=file-view-default#virtualaddresseditor.py-131


If you could create a pull request for replacing the relevant str() calls by six.text_type() calls here, I’m pretty sure it will be merged into the default branch.


Regards,

Jochem 

Jochem Oosterveen

unread,
Sep 19, 2015, 4:15:23 AM9/19/15
to Project Camelot
Hello Sebastian,

On 15 Sep 2015, at 18:37, Sebastian Stetter wrote:
> The reason seams to be, that the function emit_editing_finished() in
> virtuayladdress.py is using str() instead of unicode() (as the other
> functions do) to cast the output of self.combo.currentText() and
> self.editor.text().

Erik Janssens

unread,
Sep 19, 2015, 4:35:55 AM9/19/15
to project...@googlegroups.com
ok, this was a bug indeed, the proposed changes have been
applied to the default branch
--
--
You received this message because you are subscribed to the "Project Camelot" group.
Visit www.python-camelot.com for more information
 
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to
project-camel...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/project-camelot?hl=en

---
You received this message because you are subscribed to the Google Groups "Project Camelot" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-camel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted

Sebastian Stetter

unread,
Sep 20, 2015, 5:47:49 PM9/20/15
to Project Camelot, erik.j...@conceptive.be
OK, I get it. Thanks.
I am not exactely sure what a pull request is, though.

Erik, thanks for the fix.

Sebastian
Reply all
Reply to author
Forward
0 new messages