Skip to content

Commit 4a82f5f

Browse files
committed
Bugfix patches from Menno (menno@freshfoo.com)
0001-Handle-network-errors-when-posting-to-pastebin.patch 0002-Avoid-crash-when-sizing-the-terminal-window-to-be-qu.patch Thanks, Menno. xxx committer: Bob Farrell <robertanthonyfarrell@gmail.com>
1 parent 2b932d7 commit 4a82f5f

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎bpython/cli.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import fcntl
4444
import string
4545
import shlex
46+
import socket
4647
import pydoc
4748
import cStringIO
4849

@@ -713,8 +714,12 @@ def pastebin(self):
713714
pdata = urllib.urlencode(pdata)
714715

715716
self.statusbar.message('Posting data to pastebin...')
716-
u = urllib.urlopen(url, data=pdata)
717-
d = u.read()
717+
try:
718+
u = urllib.urlopen(url, data=pdata)
719+
d = u.read()
720+
except (socket.error, socket.timeout, IOError), e:
721+
self.statusbar.message( 'Upload failed: %s' % str(e) )
722+
return
718723

719724
rx = re.search('(http://rafb.net/p/[0-9a-zA-Z]+\.html)', d)
720725
if not rx:
@@ -928,6 +933,7 @@ def resize(self):
928933
self.scr.erase()
929934
self.scr.resize(self.h, self.w)
930935
self.scr.mvwin(self.y, self.x)
936+
self.statusbar.resize(refresh=False)
931937
self.redraw()
932938

933939
def write(self, s):
@@ -1422,13 +1428,14 @@ def size(self):
14221428
self.h = 1
14231429
self.x = 0
14241430

1425-
def resize(self):
1431+
def resize(self, refresh=True):
14261432
"""This method exists simply to keep it straight forward when
14271433
initialising a window and resizing it."""
14281434
self.size()
14291435
self.win.mvwin(self.y, self.x)
14301436
self.win.resize(self.h, self.w)
1431-
self.refresh()
1437+
if refresh:
1438+
self.refresh()
14321439

14331440
def refresh(self):
14341441
"""This is here to make sure the status bar text is redraw properly
@@ -1598,7 +1605,6 @@ def do_resize(caller):
15981605
DO_RESIZE = False
15991606

16001607
caller.resize()
1601-
caller.statusbar.resize()
16021608
# The list win resizes itself every time it appears so no need to do it here.
16031609

16041610

0 commit comments

Comments
 (0)