summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-05-26 12:51:38 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-05-26 12:51:38 (GMT)
commit593daf545bd9b7e7bcb27b498ecc6f36db9ae395 (patch)
treec0a57029b9ab0eb18a2bb4f8fd65f0817f1a1707 /Parser
parentc3cb683d638e9d660c18a05293a576f98965166e (diff)
downloadcpython-593daf545bd9b7e7bcb27b498ecc6f36db9ae395.zip
cpython-593daf545bd9b7e7bcb27b498ecc6f36db9ae395.tar.gz
cpython-593daf545bd9b7e7bcb27b498ecc6f36db9ae395.tar.bz2
Renamed PyString to PyBytes
Diffstat (limited to 'Parser')
-rwxr-xr-xParser/asdl_c.py10
-rw-r--r--Parser/tokenizer.c32
2 files changed, 21 insertions, 21 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 25ff424..0d6c5c0 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -375,7 +375,7 @@ class Obj2ModVisitor(PickleVisitor):
# there's really nothing more we can do if this fails ...
self.emit("if (tmp == NULL) goto failed;", 1)
error = "expected some sort of %s, but got %%.400s" % name
- format = "PyErr_Format(PyExc_TypeError, \"%s\", PyString_AS_STRING(tmp));"
+ format = "PyErr_Format(PyExc_TypeError, \"%s\", PyBytes_AS_STRING(tmp));"
self.emit(format % error, 1, reflow=False)
self.emit("failed:", 0)
self.emit("Py_XDECREF(tmp);", 1)
@@ -704,7 +704,7 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
fnames = PyTuple_New(num_fields);
if (!fnames) return NULL;
for (i = 0; i < num_fields; i++) {
- PyObject *field = PyString_FromString(fields[i]);
+ PyObject *field = PyBytes_FromString(fields[i]);
if (!field) {
Py_DECREF(fnames);
return NULL;
@@ -723,7 +723,7 @@ static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
PyObject *s, *l = PyTuple_New(num_fields);
if (!l) return 0;
for(i = 0; i < num_fields; i++) {
- s = PyString_FromString(attrs[i]);
+ s = PyBytes_FromString(attrs[i]);
if (!s) {
Py_DECREF(l);
return 0;
@@ -797,7 +797,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
PyObject *s = PyObject_Repr(obj);
if (s == NULL) return 1;
PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",
- PyString_AS_STRING(s));
+ PyBytes_AS_STRING(s));
Py_DECREF(s);
return 1;
}
@@ -815,7 +815,7 @@ static int obj2ast_bool(PyObject* obj, bool* out, PyArena* arena)
PyObject *s = PyObject_Repr(obj);
if (s == NULL) return 1;
PyErr_Format(PyExc_ValueError, "invalid boolean value: %.400s",
- PyString_AS_STRING(s));
+ PyBytes_AS_STRING(s));
Py_DECREF(s);
return 1;
}
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 1d0a4aa..bce2bda 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -12,7 +12,7 @@
#ifndef PGEN
#include "unicodeobject.h"
-#include "stringobject.h"
+#include "bytesobject.h"
#include "fileobject.h"
#include "codecs.h"
#include "abstract.h"
@@ -344,7 +344,7 @@ check_bom(int get_char(struct tok_state *),
1) NULL: need to call tok->decoding_readline to get a new line
2) PyUnicodeObject *: decoding_feof has called tok->decoding_readline and
stored the result in tok->decoding_buffer
- 3) PyStringObject *: previous call to fp_readl did not have enough room
+ 3) PyBytesObject *: previous call to fp_readl did not have enough room
(in the s buffer) to copy entire contents of the line read
by tok->decoding_readline. tok->decoding_buffer has the overflow.
In this case, fp_readl is called in a loop (with an expanded buffer)
@@ -375,7 +375,7 @@ fp_readl(char *s, int size, struct tok_state *tok)
return error_ret(tok);
} else {
tok->decoding_buffer = NULL;
- if (PyString_CheckExact(buf))
+ if (PyBytes_CheckExact(buf))
utf8 = buf;
}
if (utf8 == NULL) {
@@ -384,10 +384,10 @@ fp_readl(char *s, int size, struct tok_state *tok)
if (utf8 == NULL)
return error_ret(tok);
}
- str = PyString_AsString(utf8);
- utf8len = PyString_GET_SIZE(utf8);
+ str = PyBytes_AsString(utf8);
+ utf8len = PyBytes_GET_SIZE(utf8);
if (utf8len > size) {
- tok->decoding_buffer = PyString_FromStringAndSize(str+size, utf8len-size);
+ tok->decoding_buffer = PyBytes_FromStringAndSize(str+size, utf8len-size);
if (tok->decoding_buffer == NULL) {
Py_DECREF(utf8);
return error_ret(tok);
@@ -591,7 +591,7 @@ decode_str(const char *str, struct tok_state *tok)
utf8 = translate_into_utf8(str, tok->enc);
if (utf8 == NULL)
return error_ret(tok);
- str = PyString_AsString(utf8);
+ str = PyBytes_AsString(utf8);
}
#endif
for (s = str;; s++) {
@@ -624,7 +624,7 @@ decode_str(const char *str, struct tok_state *tok)
"unknown encoding: %s", tok->enc);
return error_ret(tok);
}
- str = PyString_AsString(utf8);
+ str = PyBytes_AsString(utf8);
}
#endif
assert(tok->decoding_buffer == NULL);
@@ -706,11 +706,11 @@ tok_stdin_decode(struct tok_state *tok, char **inp)
return 0;
enc = ((PyFileObject *)sysstdin)->f_encoding;
- if (enc == NULL || !PyString_Check(enc))
+ if (enc == NULL || !PyBytes_Check(enc))
return 0;
Py_INCREF(enc);
- encoding = PyString_AsString(enc);
+ encoding = PyBytes_AsString(enc);
decoded = PyUnicode_Decode(*inp, strlen(*inp), encoding, NULL);
if (decoded == NULL)
goto error_clear;
@@ -720,9 +720,9 @@ tok_stdin_decode(struct tok_state *tok, char **inp)
if (utf8 == NULL)
goto error_clear;
- assert(PyString_Check(utf8));
- converted = new_string(PyString_AS_STRING(utf8),
- PyString_GET_SIZE(utf8));
+ assert(PyBytes_Check(utf8));
+ converted = new_string(PyBytes_AS_STRING(utf8),
+ PyBytes_GET_SIZE(utf8));
Py_DECREF(utf8);
if (converted == NULL)
goto error_nomem;
@@ -1609,8 +1609,8 @@ PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int *offset)
/* convert source to original encondig */
PyObject *lineobj = dec_utf8(tok->encoding, tok->buf, len);
if (lineobj != NULL) {
- int linelen = PyString_Size(lineobj);
- const char *line = PyString_AsString(lineobj);
+ int linelen = PyBytes_Size(lineobj);
+ const char *line = PyBytes_AsString(lineobj);
text = PyObject_MALLOC(linelen + 1);
if (text != NULL && line != NULL) {
if (linelen)
@@ -1624,7 +1624,7 @@ PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int *offset)
PyObject *offsetobj = dec_utf8(tok->encoding,
tok->buf, *offset-1);
if (offsetobj) {
- *offset = PyString_Size(offsetobj) + 1;
+ *offset = PyBytes_Size(offsetobj) + 1;
Py_DECREF(offsetobj);
}
}