-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os.system causes TypeError in Python 3 #2452
Comments
I can't reproduce it with master branch on Linux. |
@stonebig - can you reproduce this on Windows? |
Winpython3.4.3.3-64bit/Spyder2.3.4/French windows7-64bit: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> import os
>>>
>>> command = "echo x"
>>> response = os.system(command)
x
>>> print(response)
0
>>> Shots in the dark:
|
What if you create a script and run it in the current IPython console ? |
@jondo, maybe your coworker is using an old Spyder version. We fixed a lot of unicode bugs for the Python console in 2.3.2. |
I have now found out that I can only reliably reproduce this bug when I use command = "ping -n 1 127.0.0.1" instead. I am using German Windows 7,64 bit, and I now did a fresh install of the current When I alternatively paste the code line by line into the Python console after a fresh start of Spyder.exe, I see: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> import os
>>> command = "ping -n 1 127.0.0.1"
>>> response = os.system(command) and after entering this, the internal console opens with: Spyder Internal Console
This console is used to report application
internal errors and to inspect Spyder
internals with the following commands:
spy.app, spy.window, dir(spy)
Please don't use it to run your code
>>> D:\RobertPollak\WinPython-64bit-3.4.3.3\python-3.4.3.amd64\lib\site-packages\IPython\nbformat\current.py:19: UserWarning: IPython.nbformat.current is deprecated.
- use IPython.nbformat for read/write/validate public API
- use IPython.nbformat.vX directly to composing notebooks of a particular version
""")
Traceback (most recent call last):
File "D:\RobertPollak\WinPython-64bit-3.4.3.3\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\externalshell\baseshell.py", line 285, in write_output
self.shell.write(self.get_stdout(), flush=True)
File "D:\RobertPollak\WinPython-64bit-3.4.3.3\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\shell.py", line 572, in write
self.flush(error=error, prompt=prompt)
File "D:\RobertPollak\WinPython-64bit-3.4.3.3\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\shell.py", line 581, in flush
text = "".join(self.__buffer)
TypeError: sequence item 0: expected str instance, bytes found
Traceback (most recent call last):
File "D:\RobertPollak\WinPython-64bit-3.4.3.3\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\externalshell\pythonshell.py", line 563, in write_error
self.shell.write_error(self.get_stderr())
File "D:\RobertPollak\WinPython-64bit-3.4.3.3\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\shell.py", line 557, in write_error
self.flush()
File "D:\RobertPollak\WinPython-64bit-3.4.3.3\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\shell.py", line 581, in flush
text = "".join(self.__buffer)
TypeError: sequence item 0: expected str instance, bytes found (My colleague, who also sees this issue, is on the same OS and has never had any Python version installed on his machine before. He has also got a fresh install of |
ok, now I have an error message too: Console interne de Spyder
Il s'agit d'une console de débogage
utilisée par Spyder pour signaler des erreurs
internes ou pour inspecter les entrailles de
l'application avec les commandes ci-dessous :
spy.app, spy.window, dir(spy)
Ne l'utilisez pas pour exécuter votre propre code.
>>> D:\result_tests\winpython-3.4.3.3.amd64\python-3.4.3.amd64\lib\site-packages\IPython\nbformat\current.py:19: UserWarning: IPython.nbformat.current is deprecated.
- use IPython.nbformat for read/write/validate public API
- use IPython.nbformat.vX directly to composing notebooks of a particular version
""")
Traceback (most recent call last):
Traceback (most recent call last):
File "D:\result_tests\winpython-3.4.3.3.amd64\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\externalshell\pythonshell.py", line 563, in write_error
self.shell.write_error(self.get_stderr())
File "D:\result_tests\winpython-3.4.3.3.amd64\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\shell.py", line 557, in write_error
self.flush()
File "D:\result_tests\winpython-3.4.3.3.amd64\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\shell.py", line 581, in flush
text = "".join(self.__buffer)
TypeError: sequence item 0: expected str instance, bytes found
File "D:\result_tests\winpython-3.4.3.3.amd64\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\externalshell\baseshell.py", line 285, in write_output
self.shell.write(self.get_stdout(), flush=True)
File "D:\result_tests\winpython-3.4.3.3.amd64\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\shell.py", line 572, in write
self.flush(error=error, prompt=prompt)
File "D:\result_tests\winpython-3.4.3.3.amd64\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\shell.py", line 581, in flush
text = "".join(self.__buffer)
TypeError: sequence item 0: expected str instance, bytes found
Traceback (most recent call last):
File "D:\result_tests\winpython-3.4.3.3.amd64\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\shell.py", line 823, in paste
self.execute_lines(lines)
File "D:\result_tests\winpython-3.4.3.3.amd64\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\externalshell\pythonshell.py", line 70, in execute_lines
self.flush()
File "D:\result_tests\winpython-3.4.3.3.amd64\python-3.4.3.amd64\lib\site-packages\spyderlib\widgets\shell.py", line 581, in flush
text = "".join(self.__buffer)
TypeError: sequence item 0: expected str instance, bytes found |
so, the ping result give some non-ascii character, in French So I assume In German too:
If I replace your command:
==> I guess the nota: it's a bit curious that on the Ipython Qtconsole of spyder:
|
as a bit of fun, this works perfectly on the Ipython Qtconsole of spyder:
|
Yes, I can also reproduce this with os.system("echo é") And the German ping output has a non-ascii character:
The reason for my originally wrong test case was that the error "sticks" until Spyder is restarted: When the error has appeared once, it also appears on |
I guess that the error sticks because the output buffer is not emptied on error and still contains non-ascii chars. |
Here's my test case:
When I run this in WinPython-64bit-3.4.3.3, Spyder's "Internal console" opens and displays
Switching back to the IPython console, I see that the response
0
has been printed correctly, though.In WinPython-64bit-2.7.9.4, the test case runs without error.
The text was updated successfully, but these errors were encountered: