Skip to content

Commit 047d831

Browse files
committed
Merge in main branch with wizard branch to keep up to date
2 parents dcfffb5 + eadda42 commit 047d831

File tree

14 files changed

+125
-35
lines changed

14 files changed

+125
-35
lines changed

CHANGELOG

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Changelog
22
=========
33

4+
v0.9.6.2
5+
--------
6+
Unfortunately another bugfix release as I (Bob) broke py3 support.
7+
8+
* #84: bpython doesn't work with Python 3
9+
Thanks very much to Henry Prêcheur for both the bug report and the
10+
patch.
11+
12+
v0.9.6.1
13+
--------
14+
A quick bugfix release (this should not become a habit).
15+
16+
* #82: Crash on saving file.
17+
418
v0.9.6
519
------
620
A bugfix/feature release (and a start at gtk). Happy Christmas everyone!
@@ -13,7 +27,7 @@ A bugfix/feature release (and a start at gtk). Happy Christmas everyone!
1327
* #78: Theme without a certain value raises exception
1428

1529
- add the possibility for a banner to be shown on bpython startup (when
16-
embedded or in code) written by Caio Ramao.
30+
embedded or in code) written by Caio Romao.
1731
- add a hack to add a write() method to our fake stdin object
1832
- Don't use curses interface when stdout is not attached to a terminal.
1933
- PEP-8 conformance.

CHECKLIST

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Check that all of the following work before a release:
2+
3+
* Runs under Python 2.5, 2.6 and 3.1 (after 2to3).
4+
5+
* Save
6+
7+
* Rewind
8+
9+
* Pastebin
10+
11+
* Pager
12+
13+
* Inspect source
14+
15+
* History
16+
17+
* Tab completion
18+
19+
* Argument inspection
20+
21+
* All keybinds
22+
23+
* All packaged themes
24+
25+
* Command line arguments correctly passed to scripts
26+
27+
* Delegate to standard Python appropriately
28+
29+
* GTK port (and, when implemented, all of the above for GTK port)
30+
31+
* Update CHANGELOG
32+
33+
* Update __version__

ROADMAP

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ bpython.gtk_
1919
- Add shortcut keys to bpython.gtk_
2020
- Show a status bar thingy in bpython.gtk_
2121
- Colourise docstring (#80)
22+
23+
common
24+
- test suite

bpython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# THE SOFTWARE.
2222

2323

24-
__version__ = '0.9.6'
24+
__version__ = '0.9.6.2'
2525

2626

2727
def embed(locals_=None, args=['-i', '-q'], banner=None):

bpython/args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Module to handle command line argument parsing, for all front-ends.
33
"""
4-
from __future__ import with_statement
54

65
from __future__ import with_statement
76
import os
@@ -75,7 +74,7 @@ def parse(args, extras=None):
7574
if options.version:
7675
print 'bpython version', __version__,
7776
print 'on top of Python', sys.version.split()[0]
78-
print ('(C) 2008-2009 Bob Farrell, Andreas Stuehrk et al. '
77+
print ('(C) 2008-2010 Bob Farrell, Andreas Stuehrk et al. '
7978
'See AUTHORS for detail.')
8079
raise SystemExit
8180

@@ -102,5 +101,6 @@ def exec_code(interpreter, args):
102101
with open(args[0], 'r') as sourcefile:
103102
code_obj = compile(sourcefile.read(), args[0], 'exec')
104103
old_argv, sys.argv = sys.argv, args
104+
sys.path.insert(0, os.path.abspath(os.path.dirname(args[0])))
105105
interpreter.runcode(code_obj)
106106
sys.argv = old_argv

bpython/cli.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,12 @@ def p_key(self, key):
725725
self.complete()
726726
return ''
727727

728-
elif key == 'KEY_DC': # Del
728+
elif key in key_dispatch[config.delete_key] and not self.s:
729+
# Delete on empty line exits
730+
self.do_exit = True
731+
return None
732+
733+
elif key in ('KEY_DC', ) + key_dispatch[config.delete_key]:
729734
self.delete()
730735
self.complete()
731736
# Redraw (as there might have been highlighted parens)
@@ -746,12 +751,12 @@ def p_key(self, key):
746751
self.fwd()
747752
return ''
748753

749-
elif key == 'KEY_LEFT': # Cursor Left
754+
elif key in ("KEY_LEFT",' ^B', chr(2)): # Cursor Left or ^B
750755
self.mvc(1)
751756
# Redraw (as there might have been highlighted parens)
752757
self.print_line(self.s)
753758

754-
elif key == 'KEY_RIGHT': # Cursor Right
759+
elif key in ("KEY_RIGHT", '^F', chr(6)): # Cursor Right or ^F
755760
self.mvc(-1)
756761
# Redraw (as there might have been highlighted parens)
757762
self.print_line(self.s)
@@ -896,9 +901,13 @@ def prompt(self, more):
896901

897902
def push(self, s, insert_into_history=True):
898903
# curses.raw(True) prevents C-c from causing a SIGINT
899-
curses.raw(True)
904+
curses.raw(False)
900905
try:
901906
return Repl.push(self, s, insert_into_history)
907+
except SystemExit:
908+
# Avoid a traceback on e.g. quit()
909+
self.do_exit = True
910+
return False
902911
finally:
903912
curses.raw(True)
904913

@@ -1242,11 +1251,13 @@ class Statusbar(object):
12421251
12431252
"""
12441253

1245-
def __init__(self, scr, pwin, background, s=None, c=None):
1254+
def __init__(self, scr, pwin, background, config, s=None, c=None):
12461255
"""Initialise the statusbar and display the initial text (if any)"""
12471256
self.size()
12481257
self.win = newwin(background, self.h, self.w, self.y, self.x)
12491258

1259+
self.config = config
1260+
12501261
self.s = s or ''
12511262
self._s = self.s
12521263
self.c = c
@@ -1385,7 +1396,7 @@ def init_wins(scr, colors, config):
13851396
#
13861397
# This should show to be configured keys from ~/.bpython/config
13871398
#
1388-
statusbar = Statusbar(scr, main_win, background,
1399+
statusbar = Statusbar(scr, main_win, background, config,
13891400
" <%s> Rewind <%s> Save <%s> Pastebin <%s> Pager <%s> Show Source " %
13901401
(config.undo_key, config.save_key,
13911402
config.pastebin_key, config.last_output_key,
@@ -1549,13 +1560,14 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
15491560
sys.stdout = repl
15501561
sys.stderr = repl
15511562

1552-
repl.startup()
1553-
15541563
if args:
15551564
bpython.args.exec_code(interpreter, args)
15561565
if not interactive:
15571566
curses.raw(False)
15581567
return repl.getstdout()
1568+
else:
1569+
sys.path.insert(0, '')
1570+
repl.startup()
15591571

15601572
if banner is not None:
15611573
repl.write(banner)

bpython/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ def loadini(struct, configfile):
5353
'clear_screen': 'C-l',
5454
'clear_word': 'C-w',
5555
'cut_to_buffer': 'C-k',
56+
'delete': 'C-d',
5657
'down_one_line': 'C-n',
57-
'exit': 'C-d',
58+
'exit': '',
5859
'last_output': 'F9',
5960
'pastebin': 'F8',
6061
'save': 'C-s',
@@ -87,6 +88,7 @@ def loadini(struct, configfile):
8788
struct.clear_word_key = config.get('keyboard', 'clear_word')
8889
struct.clear_line_key = config.get('keyboard', 'clear_line')
8990
struct.clear_screen_key = config.get('keyboard', 'clear_screen')
91+
struct.delete_key = config.get('keyboard', 'delete')
9092
struct.exit_key = config.get('keyboard', 'exit')
9193
struct.last_output_key = config.get('keyboard', 'last_output')
9294

bpython/gtk_.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License
22
#
3-
# Copyright (c) 2009 the bpython authors.
3+
# Copyright (c) 2009-2010 the bpython authors.
44
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -251,7 +251,8 @@ class ReplWidget(gtk.TextView, repl.Repl):
251251
__gsignals__ = dict(button_press_event=None,
252252
focus_in_event=None,
253253
focus_out_event=None,
254-
realize=None)
254+
realize=None,
255+
exit_event=(gobject.SIGNAL_RUN_LAST, None, ()))
255256

256257
def __init__(self, interpreter, config):
257258
gtk.TextView.__init__(self)
@@ -445,6 +446,10 @@ def do_key_press_event(self, event):
445446
self.list_win_visible):
446447
self.list_win.back()
447448
return True
449+
elif state & gtk.gdk.CONTROL_MASK:
450+
if event.string == chr(4) and not self.current_line():
451+
self.emit('exit-event')
452+
return True
448453
return gtk.TextView.do_key_press_event(self, event)
449454

450455
def do_realize(self):
@@ -575,7 +580,11 @@ def push_line(self):
575580
self.text_buffer.insert(iter_, '\n')
576581
self.move_cursor(1)
577582
self.highlight_current_line()
578-
return self.push(line + '\n')
583+
try:
584+
return self.push(line + '\n')
585+
except SystemExit:
586+
self.emit('exit-event')
587+
return False
579588

580589
def reprint_line(self, lineno, tokens):
581590
"""
@@ -632,16 +641,24 @@ def main(args=None):
632641

633642
interpreter = repl.Interpreter(None, getpreferredencoding())
634643
repl_widget = ReplWidget(interpreter, config)
644+
repl_widget.connect('exit-event', gtk.main_quit)
635645

636-
sys.stderr = repl_widget
637-
sys.stdout = repl_widget
646+
gobject.idle_add(init_import_completion)
638647

639-
# repl.startup()
648+
if not exec_args:
649+
sys.path.insert(0, '')
650+
gobject.idle_add(repl_widget.startup)
651+
else:
652+
if options.interactive:
653+
gobject.idle_add(bpython.args.exec_code, interpreter, exec_args)
654+
else:
655+
bpython.args.exec_code(interpreter, exec_args)
656+
return 0
640657

641-
gobject.idle_add(init_import_completion)
658+
sys.stderr = repl_widget
659+
sys.stdout = repl_widget
642660

643661
if not options.socket_id:
644-
# print options.socket_id
645662
parent = gtk.Window()
646663
parent.connect('delete-event', lambda widget, event: gtk.main_quit())
647664

@@ -666,7 +683,15 @@ def main(args=None):
666683
parent.show_all()
667684
parent.connect('delete-event', lambda widget, event: gtk.main_quit())
668685

669-
gtk.main()
686+
try:
687+
gtk.main()
688+
except KeyboardInterrupt:
689+
pass
690+
finally:
691+
if config.hist_length:
692+
histfilename = os.path.expanduser(config.hist_file)
693+
repl_widget.rl_history.save(histfilename, getpreferredencoding())
694+
return 0
670695

671696

672697
if __name__ == '__main__':

bpython/importcompletion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License
22
#
3-
# Copyright (c) 2009 Andreas Stuehrk
3+
# Copyright (c) 2009-2010 Andreas Stuehrk
44
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal

bpython/inspection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License
22
#
3-
# Copyright (c) 2009 the bpython authors.
3+
# Copyright (c) 2009-2010 the bpython authors.
44
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)