2

When I try to submit code from Sublime Text 3 to a python3 interpreter (I'm using 3.2.3) using SublimeREPL, I get the following error:

>>> x = -9
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' does not support the buffer interface
>>> 

(I'm on Ubuntu 12.04; Sublime Text 3 Build 3047.)

The error doesn't appear if I use a python-2.x interpreter

Someone else had the same problem and opened an issue in the SublimeREPL github but it was marked as not reproducible. Can anyone point me in the right direction to get rid of this?

I'm brand new to Sublime Text, so perhaps I'm doing something else stupid. Here's the menu command I'm using to launch python3 (I tried both buffered and unbuffered):

            {"command": "repl_open",
             "caption": "Python3",
             "id": "repl_python3",
             "mnemonic": "p",
             "args": {
                "type": "subprocess",
                "encoding": "utf8",
                "cmd": ["python3", "-i", "-u"],
                "cwd": "$file_path",
                "syntax": "Packages/Python/Python.tmLanguage",
                "external_id": "python",
                "extend_env": {"PYTHONIOENCODING": "utf-8"}
                }
            }
cauchy
  • 198
  • 8
  • what happens if you run python from the command line and try the same thing? – MattDMo Oct 08 '13 at 21:35
  • From [this](http://stackoverflow.com/a/5471351/2816475) answer: "If you use Python3x then string is not the same type as for Python 2.x, you must cast it to bytes (encode it)." Your error is not related to the SublimeREPL. You just use bad approach for Python3 programming. – Ronin Oct 09 '13 at 01:54
  • @MattDMo: Things work fine from the command line. Things also work fine using PyDev within Eclipse and the same python 3.2.3 interpreter. And things work fine in Sublime Text with a python 2.x interpreter. – cauchy Oct 09 '13 at 02:09
  • @SergeyRonin: I'm not sure if you read my question. This is not a problem with the way I'm using python3--the code example above, for example, doesn't use anything specific to python3. This is an issue with the way SublimeREPL integrates python3 and Sublime Text. This must be a rather limited problem and not a general bug, since many, many people use ST3 with python3. I'm just looking for any thoughts that might help me fix it. – cauchy Oct 09 '13 at 02:13
  • For anyone who finds this later: I never solved the problem directly. I think there's something wrong with my python-3.2.3 installation, but it's the default with Ubuntu 12.04, so you can't fully remove it, and reinstalling didn't help. What finally did work was to install python-3.3.2 as a separate interpreter and launch that directly; it works as it should in ST3. – cauchy Oct 10 '13 at 16:32

0 Answers0