Skip to content

Unicode trait handling for those vtk methods returning unicode data#355

Merged
prabhuramachandran merged 8 commits into
masterfrom
unicode-coercion
Apr 27, 2016
Merged

Unicode trait handling for those vtk methods returning unicode data#355
prabhuramachandran merged 8 commits into
masterfrom
unicode-coercion

Conversation

@stefanoborini
Copy link
Copy Markdown
Contributor

The generator code did not handle unicode, but some vtk routines do return them. Although never able to reproduce it, issue #354 shows a situation where it does matter.

I am unsure about potential side effects of this change on client code, but I am surprised it worked until now, and I expect the method was simply not generated, or it was but it returned an empty string.

Comment thread tvtk/wrapper_gen.py Outdated
if default == '\x00':
t_def = 'traits.Unicode(u"", '
elif default == '"':
t_def = "traits.Unicode(u'%(default)s', " % locals()
Copy link
Copy Markdown
Member

@rkern rkern Apr 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if default == u'\x00':
    default = u''
t_def = 'traits.Unicode({0!r}, enter_set=True, auto_set=False)'.format(default)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't .encode() or clean_special_chars(). {!r} takes care of everything.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkern done. I also took care of the part handling String and removed the cleaning function.

@kitchoi
Copy link
Copy Markdown
Contributor

kitchoi commented Apr 25, 2016

Verified that it works with the following tox.ini

[tox]
envlist = py27

[testenv]
# To make sure we actually test the tarball and now the working directory
changedir = .tox

# We use symbolic links to provide vtk which is not on pypi
whitelist_externals=/bin/ln

# Install development requirements
deps = numpy

# e.g. export VTK_PATH=${HOME}/.cache/VTK-6.3.0-Linux-64bit/lib/python2.7/site-packages/vtk
# e.g. export LD_LIBRARY_PATH=${HOME}/.cache/VTK-6.3.0-Linux-64bit/lib
passenv = VTK_PATH LD_LIBRARY_PATH

basepython = python2.7

commands =
     ln -sf {env:VTK_PATH} {envsitepackagesdir}/

@stefanoborini
Copy link
Copy Markdown
Contributor Author

Failure seems due to a network problem. Restarting

Comment thread tvtk/wrapper_gen.py Outdated

elif PY_VER < 3 and typ is unicode:
if default == u'\x00':
default = ''
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default = u''

@prabhuramachandran prabhuramachandran merged commit e633f8f into master Apr 27, 2016
@prabhuramachandran prabhuramachandran deleted the unicode-coercion branch April 27, 2016 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants