Skip to content

Commit 3f737f5

Browse files
author
Łukasz Langa
committed
merge with upstream
2 parents b10636a + 973e82a commit 3f737f5

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
v0.9.7
5+
------
6+
7+
* Pastebin confirmation added; we were getting a lot of people accidentally
8+
pastebinning sensitive information so I think this is a good idea.
9+
410
v0.9.6.2
511
--------
612
Unfortunately another bugfix release as I (Bob) broke py3 support.

bpython/cli.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,9 @@ def clear_current_line(self):
339339
def clear_wrapped_lines(self):
340340
"""Clear the wrapped lines of the current input."""
341341
# curses does not handle this on its own. Sad.
342-
width = self.scr.getmaxyx()[1]
343-
for y in xrange(self.iy + 1, self.iy + len(self.s) // width + 1):
342+
height, width = self.scr.getmaxyx()
343+
max_y = min(self.iy + (self.ix + len(self.s)) // width + 1, height)
344+
for y in xrange(self.iy + 1, max_y):
344345
self.scr.move(y, 0)
345346
self.scr.clrtoeol()
346347

@@ -478,12 +479,7 @@ def fwd(self):
478479
"""Same as back() but, well, forward"""
479480

480481
self.cpos = 0
481-
482-
width = self.scr.getmaxyx()[1]
483-
for y in xrange(self.iy + 1, self.iy + len(self.s) // width + 1):
484-
self.scr.move(y, 0)
485-
self.scr.clrtoeol()
486-
482+
self.clear_wrapped_lines()
487483
self.rl_history.enter(self.s)
488484
self.s = self.rl_history.forward()
489485
self.print_line(self.s, clr=True)
@@ -1215,8 +1211,8 @@ def undo(self, n=1):
12151211

12161212
def writetb(self, lines):
12171213
for line in lines:
1218-
self.echo('\x01%s\x03%s' % (self.config.color_scheme['error'],
1219-
line))
1214+
self.write('\x01%s\x03%s' % (self.config.color_scheme['error'],
1215+
line))
12201216

12211217
def yank_from_buffer(self):
12221218
"""Paste the text from the cut buffer at the current cursor location"""
@@ -1394,7 +1390,7 @@ def init_wins(scr, colors, config):
13941390
# This should show to be configured keys from ~/.bpython/config
13951391
#
13961392
statusbar = Statusbar(scr, main_win, background, config,
1397-
" <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
1393+
" <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
13981394
(config.undo_key, config.save_key,
13991395
config.pastebin_key, config.last_output_key,
14001396
config.show_source_key),

bpython/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def loadini(struct, configfile):
4545
'paste_time': 0.02,
4646
'syntax': True,
4747
'tab_length': 4,
48+
'pastebin_confirm': True,
49+
'pastebin_private': False,
4850
'pastebin_url': 'http://bpaste.net/xmlrpc/',
4951
'pastebin_show_url': 'http://bpaste.net/show/$paste_id/',
5052
},
@@ -92,6 +94,8 @@ def loadini(struct, configfile):
9294
struct.exit_key = config.get('keyboard', 'exit')
9395
struct.last_output_key = config.get('keyboard', 'last_output')
9496

97+
struct.pastebin_confirm = config.getboolean('general', 'pastebin_confirm')
98+
struct.pastebin_private = config.getboolean('general', 'pastebin_private')
9599
struct.pastebin_url = config.get('general', 'pastebin_url')
96100
struct.pastebin_show_url = config.get('general', 'pastebin_show_url')
97101

bpython/repl.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
from bpython import importcompletion, inspection
4747
from bpython.formatter import Parenthesis
4848

49+
# Needed for special handling of __abstractmethods__
50+
# abc only exists since 2.6, so check both that it exists and that it's
51+
# the one we're expecting
52+
try:
53+
import abc
54+
abc.ABCMeta
55+
has_abc = True
56+
except (ImportError, AttributeError):
57+
has_abc = False
58+
4959
py3 = sys.version_info[0] == 3
5060

5161

@@ -339,6 +349,11 @@ def attr_lookup(self, obj, expr, attr):
339349
if hasattr(obj, '__class__'):
340350
words.append('__class__')
341351
words = words + rlcompleter.get_class_members(obj.__class__)
352+
if has_abc and not isinstance(obj.__class__, abc.ABCMeta):
353+
try:
354+
words.remove('__abstractmethods__')
355+
except ValueError:
356+
pass
342357

343358
matches = []
344359
n = len(attr)
@@ -625,6 +640,13 @@ def write2file(self):
625640
def pastebin(self):
626641
"""Upload to a pastebin and display the URL in the status bar."""
627642

643+
if (self.config.pastebin_confirm and
644+
not self.statusbar.prompt("Pastebin buffer? (y/N) "
645+
).lower().startswith('y'
646+
)):
647+
self.statusbar.message("Pastebin aborted")
648+
return
649+
628650
pasteservice = ServerProxy(self.config.pastebin_url)
629651

630652
s = self.getstdout()

0 commit comments

Comments
 (0)