~ubuntu-branches/ubuntu/natty/python3.2/natty-updates

« back to all changes in this revision

Viewing changes to Parser/tokenizer.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2011-01-16 18:09:56 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110116180956-yf91p6ode1z6lsi1
Tags: 3.2~rc1-0ubuntu1
Python 3.2 release candidate 1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
545
545
{
546
546
    char *line = NULL;
547
547
    int badchar = 0;
 
548
    PyObject *filename;
548
549
    for (;;) {
549
550
        if (tok->decoding_state == STATE_NORMAL) {
550
551
            /* We already have a codec associated with
585
586
    if (badchar) {
586
587
        /* Need to add 1 to the line number, since this line
587
588
           has not been counted, yet.  */
588
 
        PyErr_Format(PyExc_SyntaxError,
589
 
            "Non-UTF-8 code starting with '\\x%.2x' "
590
 
            "in file %.200s on line %i, "
591
 
            "but no encoding declared; "
592
 
            "see http://python.org/dev/peps/pep-0263/ for details",
593
 
            badchar, tok->filename, tok->lineno + 1);
 
589
        filename = PyUnicode_DecodeFSDefault(tok->filename);
 
590
        if (filename != NULL) {
 
591
            PyErr_Format(PyExc_SyntaxError,
 
592
                    "Non-UTF-8 code starting with '\\x%.2x' "
 
593
                    "in file %U on line %i, "
 
594
                    "but no encoding declared; "
 
595
                    "see http://python.org/dev/peps/pep-0263/ for details",
 
596
                    badchar, filename, tok->lineno + 1);
 
597
            Py_DECREF(filename);
 
598
        }
594
599
        return error_ret(tok);
595
600
    }
596
601
#endif
888
893
        if (tok->prompt != NULL) {
889
894
            char *newtok = PyOS_Readline(stdin, stdout, tok->prompt);
890
895
#ifndef PGEN
 
896
            if (newtok != NULL) {
 
897
                char *translated = translate_newlines(newtok, 0, tok);
 
898
                PyMem_FREE(newtok);
 
899
                if (translated == NULL)
 
900
                    return EOF;
 
901
                newtok = translated;
 
902
            }
891
903
            if (tok->encoding && newtok && *newtok) {
892
904
                /* Recode to UTF-8 */
893
905
                Py_ssize_t buflen;