-
Kirill Smelkov authored
In bbbb58f0 (golang_str: bstr/ustr support for + and *) I've added support for binary string operations, but similarly to __eq__ did not handle correctly the case for arbitrary arguments that potentially define __radd__ and similar. As the result it breaks when running e.g. bstr + pyparsing.Regex File ".../pyparsing-2.4.7-py2.7.egg/pyparsing.py", line 6591, in pyparsing_common _full_ipv6_address = (_ipv6_part + (':' + _ipv6_part) * 7).setName("full IPv6 address") File "golang/_golang_str.pyx", line 469, in golang._golang._pybstr.__add__ return pyb(zbytes.__add__(a, _pyb_coerce(b))) File "golang/_golang_str.pyx", line 243, in golang._golang._pyb_coerce raise TypeError("b: coerce: invalid type %s" % type(x)) TypeError: b: coerce: invalid type <class 'pyparsing.Regex'> because pyparsing.Regex is a type, that does not inherit from str, but defines its own __radd__ to handle str + Regex as Regex. -> Fix it by returning NotImplemented from under __add__ and other operations where it is needed so that bstr and ustr behave in the same way as builtin str wrt third types, but care to handle bstr/ustr promise that only explicit conversion through `b` and `u` accept objects with buffer interface. Automatic coercion does not.
aa5d2f91