summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c14
-rw-r--r--Python/marshal.c11
2 files changed, 20 insertions, 5 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 4aa9c62..20746fa 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1451,14 +1451,24 @@ builtin_ord(PyObject *self, PyObject* obj)
return PyInt_FromLong(ord);
}
#ifdef Py_USING_UNICODE
- } else if (PyUnicode_Check(obj)) {
+ }
+ else if (PyUnicode_Check(obj)) {
size = PyUnicode_GET_SIZE(obj);
if (size == 1) {
ord = (long)*PyUnicode_AS_UNICODE(obj);
return PyInt_FromLong(ord);
}
#endif
- } else {
+ }
+ else if (PyBytes_Check(obj)) {
+ /* XXX Hopefully this is temporary */
+ size = PyBytes_GET_SIZE(obj);
+ if (size == 1) {
+ ord = (long)*PyBytes_AS_STRING(obj);
+ return PyInt_FromLong(ord);
+ }
+ }
+ else {
PyErr_Format(PyExc_TypeError,
"ord() expected string of length 1, but " \
"%.200s found", obj->ob_type->tp_name);
diff --git a/Python/marshal.c b/Python/marshal.c
index fd1bd72..2fb47e7 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -1062,9 +1062,14 @@ marshal_dump(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "OO|i:dump", &x, &f, &version))
return NULL;
if (!PyFile_Check(f)) {
- PyErr_SetString(PyExc_TypeError,
- "marshal.dump() 2nd arg must be file");
- return NULL;
+ /* XXX Quick hack -- need to do this differently */
+ PyObject *s = PyMarshal_WriteObjectToString(x, version);
+ PyObject *res = NULL;
+ if (s != NULL) {
+ res = PyObject_CallMethod(f, "write", "O", s);
+ Py_DECREF(s);
+ }
+ return res;
}
wf.fp = PyFile_AsFile(f);
wf.str = NULL;