~ubuntu-branches/ubuntu/natty/python3.1/natty-security

« back to all changes in this revision

Viewing changes to Python/ast.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-07-06 16:52:42 UTC
  • mfrom: (1.2.1 upstream) (2.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20100706165242-2xv4i019r3et6c0j
Tags: 3.1.2+20100706-1ubuntu1
* Merge with Debian; remaining changes:
  - Regenerate the control file.
  - Add debian/patches/overwrite-semaphore-check for Lucid buildds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    /* Check whether there are non-ASCII characters in the
59
59
       identifier; if so, normalize to NFKC. */
60
60
    for (; *u; u++) {
61
 
        if (*u >= 128) {
62
 
            PyObject *m = PyImport_ImportModuleNoBlock("unicodedata");
63
 
            PyObject *id2;
64
 
            if (!m)
65
 
                return NULL;
66
 
            id2 = PyObject_CallMethod(m, "normalize", "sO", "NFKC", id);
67
 
            Py_DECREF(m);
68
 
            if (!id2)
69
 
                return NULL;
70
 
            Py_DECREF(id);
71
 
            id = id2;
72
 
            break;
73
 
        }
 
61
        if (*u >= 128) {
 
62
            PyObject *m = PyImport_ImportModuleNoBlock("unicodedata");
 
63
            PyObject *id2;
 
64
            if (!m)
 
65
                return NULL;
 
66
            id2 = PyObject_CallMethod(m, "normalize", "sO", "NFKC", id);
 
67
            Py_DECREF(m);
 
68
            if (!id2)
 
69
                return NULL;
 
70
            Py_DECREF(id);
 
71
            id = id2;
 
72
            break;
 
73
        }
74
74
    }
75
75
    PyUnicode_InternInPlace(&id);
76
76
    PyArena_AddPyObject(arena, id);
226
226
        c.c_encoding = STR(n);
227
227
        n = CHILD(n, 0);
228
228
    } else {
229
 
        /* PEP 3120 */
 
229
        /* PEP 3120 */
230
230
        c.c_encoding = "utf-8";
231
231
    }
232
232
    c.c_arena = arena;
424
424
            s = e->v.List.elts;
425
425
            break;
426
426
        case Tuple_kind:
427
 
            if (asdl_seq_LEN(e->v.Tuple.elts) == 0) 
 
427
            if (asdl_seq_LEN(e->v.Tuple.elts) == 0)
428
428
                return ast_error(n, "can't assign to ()");
429
429
            e->v.Tuple.ctx = ctx;
430
430
            s = e->v.Tuple.elts;
471
471
            expr_name = "conditional expression";
472
472
            break;
473
473
        default:
474
 
            PyErr_Format(PyExc_SystemError, 
475
 
                         "unexpected expression in assignment %d (line %d)", 
 
474
            PyErr_Format(PyExc_SystemError,
 
475
                         "unexpected expression in assignment %d (line %d)",
476
476
                         e->kind, e->lineno);
477
477
            return 0;
478
478
    }
487
487
    }
488
488
 
489
489
    /* If the LHS is a list or tuple, we need to set the assignment
490
 
       context for all the contained elements.  
 
490
       context for all the contained elements.
491
491
    */
492
492
    if (s) {
493
493
        int i;
709
709
    }
710
710
    return i;
711
711
 error:
712
 
    return -1;   
 
712
    return -1;
713
713
}
714
714
 
715
715
/* Create AST for argument list. */
722
722
 
723
723
       parameters: '(' [typedargslist] ')'
