TypeError: must be string without null bytes, not str #2431

Closed
femibyte opened this Issue Sep 26, 2012 · 5 comments

Comments

Projects
None yet
3 participants
@femibyte

Hi, I just installed iPython 2.7 under macports, and when I try to start it I get the following error:

$ /opt/local/bin/ipython-2.7 Traceback (most recent call last):
File "/opt/local/bin/ipython-2.7", line 7, in
launch_new_instance()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 388, in launch_new_instance
app.initialize()
File "", line 2, in initialize
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/config/application.py", line 84, in catch_config_error
return method(app, _args, *_kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 324, in initialize
self.init_shell()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", line 340, in init_shell
ipython_dir=self.ipython_dir)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/config/configurable.py", line 318, in instance
inst = cls(_args, *_kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/frontend/terminal/interactiveshell.py", line 360, in init
user_module=user_module, custom_exceptions=custom_exceptions
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 481, in init
self.init_readline()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 1868, in init_readline
self.refill_readline_hist()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 1886, in refill_readline_hist
stdin_encoding))
TypeError: must be string without null bytes, not str

If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
c.Application.verbose_crash=True

Can you help ? I am not sure what is wrong here.

@takluyver

This comment has been minimized.

Show comment Hide comment
@takluyver

takluyver Sep 26, 2012

Member

If you move your history.sqlite out of the way (don't delete it, we might want to check it to work out the problem), does it start OK? Run ipython locate profile to see where that file is located.

Member

takluyver commented Sep 26, 2012

If you move your history.sqlite out of the way (don't delete it, we might want to check it to work out the problem), does it start OK? Run ipython locate profile to see where that file is located.

@reece

This comment has been minimized.

Show comment Hide comment
@reece

reece Dec 20, 2012

I hit this too. Merely typing 'ipython' would yield the error in the original question. ipython 0.13.1, python 2.7.3.

Moving history.sqlite (in ~/.config/ipython/profile_default/) out of the way solved the problem.

This situation arose immediately after piping data into a script that did IPython.embed(). Might this have poisoned the history database. I see a bunch of illegible characters (not displayable in utf-8) in the history table.

reece commented Dec 20, 2012

I hit this too. Merely typing 'ipython' would yield the error in the original question. ipython 0.13.1, python 2.7.3.

Moving history.sqlite (in ~/.config/ipython/profile_default/) out of the way solved the problem.

This situation arose immediately after piping data into a script that did IPython.embed(). Might this have poisoned the history database. I see a bunch of illegible characters (not displayable in utf-8) in the history table.

@takluyver

This comment has been minimized.

Show comment Hide comment
@takluyver

takluyver Jan 20, 2013

Member

Can you send us a copy of the corrupt history.sqlite file? It has every command you've used in IPython 0.11+, so if it might contain confidential data that you don't want to send, we'll work out another way to investigate it.

It's possible that piping data in confused it. Can you produce a small example that reproduces the problem?

Member

takluyver commented Jan 20, 2013

Can you send us a copy of the corrupt history.sqlite file? It has every command you've used in IPython 0.11+, so if it might contain confidential data that you don't want to send, we'll work out another way to investigate it.

It's possible that piping data in confused it. Can you produce a small example that reproduces the problem?

@reece

This comment has been minimized.

Show comment Hide comment
@reece

reece Jan 22, 2013

I stripped the history to a minimal case that demonstrates the problem. See http://harts.net/reece/tmp/ipython-corrupt-history/ for the history file and a session log. Thanks for investigating.

reece commented Jan 22, 2013

I stripped the history to a minimal case that demonstrates the problem. See http://harts.net/reece/tmp/ipython-corrupt-history/ for the history file and a session log. Thanks for investigating.

@takluyver

This comment has been minimized.

Show comment Hide comment
@takluyver

takluyver Jul 31, 2013

Member

Sorry it took me so long to get to this - PR #3854 should fix it.

Member

takluyver commented Jul 31, 2013

Sorry it took me so long to get to this - PR #3854 should fix it.

@minrk minrk closed this in #3854 Jul 31, 2013

minrk added a commit that referenced this issue Jul 31, 2013

Merge pull request #3854 from takluyver/i2431
Catch errors filling readline history on startup

In some cases, the history db can be a valid SQLite database, but contain strings with null bytes, which readline refuses to accept. This catches and ignores the resulting error.

At present, it leaves the history database untouched, and keeps trying to load readline history: if just one entry is invalid, the rest of the history may still be useful to the user.

Closes #2431

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

Merge pull request #3854 from takluyver/i2431
Catch errors filling readline history on startup

In some cases, the history db can be a valid SQLite database, but contain strings with null bytes, which readline refuses to accept. This catches and ignores the resulting error.

At present, it leaves the history database untouched, and keeps trying to load readline history: if just one entry is invalid, the rest of the history may still be useful to the user.

Closes #2431
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment