[python-ldap] syncrepl fix for pyasn1 >= 0.3

Ilya Etingof ilya at glas.net
Sat Nov 11 15:55:56 EST 2017

Hi Michael,

Thanks for looking in this!

> On 11 Nov 2017, at 20:56, Michael Ströder <michael at stroeder.com> wrote:
> Michael Ströder wrote:
>> All people installing/upgrading
>> from PyPI would be happy with python-ldap 2.5.x and pyasn1 0.3.x.
> I've decided to start 2.5.0 incorporating this patch without the
> backward-compability expressions. But I have some doubts.
> For example in class SSSResponseControl I now see this code:
>        attribute_type_error = p.getComponentByName('attributeType')
>        if attribute_type_error.hasValue():
>            self.attribute_type_error = attribute_type_error
> This does not set class attribute attribute_type_error at all in case
> there was no error. So this also changes the API for the calling
> application because instead of checking for
>   foo_sss.attribute_type_error is None
> it has to check for
>   hasattr(foo_sss, ‘attribute_type_error')

I might be looking at the wrong patch:


But there the instance attribute `attribute_type_error` is always set to either `None` or a value object.

Please, point me to the right patch to take a look. The behavior you described looks backward-incompatible indeed!

> Hmm, I could implement a custom ResponseControl.__getattr__() which
> returns None in case of non-existent but known class attributes.

Hold on! May be we could keep things simpler! ;-)

> But frankly it would be more nice if pyasn1 method getComponentByName()
> would take another optional parameter for default value returned in case
> of .hasValue()==False.
> So I could simply define a default value (here None)
>   p.getComponentByName('attributeType', None)
> and be done with it. This would avoid a lot of if-statements with
> .hasValue() and the ResponseControl.__getattr__() workaround.

Makes sense! Let me come up with an implementation shortly.

> Ciao, Michael.

More information about the python-ldap mailing list