summaryrefslogtreecommitdiff
path: root/pidl/lib/Parse/Pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-09-20 22:18:45 -0700
committerAndrew Tridgell <tridge@samba.org>2010-09-20 23:17:41 -0700
commit6a3c687f039f8f6cfeb8d12d81cd71157ad43ddd (patch)
tree204fa2cec56ff02bc38e5985566282d5d35a9771 /pidl/lib/Parse/Pidl
parentd86d2256b98e8975d536b85ba5221508642dea22 (diff)
downloadsamba-6a3c687f039f8f6cfeb8d12d81cd71157ad43ddd.tar.gz
samba-6a3c687f039f8f6cfeb8d12d81cd71157ad43ddd.tar.bz2
samba-6a3c687f039f8f6cfeb8d12d81cd71157ad43ddd.zip
pidl/python: Allow passing in UTF8 string objects as well as unicode
objects for IDL strings. Signed-off-by: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'pidl/lib/Parse/Pidl')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm14
1 files changed, 13 insertions, 1 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index d4db4c0834..ed43ba4d3e 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -987,9 +987,21 @@ sub ConvertObjectFromPythonLevel($$$$$$$$)
}
if (is_charset_array($e, $l)) {
- $self->pidl("PY_CHECK_TYPE(&PyUnicode_Type, $py_var, $fail);");
+ $self->pidl("if (PyUnicode_Check($py_var)) {");
+ $self->indent;
# FIXME: Use Unix charset setting rather than utf-8
$self->pidl($var_name . " = PyString_AsString(PyUnicode_AsEncodedString($py_var, \"utf-8\", \"ignore\"));");
+ $self->deindent;
+ $self->pidl("} else if (PyString_Check($py_var)) {");
+ $self->indent;
+ $self->pidl($var_name . " = PyString_AsString($py_var);");
+ $self->deindent;
+ $self->pidl("} else {");
+ $self->indent;
+ $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected string or unicode object, got %s\", Py_TYPE($py_var)->tp_name);");
+ $self->pidl("$fail;");
+ $self->deindent;
+ $self->pidl("}");
} else {
my $counter = "$e->{NAME}_cntr_$l->{LEVEL_INDEX}";
$self->pidl("PY_CHECK_TYPE(&PyList_Type, $py_var, $fail);");