Skip to content

Fix TypeError when using F2 without some source #614

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

Merged
merged 1 commit into from
Jun 2, 2016

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented May 31, 2016

  File "/usr/lib/python3.5/site-packages/bpython/cli.py", line 977, in p_key
    self.statusbar.message(_(e))
  File "/usr/lib/python3.5/site-packages/bpython/cli.py", line 1605, in message
    self.settext(s)
  File "/usr/lib/python3.5/site-packages/bpython/cli.py", line 1655, in settext
    if len(s) >= self.w:
TypeError: object of type 'SourceNotFound' has no len()

I have used the same code as with bpython/curtsiesfrontend/repl.py.

@blueyed blueyed force-pushed the fix-f2-without-source-in-cli branch from 55b9c7a to d1fe7e9 Compare May 31, 2016 18:13
@@ -974,7 +974,7 @@ def p_key(self, key):
try:
source = self.get_source_of_current_name()
except repl.SourceNotFound as e:
self.statusbar.message(_(e))
self.status_bar.message('%s' % (e, ))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply str(e)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I had before, but then found the code in bpython/curtsiesfrontend/repl.py doing this.
Let's change both to use str then?

@sebastinas
Copy link
Contributor

Changing both to str sounds like a good plan.

@blueyed
Copy link
Contributor Author

blueyed commented May 31, 2016

Do you want that to be in two commits?

@sebastinas
Copy link
Contributor

I don't have a strong preference either way.

      File "/usr/lib/python3.5/site-packages/bpython/cli.py", line 977, in p_key
        self.statusbar.message(_(e))
      File "/usr/lib/python3.5/site-packages/bpython/cli.py", line 1605, in message
        self.settext(s)
      File "/usr/lib/python3.5/site-packages/bpython/cli.py", line 1655, in settext
        if len(s) >= self.w:
    TypeError: object of type 'SourceNotFound' has no len()

This also adjust the string formatting in `bpython/curtsiesfrontend/repl.py`.
@blueyed blueyed force-pushed the fix-f2-without-source-in-cli branch from d1fe7e9 to 325d3bb Compare June 2, 2016 19:48
@blueyed
Copy link
Contributor Author

blueyed commented Jun 2, 2016

Done.

@sebastinas sebastinas merged commit 937865a into bpython:master Jun 2, 2016
@blueyed blueyed deleted the fix-f2-without-source-in-cli branch June 2, 2016 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants