Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 8 commits into from Apr 27, 2016

Conversation

stefanoborini
Copy link
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.

if default == '\x00':
t_def = 'traits.Unicode(u"", '
elif default == '"':
t_def = "traits.Unicode(u'%(default)s', " % locals()
Copy link
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
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
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
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
Contributor Author

Failure seems due to a network problem. Restarting


elif PY_VER < 3 and typ is unicode:
if default == u'\x00':
default = ''
Copy link
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.

None yet

4 participants