TypeError: 'str' does not support the buffer interface in ResourceUpdate
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
This occurs in PyInstaller when trying to update a Manifest. The version is pywin32-219.win-amd64-py3.4. The call is
win32api.UpdateResource(hdst, type_, name, data, language)
where hdst=63307784, type_=24, name=1, language=0 and data=
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyIdentity name="PPQT2" processorArchitecture="amd64" type="win32" version="1.0.0.0"/></assembly>'
The "str does not support the buffer interface" error is a very common Python3 problem, indicating passing a str to a file opened as raw bytes.
I don't quite follow - I expect you want to pass bytes rather than a string on py3k?
The point is, under Python 3, if the caller passes a str this error will be thrown. This would be a common mistake in code converted from Python 2. The PyInstaller maintainer agreed, yeah, the Windows API call this goes into, takes a void* type of input which should be passed as raw bytes. So not technically a bug for win32api.
But the error message is very unhelpful. It would be cool if your code did the equivalent of "if isinstance(arg, str): raise TypeError". It would make it easier to diagnose.