The branch, master has been updated
       via  6a3c687 pidl/python: Allow passing in UTF8 string objects as well 
as unicode objects for IDL strings.
      from  d86d225 s3:services_db: convert get_common_service_dispname() to 
talloc

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 6a3c687f039f8f6cfeb8d12d81cd71157ad43ddd
Author: Jelmer Vernooij <[email protected]>
Date:   Mon Sep 20 22:18:45 2010 -0700

    pidl/python: Allow passing in UTF8 string objects as well as unicode
    objects for IDL strings.
    
    Signed-off-by: Andrew Tridgell <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 pidl/lib/Parse/Pidl/Samba4/Python.pm |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm 
b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index d4db4c0..ed43ba4 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);");


-- 
Samba Shared Repository

Reply via email to