Brew and lxml for Plone 5.2

Would you give a hint how you force lxml to be build against the brew installed libxml and libxslt. Im lost after several ways of pinning.
(Macbook Big Sur with Terminal Rosetta)

Well ... this was before I used pyenv. Now with pyenv I do not need any special brew compiled libxml magic anymore. So I assumed this is the better way to go.

Nevertheless you can use brew compiled libxml/libxslt if you set the PKG_CONFIG_PATH in your terminal to the pkgconfig directory in your libraries (if existing) ... there's a stackoverflow pointing to the directories here macos - configure script cannot find libxml2 on mac - Stack Overflow

How did you manage to use pyenv so that you won't need a brew compiled libxml?
For me, it doesn't work either with macOS or brew libxml, I keep getting:

lxml.etree.ParserError: Unicode parsing is not supported on this platform

@lyralemos This is a very strange issue that I started experiencing 2 months ago on an M1 Mac as well. Until now it only happens for me when Mosaic layouts and Diazo are involved in Plone 5.2/Python3 and the culprit for me was/is repoze.xmliter. It receives chunks of content from the source/content and feeds them to lxml, but the encoding is missing/wrong and then lxml throws this very uninformative "Unicode parsing is not suppported" message.

I also spent a few hours to reinstall libxml/libxslt libraries and though the problem was in the python bindings going to maybe outdated MacosX.sdk versions of libxml. This 3 line patch fixes the error for me locally:

I've created an iterim release with this patch at

So far I have blamed this on the M1 architecture but a colleague with an Intel Mac but also Big Sur experienced similar issues 2 weeks ago, I added this patch version to the buildout and haven't heard back, but still have to follow up my curiosiity with him if this really solved the problem or had another cause.

@fredvd I also have an Intel Mac with Big Sur, I was getting the error in BrowserViews with IBlocksTransformEnabled.

I've applied your patch locally and it solved the problem.

hi fred, please pr and merge

I think its beter for the long term if someone knowledgable on the tiles/blocks tranforms first figures out the root cause of this error. This fix patches the faulty data/missing encoding in the stream before it goes into lxml for Diazo, but it should not happen in the first place.

It triggers on my local development machine where the identical content db and code base and python version on a linux server in production has no issues whatsoever.

I am pretty sure this is related to the behavior and how it stores layouts.

@fredvd could you try out Fix unicode parsing error with Python 3 by agitator · Pull Request #85 · plone/ · GitHub
After some digging and detours, ended up with the same solution as @ksuess :+1:


Yes, that fixes the issue we see in our sites. If I remove the repoze.xmliter patch the lxml.etree.ParserError: Unicode parsing is not supported on this platform error appears on Mosaic layouts. When I add your PR with the Py3 fixes it disappears again.

Good searching. :face_with_monocle: Did you know about this CR+LF method?

Plone Foundation Code of Conduct