Sublime Forum

ST3 Plugin error 'str' does not support the buffer interface

#1

Hello,

I am trying to code a very basic plugin for ST3. Right from the start, with the following (dummy) code:[code]import sublime, sublime_plugin
from subprocess import Popen, PIPE, STDOUT

class RunPhpCommand(sublime_plugin.TextCommand):
def run(self, edit):
php = Popen(’/usr/bin/php’], stdout=PIPE, stdin=PIPE)
php.stdin.write(“test”)[/code]… I get this error: Error: Traceback (most recent call last): File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_ return self.run(edit) File "/Volumes/Utilisateurs/kofkof/Library/Application Support/Sublime Text 3/Packages/User/RunPhpCommand.py", line 7, in run php.stdin.write("test") TypeError: 'str' does not support the buffer interface
I don’t understand this error message. My code doesn’t even have a ‘str’ variable. Does anyone have an idea that could help me?
Thanks.

0 Likes

#2

Just found the answer. In case it can help anybody:

php.stdin.write("test")should be:

php.stdin.write(bytes("test", "UTF-8"))
0 Likes