Skip to content
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

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

Closed
femibyte opened this issue Sep 26, 2012 · 5 comments · Fixed by #3854
Closed

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

femibyte opened this issue Sep 26, 2012 · 5 comments · Fixed by #3854
Assignees
Labels
Milestone

Comments

@femibyte
Copy link

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
Copy link
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.

@reece
Copy link

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
Copy link
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?

@reece
Copy link

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
Copy link
Member

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

minrk added a commit that referenced this issue Jul 31, 2013
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
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 ipython#2431
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants