On 01/12/2016 10:24 AM, Jan Cholasta wrote: > On 6.1.2016 12:33, Christian Heimes wrote: >> On 2016-01-05 11:30, Tomas Babej wrote: >>> >>> >>> On 01/05/2016 08:54 AM, Jan Cholasta wrote: >>>> Hi, >>>> >>>> the attached patch replaces the default_encoding_utf8 binary module >>>> with >>>> 2 lines of equivalent Python code. >>>> >>>> Honza >>>> >>>> >>>> >>> >>> This looks fine to me, however, I wonder, why this approach was ever >>> taken? The sys.setdefaultencoding is available in all versions of Python >>> ever supported by FreeIPA. >>> >>> Is it possible we're missing something here? Or was this option simply >>> overlooked? >> >> sys.setdefaultencoding() is not available unless you use a hack and >> reload the sys module. The function is hidden for a very good reason. It >> can and will break internal assumption as well as libraries in bad, hard >> to detect ways. For example it wreaks havoc on hashing for dicts and >> sets. >> >> The blog posting >> https://anonbadger.wordpress.com/2015/06/16/why-sys-setdefaultencoding-will-break-code/ >> >> explains the problem in much greater detail. > > Tomáši, does this answer your question? >
Not really, I was more curious as to why the current, more complex solution using the C extension was ever preferred over pure python version. > Updated patch attached. Patch works fine, ACK. Pushed to master: 7e56b4bbd79d9d42af23babc7496dd15d85d28ea Tomas -- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code