Menu

#694 TypeError: 'str' does not support the buffer interface in ResourceUpdate

v1.0 (example)
open
nobody
None
5
2015-05-20
2015-05-15
dcortesi
No

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.

Discussion

  • Mark Hammond

    Mark Hammond - 2015-05-20

    I don't quite follow - I expect you want to pass bytes rather than a string on py3k?

     
  • dcortesi

    dcortesi - 2015-05-20

    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.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.