Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'encoding': 0.05; 'attribute': 0.07; 'binary': 0.07; 'encoded': 0.07; 'strings.': 0.09; 'subject:module': 0.09; 'attempted': 0.16; 'dict': 0.16; 'expects': 0.16; 'ldif': 0.16; 'michael,': 0.16; 'non-ascii': 0.16; 'overriding': 0.16; 'received:172.18.0': 0.16; 'stumbled': 0.16; 'yup,': 0.16; 'module': 0.19; 'passing': 0.19; 'properly': 0.19; 'work,': 0.20; 'seems': 0.21; 'to:name:python- list@python.org': 0.22; 'this?': 0.23; 'byte': 0.24; 'entries': 0.24; 'unicode': 0.24; 'handling': 0.26; 'pass': 0.26; 'skip:_ 20': 0.27; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'idea': 0.28; 'character': 0.29; 'mode': 0.30; 'see,': 0.30; 'went': 0.31; 'code': 0.31; 'option': 0.32; 'open': 0.33; 'raw': 0.33; 'moment': 0.34; 'could': 0.34; 'knowledge': 0.35; 'convert': 0.35; 'but': 0.35; 'module.': 0.36; 'entry': 0.36; 'thanks': 0.36; 'application': 0.37; 'to:addr:python-list': 0.38; 'files': 0.38; 'expect': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:unknown': 0.61; 'today,': 0.61; 'simply': 0.61; "you're": 0.61; 'first': 0.61; 'making': 0.63; 'more': 0.64; 'therefore': 0.72; 'to:charset:iso-8859-1': 0.74 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=x4wvebh7U2otgv2g1Q/ELETKOrtBkVhBqv1eL6GwWag= c=1 sm=1 a=P90J6pEA2ccA:10 a=xv9iwkAQU-cA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=8nJEP1OIZ-IA:10 a=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=E47vONwXPlxBwylaY8wA:9 a=wPNLvfGTeEIA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 From: "Joseph L. Casale" To: =?iso-8859-1?Q?Michael_Str=F6der?= , "python-list@python.org" Subject: RE: Ldap module and base64 oncoding Thread-Topic: Ldap module and base64 oncoding Thread-Index: AQHOWq+62gcVydFyA0eXB9j8yy7c/ZkZeivw Date: Tue, 28 May 2013 00:12:58 +0000 References: , , , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.18.0.4] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369699988 news.xs4all.nl 15917 [2001:888:2000:d::a6]:35528 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46235 > Note that all modules in python-ldap up to 2.4.10 including module 'ldif'= =0A= > expect raw byte strings to be passed as arguments. It seems to me you're= =0A= > passing a Unicode object in the entry dictionary which will fail in case = an=0A= > attribute value contains NON-ASCII chars.=0A= =0A= Yup, I was.=0A= =0A= > python-ldap expects raw strings since it's not schema-aware and therefore= does=0A= > not have any knowledge about the LDAP syntax used for a particular attrib= ute=0A= > type. So automagically convert Unicode strings will likely fail in many c= ases.=0A= > =3D> The calling application has to deal with it.=0A= =0A= I see, that recco went a long a way in cleaning up my code actually and mak= ing the=0A= handling of decoding and encoding more consistent.=0A= =0A= > Don't muck with overriding _unparseAttrTypeandValue(). Simply pass the= =0A= > properly encoded data into ldif module.=0A= =0A= I had some time today, so I attempted to open the ldif files in binary mode= to simply=0A= work with the raw byte strings but the moment the first entry was parsed, p= arse()=0A= stumbled on a character in the first entries dict and passed a dn of None f= or the last half?=0A= =0A= If the option to avoid worrying about decoding and encoding could work, I w= ould be=0A= happy to process the whole lot in byte strings. Any idea what may cause thi= s?=0A= =0A= Thanks a lot Michael,=0A= jlc=