Mercurial > cpython-lru_cache-weakref
comparison Modules/parsermodule.c @ 47294:4fe192d48960 legacy-trunk
Renamed PyString to PyBytes
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Mon, 26 May 2008 12:51:38 +0000 |
| parents | f419b2e96a98 |
| children | 52294af4b663 |
comparison
equal
deleted
inserted
replaced
| 47292:abafccfe7501 | 47294:4fe192d48960 |
|---|---|
| 103 } | 103 } |
| 104 (void) addelem(v, i+1, w); | 104 (void) addelem(v, i+1, w); |
| 105 } | 105 } |
| 106 | 106 |
| 107 if (TYPE(n) == encoding_decl) | 107 if (TYPE(n) == encoding_decl) |
| 108 (void) addelem(v, i+1, PyString_FromString(STR(n))); | 108 (void) addelem(v, i+1, PyBytes_FromString(STR(n))); |
| 109 return (v); | 109 return (v); |
| 110 } | 110 } |
| 111 else if (ISTERMINAL(TYPE(n))) { | 111 else if (ISTERMINAL(TYPE(n))) { |
| 112 PyObject *result = mkseq(2 + lineno + col_offset); | 112 PyObject *result = mkseq(2 + lineno + col_offset); |
| 113 if (result != NULL) { | 113 if (result != NULL) { |
| 114 (void) addelem(result, 0, PyInt_FromLong(TYPE(n))); | 114 (void) addelem(result, 0, PyInt_FromLong(TYPE(n))); |
| 115 (void) addelem(result, 1, PyString_FromString(STR(n))); | 115 (void) addelem(result, 1, PyBytes_FromString(STR(n))); |
| 116 if (lineno == 1) | 116 if (lineno == 1) |
| 117 (void) addelem(result, 2, PyInt_FromLong(n->n_lineno)); | 117 (void) addelem(result, 2, PyInt_FromLong(n->n_lineno)); |
| 118 if (col_offset == 1) | 118 if (col_offset == 1) |
| 119 (void) addelem(result, 3, PyInt_FromLong(n->n_col_offset)); | 119 (void) addelem(result, 3, PyInt_FromLong(n->n_col_offset)); |
| 120 } | 120 } |
| 687 return 0; | 687 return 0; |
| 688 } | 688 } |
| 689 temp = PySequence_GetItem(elem, 1); | 689 temp = PySequence_GetItem(elem, 1); |
| 690 if (temp == NULL) | 690 if (temp == NULL) |
| 691 return 0; | 691 return 0; |
| 692 if (!PyString_Check(temp)) { | 692 if (!PyBytes_Check(temp)) { |
| 693 PyErr_Format(parser_error, | 693 PyErr_Format(parser_error, |
| 694 "second item in terminal node must be a string," | 694 "second item in terminal node must be a string," |
| 695 " found %s", | 695 " found %s", |
| 696 Py_TYPE(temp)->tp_name); | 696 Py_TYPE(temp)->tp_name); |
| 697 Py_DECREF(temp); | 697 Py_DECREF(temp); |
| 712 return 0; | 712 return 0; |
| 713 } | 713 } |
| 714 Py_DECREF(o); | 714 Py_DECREF(o); |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 len = PyString_GET_SIZE(temp) + 1; | 717 len = PyBytes_GET_SIZE(temp) + 1; |
| 718 strn = (char *)PyObject_MALLOC(len); | 718 strn = (char *)PyObject_MALLOC(len); |
| 719 if (strn != NULL) | 719 if (strn != NULL) |
| 720 (void) memcpy(strn, PyString_AS_STRING(temp), len); | 720 (void) memcpy(strn, PyBytes_AS_STRING(temp), len); |
| 721 Py_DECREF(temp); | 721 Py_DECREF(temp); |
| 722 } | 722 } |
| 723 else if (!ISNONTERMINAL(type)) { | 723 else if (!ISNONTERMINAL(type)) { |
| 724 /* | 724 /* |
| 725 * It has to be one or the other; this is an error. | 725 * It has to be one or the other; this is an error. |
| 798 PyNode_Free(res); | 798 PyNode_Free(res); |
| 799 res = NULL; | 799 res = NULL; |
| 800 } | 800 } |
| 801 if (res && encoding) { | 801 if (res && encoding) { |
| 802 Py_ssize_t len; | 802 Py_ssize_t len; |
| 803 len = PyString_GET_SIZE(encoding) + 1; | 803 len = PyBytes_GET_SIZE(encoding) + 1; |
| 804 res->n_str = (char *)PyObject_MALLOC(len); | 804 res->n_str = (char *)PyObject_MALLOC(len); |
| 805 if (res->n_str != NULL) | 805 if (res->n_str != NULL) |
| 806 (void) memcpy(res->n_str, PyString_AS_STRING(encoding), len); | 806 (void) memcpy(res->n_str, PyBytes_AS_STRING(encoding), len); |
| 807 Py_DECREF(encoding); | 807 Py_DECREF(encoding); |
| 808 Py_DECREF(tuple); | 808 Py_DECREF(tuple); |
| 809 } | 809 } |
| 810 } | 810 } |
| 811 } | 811 } |