724
724
       typedargslist: ((tfpdef ['=' test] ',')*
725
 
           ('*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] 
 
725
           ('*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef]
726
726
           | '**' tfpdef)
727
727
           | tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
728
728
       tfpdef: NAME [':' test]
729
729
       varargslist: ((vfpdef ['=' test] ',')*
730
 
           ('*' [vfpdef] (',' vfpdef ['=' test])*  [',' '**' vfpdef] 
 
730
           ('*' [vfpdef] (',' vfpdef ['=' test])*  [',' '**' vfpdef]
731
731
           | '**' vfpdef)
732
732
           | vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
733
733
       vfpdef: NAME
768
768
        if (TYPE(ch) == vfpdef || TYPE(ch) == tfpdef) nposargs++;
769
769
        if (TYPE(ch) == EQUAL) nposdefaults++;
770
770
    }
771
 
    /* count the number of keyword only args & 
 
771
    /* count the number of keyword only args &
772
772
       defaults for keyword only args */
773
773
    for ( ; i < NCH(n); ++i) {
774
774
        ch = CHILD(n, i);
782
782
                   asdl_seq_new(nkwonlyargs, c->c_arena) : NULL);
783
783
    if (!kwonlyargs && nkwonlyargs)
784
784
        goto error;
785
 
    posdefaults = (nposdefaults ? 
 
785
    posdefaults = (nposdefaults ?
786
786
                    asdl_seq_new(nposdefaults, c->c_arena) : NULL);
787
787
    if (!posdefaults && nposdefaults)
788
788
        goto error;
789
 
    /* The length of kwonlyargs and kwdefaults are same 
 
789
    /* The length of kwonlyargs and kwdefaults are same
790
790
       since we set NULL as default for keyword only argument w/o default
791
791
       - we have sequence data structure, but no dictionary */
792
792
    kwdefaults = (nkwonlyargs ?
823
823
                    found_default = 1;
824
824
                }
825
825
                else if (found_default) {
826
 
                    ast_error(n, 
 
826
                    ast_error(n,
827
827
                             "non-default argument follows default argument");
828
828
                    goto error;
829
829
                }
835
835
                break;
836
836
            case STAR:
837
837
                if (i+1 >= NCH(n)) {
838
 
                    ast_error(CHILD(n, i), 
 
838
                    ast_error(CHILD(n, i),
839
839
                        "named arguments must follow bare *");
840
840
                    goto error;
841
841
                }
932
932
    /* decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE */
933
933
    expr_ty d = NULL;
934
934
    expr_ty name_expr;
935
 
    
 
935
 
936
936
    REQ(n, decorator);
937
937
    REQ(CHILD(n, 0), AT);
938
938
    REQ(RCHILD(n, -1), NEWLINE);
939
 
    
 
939
 
940
940
    name_expr = ast_for_dotted_name(c, CHILD(n, 1));
941
941
    if (!name_expr)
942
942
        return NULL;
943
 
        
 
943
 
944
944
    if (NCH(n) == 3) { /* No arguments */
945
945
        d = name_expr;
946
946
        name_expr = NULL;
968
968
    asdl_seq* decorator_seq;
969
969
    expr_ty d;
970
970
    int i;
971
 
    
 
971
 
972
972
    REQ(n, decorators);
973
973
    decorator_seq = asdl_seq_new(NCH(n), c->c_arena);
974
974
    if (!decorator_seq)
975
975
        return NULL;
976
 
        
 
976
 
977
977
    for (i = 0; i < NCH(n); i++) {
978
978
        d = ast_for_decorator(c, CHILD(n, i));
979
979
            if (!d)
1029
1029
      return NULL;
1030
1030
 
1031
1031
    assert(TYPE(CHILD(n, 1)) == funcdef ||
1032
 
           TYPE(CHILD(n, 1)) == classdef);
 
1032
           TYPE(CHILD(n, 1)) == classdef);
1033
1033
 
1034
1034
    if (TYPE(CHILD(n, 1)) == funcdef) {
1035
1035
      thing = ast_for_funcdef(c, CHILD(n, 1), decorator_seq);
1077
1077
static expr_ty
1078
1078
ast_for_ifexpr(struct compiling *c, const node *n)
1079
1079
{
1080
 
    /* test: or_test 'if' or_test 'else' test */ 
 
1080
    /* test: or_test 'if' or_test 'else' test */
1081
1081
    expr_ty expression, body, orelse;
1082
1082
 
1083
1083
    assert(NCH(n) == 5);
1174
1174
        asdl_seq *t;
1175
1175
        expr_ty expression;
1176
1176
        node *for_ch;
1177
 
        
 
1177
 
1178
1178
        REQ(n, comp_for);
1179
 
        
 
1179
 
1180
1180
        for_ch = CHILD(n, 1);
1181
1181
        t = ast_for_exprlist(c, for_ch, Store);
1182
1182
        if (!t)
1201
1201
        if (NCH(n) == 5) {
1202
1202
            int j, n_ifs;
1203
1203
            asdl_seq *ifs;
1204
 
            
 
1204
 
1205
1205
            n = CHILD(n, 4);
1206
1206
            n_ifs = count_comp_ifs(c, n);
1207
1207
            if (n_ifs == -1)
1215
1215
                REQ(n, comp_iter);
1216
1216
                n = CHILD(n, 0);
1217
1217
                REQ(n, comp_if);
1218
 
                
 
1218
 
1219
1219
                expression = ast_for_expr(c, CHILD(n, 1));
1220
1220
                if (!expression)
1221
1221
                    return NULL;
1240
1240
       argument: [test '='] test [comp_for]       # Really [keyword '='] test */
1241
1241
    expr_ty elt;
1242
1242
    asdl_seq *comps;
1243
 
    
 
1243
 
1244
1244
    assert(NCH(n) > 1);
1245
 
    
 
1245
 
1246
1246
    elt = ast_for_expr(c, CHILD(n, 0));
1247
1247
    if (!elt)
1248
1248
        return NULL;
1249
 
    
 
1249
 
1250
1250
    comps = ast_for_comprehension(c, CHILD(n, 1));
1251
1251
    if (!comps)
1252
1252
        return NULL;
1267
1267
{
1268
1268
    expr_ty key, value;
1269
1269
    asdl_seq *comps;
1270
 
    
 
1270
 
1271
1271
    assert(NCH(n) > 3);
1272
1272
    REQ(CHILD(n, 1), COLON);
1273
 
    
 
1273
 
1274
1274
    key = ast_for_expr(c, CHILD(n, 0));
1275
1275
    if (!key)
1276
1276
        return NULL;
1278
1278
    value = ast_for_expr(c, CHILD(n, 2));
1279
1279
    if (!value)
1280
1280
        return NULL;
1281
 
    
 
1281
 
1282
1282
    comps = ast_for_comprehension(c, CHILD(n, 3));
1283
1283
    if (!comps)
1284
1284
        return NULL;
1285
 
    
 
1285
 
1286
1286
    return DictComp(key, value, comps, LINENO(n), n->n_col_offset, c->c_arena);
1287
1287
}
1288
1288
 
1317
1317
    */
1318
1318
    node *ch = CHILD(n, 0);
1319
1319
    int bytesmode = 0;
1320
 
    
 
1320
 
1321
1321
    switch (TYPE(ch)) {
1322
1322
    case NAME: {
1323
1323
        /* All names start in Load context, but may later be
1368
1368
        return Ellipsis(LINENO(n), n->n_col_offset, c->c_arena);
1369
1369
    case LPAR: /* some parenthesized expressions */
1370
1370
        ch = CHILD(n, 1);
1371
 
        
 
1371
 
1372
1372
        if (TYPE(ch) == RPAR)
1373
1373
            return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);
1374
 
        
 
1374
 
1375
1375
        if (TYPE(ch) == yield_expr)
1376
1376
            return ast_for_expr(c, ch);
1377
1377
 
1378
 
        /* testlist_comp: test ( comp_for | (',' test)* [','] ) */ 
 
1378
        /* testlist_comp: test ( comp_for | (',' test)* [','] ) */
1379
1379
        if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == comp_for))
1380
1380
            return ast_for_genexp(c, ch);
1381
 
        
 
1381
 
1382
1382
        return ast_for_testlist(c, ch);
1383
1383
    case LSQB: /* list (or list comprehension) */
1384
1384
        ch = CHILD(n, 1);
1385
 
        
 
1385
 
1386
1386
        if (TYPE(ch) == RSQB)
1387
1387
            return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);
1388
 
        
 
1388
 
1389
1389
        REQ(ch, testlist_comp);
1390
1390
        if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {
1391
1391
            asdl_seq *elts = seq_for_testlist(c, ch);
1432
1432
            keys = asdl_seq_new(size, c->c_arena);
1433
1433
            if (!keys)
1434
1434
                return NULL;
1435
 
            
 
1435
 
1436
1436
            values = asdl_seq_new(size, c->c_arena);
1437
1437
            if (!values)
1438
1438
                return NULL;
1439
 
            
 
1439
 
1440
1440
            for (i = 0; i < NCH(ch); i += 4) {
1441
1441
                expr_ty expression;
1442
 
                
 
1442
 
1443
1443
                expression = ast_for_expr(c, CHILD(ch, i));
1444
1444
                if (!expression)
1445
1445
                    return NULL;
1477
1477
    if (NCH(n) == 1 && TYPE(ch) == test) {
1478
1478
        /* 'step' variable hold no significance in terms of being used over
1479
1479
           other vars */
1480
 
        step = ast_for_expr(c, ch); 
 
1480
        step = ast_for_expr(c, ch);
1481
1481
        if (!step)
1482
1482
            return NULL;
1483
 
            
 
1483
 
1484
1484
        return Index(step, c->c_arena);
1485
1485
    }
1486
1486
 
1537
1537
ast_for_binop(struct compiling *c, const node *n)
1538
1538
{
1539
1539
    /* Must account for a sequence of expressions.
1540
 
       How should A op B op C by represented?  
 
1540
       How should A op B op C by represented?
1541
1541
       BinOp(BinOp(A, op, B), op, C).
1542
1542
    */
1543
1543
 
1575
1575
        if (!tmp)
1576
1576
            return NULL;
1577
1577
 
1578
 
        tmp_result = BinOp(result, newoperator, tmp, 
 
1578
        tmp_result = BinOp(result, newoperator, tmp,
1579
1579
                           LINENO(next_oper), next_oper->n_col_offset,
1580
1580
                           c->c_arena);
1581
 
        if (!tmp_result) 
 
1581
        if (!tmp_result)
1582
1582
            return NULL;
1583
1583
        result = tmp_result;
1584
1584
    }
1588
1588
static expr_ty
1589
1589
ast_for_trailer(struct compiling *c, const node *n, expr_ty left_expr)
1590
1590
{
1591
 
    /* trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME 
 
1591
    /* trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
1592
1592
       subscriptlist: subscript (',' subscript)* [',']
1593
1593
       subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop]
1594
1594
     */
1619
1619
                             c->c_arena);
1620
1620
        }
1621
1621
        else {
1622
 
            /* The grammar is ambiguous here. The ambiguity is resolved 
 
1622
            /* The grammar is ambiguous here. The ambiguity is resolved
1623
1623
               by treating the sequence as a tuple literal if there are
1624
1624
               no slice features.
1625
1625
            */
1772
1772
    /* handle the full range of simple expressions
1773
1773
       test: or_test ['if' or_test 'else' test] | lambdef
1774
1774
       test_nocond: or_test | lambdef_nocond
1775
 
       or_test: and_test ('or' and_test)* 
 
1775
       or_test: and_test ('or' and_test)*
1776
1776
       and_test: not_test ('and' not_test)*
1777
1777
       not_test: 'not' not_test | comparison
1778
1778
       comparison: expr (comp_op expr)*
1860
1860
                    if (!expression) {
1861
1861
                        return NULL;
1862
1862
                    }
1863
 
                        
 
1863
 
1864
1864
                    asdl_seq_SET(ops, i / 2, newoperator);
1865
1865
                    asdl_seq_SET(cmps, i / 2, expression);
1866
1866
                }
1868
1868
                if (!expression) {
1869
1869
                    return NULL;
1870
1870
                }
1871
 
                    
 
1871
 
1872
1872
                return Compare(expression, ops, cmps, LINENO(n),
1873
1873
                               n->n_col_offset, c->c_arena);
1874
1874
            }
1987
1987
                if (!e)
1988
1988
                    return NULL;
1989
1989
                asdl_seq_SET(args, nargs++, e);
1990
 
            }  
 
1990
            }
1991
1991
            else if (TYPE(CHILD(ch, 1)) == comp_for) {
1992
1992
                e = ast_for_genexp(c, ch);
1993
1993
                if (!e)
1999
1999
                identifier key, tmp;
2000
2000
                int k;
2001
2001
 
2002
 
                /* CHILD(ch, 0) is test, but must be an identifier? */ 
 
2002
                /* CHILD(ch, 0) is test, but must be an identifier? */
2003
2003
                e = ast_for_expr(c, CHILD(ch, 0));
2004
2004
                if (!e)
2005
2005
                    return NULL;
2015
2015
                  ast_error(CHILD(ch, 0), "keyword can't be an expression");
2016
2016
                  return NULL;
2017
2017
                } else if (forbidden_name(e, ch)) {
2018
 
                  return NULL;
2019
 
                }
 
2018
                  return NULL;
 
2019
                }
2020
2020
                key = e->v.Name.id;
2021
2021
                for (k = 0; k < nkeywords; k++) {
2022
2022
                    tmp = ((keyword_ty)asdl_seq_GET(keywords, k))->arg;
2080
2080
ast_for_expr_stmt(struct compiling *c, const node *n)
2081
2081
{
2082
2082
    REQ(n, expr_stmt);
2083
 
    /* expr_stmt: testlist (augassign (yield_expr|testlist) 
 
2083
    /* expr_stmt: testlist (augassign (yield_expr|testlist)
2084
2084
                | ('=' (yield_expr|testlist))*)
2085
2085
       testlist: test (',' test)* [',']
2086
2086
       augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^='
2154
2154
            e = ast_for_testlist(c, ch);
2155
2155
 
2156
2156
            /* set context to assign */
2157
 
            if (!e) 
 
2157
            if (!e)
2158
2158
              return NULL;
2159
2159
 
2160
2160
            if (!set_context(c, e, Store, CHILD(n, i)))
2200
2200
ast_for_del_stmt(struct compiling *c, const node *n)
2201
2201
{
2202
2202
    asdl_seq *expr_list;
2203
 
    
 
2203
 
2204
2204
    /* del_stmt: 'del' exprlist */
2205
2205
    REQ(n, del_stmt);
2206
2206
 
2323
2323
                int i;
2324
2324
                size_t len;
2325
2325
                char *s;
2326
 
                PyObject *uni;
 
2326
                PyObject *uni;
2327
2327
 
2328
2328
                len = 0;
2329
2329
                for (i = 0; i < NCH(n); i += 2)
2344
2344
                }
2345
2345
                --s;
2346
2346
                *s = '\0';
2347
 
                uni = PyUnicode_DecodeUTF8(PyBytes_AS_STRING(str),
2348
 
                                           PyBytes_GET_SIZE(str), 
2349
 
                                           NULL);
2350
 
                Py_DECREF(str);
2351
 
                if (!uni)
2352
 
                    return NULL;
2353
 
                str = uni;
 
2347
                uni = PyUnicode_DecodeUTF8(PyBytes_AS_STRING(str),
 
2348
                                           PyBytes_GET_SIZE(str),
 
2349
                                           NULL);
 
2350
                Py_DECREF(str);
 
2351
                if (!uni)
 
2352
                    return NULL;
 
2353
                str = uni;
2354
2354
                PyUnicode_InternInPlace(&str);
2355
2355
                PyArena_AddPyObject(c->c_arena, str);
2356
2356
                return alias(str, NULL, c->c_arena);
2407
2407
        int idx, ndots = 0;
2408
2408
        alias_ty mod = NULL;
2409
2409
        identifier modname;
2410
 
        
 
2410
 
2411
2411
       /* Count the number of dots (for relative imports) and check for the
2412
2412
          optional module name */
2413
2413
        for (idx = 1; idx < NCH(n); idx++) {
2416
2416
                idx++;
2417
2417
                break;
2418
2418
            } else if (TYPE(CHILD(n, idx)) == ELLIPSIS) {
2419
 
                /* three consecutive dots are tokenized as one ELLIPSIS */ 
 
2419
                /* three consecutive dots are tokenized as one ELLIPSIS */
2420
2420
                ndots += 3;
2421
2421
                continue;
2422
2422
            } else if (TYPE(CHILD(n, idx)) != DOT) {
2545
2545
        expr2 = ast_for_expr(c, CHILD(n, 3));
2546
2546
        if (!expr2)
2547
2547
            return NULL;
2548
 
            
 
2548
 
2549
2549
        return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena);
2550
2550
    }
2551
2551
    PyErr_Format(PyExc_SystemError,
2572
2572
    if (TYPE(CHILD(n, 0)) == simple_stmt) {
2573
2573
        n = CHILD(n, 0);
2574
2574
        /* simple_stmt always ends with a NEWLINE,
2575
 
           and may have a trailing SEMI 
 
2575
           and may have a trailing SEMI
2576
2576
        */
2577
2577
        end = NCH(n) - 1;
2578
2578
        if (TYPE(CHILD(n, end - 1)) == SEMI)
2637
2637
        expression = ast_for_expr(c, CHILD(n, 1));
2638
2638
        if (!expression)
2639
2639
            return NULL;
2640
 
        suite_seq = ast_for_suite(c, CHILD(n, 3)); 
 
2640
        suite_seq = ast_for_suite(c, CHILD(n, 3));
2641
2641
        if (!suite_seq)
2642
2642
            return NULL;
2643
 
            
 
2643
 
2644
2644
        return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset,
2645
2645
                  c->c_arena);
2646
2646
    }
2698
2698
            if (!suite_seq2)
2699
2699
                return NULL;
2700
2700
 
2701
 
            asdl_seq_SET(orelse, 0, 
2702
 
                         If(expression, suite_seq, suite_seq2, 
 
2701
            asdl_seq_SET(orelse, 0,
 
2702
                         If(expression, suite_seq, suite_seq2,
2703
2703
                            LINENO(CHILD(n, NCH(n) - 6)),
2704
2704
                            CHILD(n, NCH(n) - 6)->n_col_offset,
2705
2705
                            c->c_arena));
2720
2720
                return NULL;
2721
2721
 
2722
2722
            asdl_seq_SET(newobj, 0,
2723
 
                         If(expression, suite_seq, orelse, 
 
2723
                         If(expression, suite_seq, orelse,
2724
2724
                            LINENO(CHILD(n, off)),
2725
2725
                            CHILD(n, off)->n_col_offset, c->c_arena));
2726
2726
            orelse = newobj;
2914
2914
        ast_error(n, "malformed 'try' statement");
2915
2915
        return NULL;
2916
2916
    }
2917
 
    
 
2917
 
2918
2918
    if (n_except > 0) {
2919
2919
        int i;
2920
2920
        stmt_ty except_st;
3125
3125
                return ast_for_funcdef(c, ch, NULL);
3126
3126
            case classdef:
3127
3127
                return ast_for_classdef(c, ch, NULL);
3128
 
            case decorated:
3129
 
                return ast_for_decorated(c, ch);
 
3128
            case decorated:
 
3129
                return ast_for_decorated(c, ch);
3130
3130
            default:
3131
3131
                PyErr_Format(PyExc_SystemError,
3132
3132
                             "unhandled small_stmt: TYPE=%d NCH=%d\n",
3288
3288
        if (quote == 'b' || quote == 'B') {
3289
3289
            quote = *++s;
3290
3290
            *bytesmode = 1;
3291
 
        }             
 
3291
        }
3292
3292
        if (quote == 'r' || quote == 'R') {
3293
3293
            quote = *++s;
3294
3294
            rawmode = 1;
3301
3301
    s++;
3302
3302
    len = strlen(s);
3303
3303
    if (len > INT_MAX) {
3304
 
        PyErr_SetString(PyExc_OverflowError, 
 
3304
        PyErr_SetString(PyExc_OverflowError,
3305
3305
                        "string to parse is too long");
3306
3306
        return NULL;
3307
3307
    }
3345
3345
            return PyBytes_FromStringAndSize(s, len);
3346
3346
        } else if (strcmp(c->c_encoding, "utf-8") == 0) {
3347
3347
            return PyUnicode_FromStringAndSize(s, len);
3348
 
        } else {
 
3348
        } else {
3349
3349
            return PyUnicode_DecodeLatin1(s, len, NULL);
3350
3350
        }
3351
3351
    }