Skip to content
Permalink
Browse files

BF: FormComponent crashes if non-ascii chracters are used as items on…

… Python2
  • Loading branch information...
hsogo committed May 12, 2019
1 parent 417c9f4 commit 8287674f49a4c8ca2c268a4d80d5becc9d8b757f
Showing with 10 additions and 4 deletions.
  1. +10 −4 psychopy/visual/form.py
@@ -15,6 +15,8 @@
ColorMixin)
from random import shuffle

from psychopy.constants import PY3

__author__ = 'Jon Peirce, David Bridges, Anthony Haffey'


@@ -171,8 +173,12 @@ def _checkHeaders(fields):
_checkHeaders(item.keys())
# Convert options to list of strings
for idx, item in enumerate(items):
if isinstance(item['options'], str):
items[idx]['options'] = item['options'].split(',')
if PY3:
if isinstance(item['options'], str):
items[idx]['options'] = item['options'].split(',')
else: # Python2
if isinstance(item['options'], unicode):
items[idx]['options'] = item['options'].split(',')
# Check types
[_checkTypes(item['type']) for item in items]
# Check N options > 1
@@ -266,7 +272,7 @@ def _setQuestion(self, item):
The width of the question bounding box as type float
"""
if self.autoLog:
psychopy.logging.exp("Question text: {}".format(item['questionText']))
psychopy.logging.exp(u"Question text: {}".format(item['questionText']))

question = psychopy.visual.TextStim(self.win,
text=item['questionText'],
@@ -310,7 +316,7 @@ def _setResponse(self, item, question):
if self.autoLog:
psychopy.logging.exp("Response type: {}".format(item['type']))
psychopy.logging.exp("Response layout: {}".format(item['layout']))
psychopy.logging.exp("Response options: {}".format(item['options']))
psychopy.logging.exp(u"Response options: {}".format(item['options']))

# Create position of response object
pos = self._getResponsePos(item, question)

0 comments on commit 8287674

Please sign in to comment.
You can’t perform that action at this time.