Skip to content

add_input_check fails to check input #9

@pdpinch

Description

@pdpinch

from ZenDesk 91873 and ZenDesk 86186:

Pre-processing student submissions using add_input_check() hasn't worked since xqueuewatcher was upgraded to Python 3. It appears that the tokenizer is not working, probably due to an encoding issue.

def _tokens(code):
"""
A wrapper around tokenize.generate_tokens.
"""
# Protect against pathological inputs: http://bugs.python.org/issue16152
code = code.rstrip() + "\n"
if isinstance(code, six.text_type):
code = code.encode('utf8')
code = "# coding: utf8\n" + code
toks = tokenize.generate_tokens(six.BytesIO(code).readline)
return toks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions