Home Download Buy Blog Forum Support

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

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

Postby kofkof on Wed Jul 24, 2013 7:08 pm

Hello,

I am trying to code a very basic plugin for ST3. Right from the start, with the following (dummy) code:
Code: Select all
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")
... I get this error:
Code: Select all
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.
kofkof
 
Posts: 7
Joined: Thu Nov 01, 2012 5:03 pm

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

Postby kofkof on Thu Jul 25, 2013 10:42 am

Just found the answer. In case it can help anybody:
Code: Select all
php.stdin.write("test")
should be:
Code: Select all
php.stdin.write(bytes("test", "UTF-8"))
kofkof
 
Posts: 7
Joined: Thu Nov 01, 2012 5:03 pm


Return to Plugin Development

Who is online

Users browsing this forum: Exabot [Bot] and 3 guests