Skip to content

Commit fa08a03

Browse files
committed
Merge branch 'master' of github.com:bpython/bpython
2 parents 1684cbf + 9a6f047 commit fa08a03

12 files changed

Lines changed: 71 additions & 71 deletions

File tree

bpython/args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def exec_code(interpreter, args):
104104
sys.argv
105105
"""
106106
with open(args[0], 'r') as sourcefile:
107-
code_obj = compile(sourcefile.read(), args[0], 'exec')
107+
source = sourcefile.read()
108108
old_argv, sys.argv = sys.argv, args
109109
sys.path.insert(0, os.path.abspath(os.path.dirname(args[0])))
110-
interpreter.runcode(code_obj)
110+
interpreter.runsource(source, args[0], 'exec')
111111
sys.argv = old_argv

bpython/cli.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,14 +968,16 @@ def p_key(self, key):
968968
return ''
969969

970970
elif key in key_dispatch[config.show_source_key]:
971-
source = self.get_source_of_current_name()
972-
if source is not None:
971+
try:
972+
source = self.get_source_of_current_name()
973973
if config.highlight_show_source:
974974
source = format(PythonLexer().get_tokens(source),
975975
TerminalFormatter())
976976
page(source)
977-
else:
978-
self.statusbar.message(_('Cannot show source.'))
977+
except (ValueError, AttributeError, IOError, TypeError), e:
978+
self.statusbar.message(_(e))
979+
except (NameError), e:
980+
self.statusbar.message(_('Cannot get source: %s' % e))
979981
return ''
980982

981983
elif key in ('\n', '\r', 'PADENTER'):

bpython/curtsiesfrontend/repl.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,14 +1300,17 @@ def pager(self, text):
13001300
self.focus_on_subprocess(command + [tmp.name])
13011301

13021302
def show_source(self):
1303-
source = self.get_source_of_current_name()
1304-
if source is None:
1305-
self.status_bar.message(_('Cannot show source.'))
1306-
else:
1303+
try:
1304+
source = self.get_source_of_current_name()
13071305
if self.config.highlight_show_source:
1308-
source = format(PythonLexer().get_tokens(source), TerminalFormatter())
1306+
source = format(PythonLexer().get_tokens(source),
1307+
TerminalFormatter())
13091308
self.pager(source)
1310-
1309+
except (ValueError, AttributeError, IOError, TypeError), e:
1310+
self.status_bar.message(_(e))
1311+
except (NameError), e:
1312+
self.status_bar.message(_('Cannot get source: %s' % e))
1313+
13111314
def help_text(self):
13121315
return (self.version_help_text() + '\n' + self.key_help_text()).encode('utf8')
13131316

bpython/repl.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -589,21 +589,23 @@ def get_args(self):
589589

590590
def get_source_of_current_name(self):
591591
"""Return the source code of the object which is bound to the
592-
current name in the current input line. Return `None` if the
592+
current name in the current input line. Throw exception if the
593593
source cannot be found."""
594-
try:
595-
obj = self.current_func
596-
if obj is None:
597-
line = self.current_line
598-
if inspection.is_eval_safe_name(line):
599-
obj = self.get_object(line)
600-
if obj is None:
601-
return None
602-
source = inspect.getsource(obj)
603-
except (AttributeError, IOError, NameError, TypeError):
604-
return None
605-
else:
606-
return source
594+
obj = self.current_func
595+
if obj is None:
596+
line = self.current_line
597+
if line == "":
598+
raise ValueError("Nothing to get source of")
599+
if inspection.is_eval_safe_name(line):
600+
obj = self.get_object(line)
601+
try:
602+
inspect.getsource(obj)
603+
except TypeError, e:
604+
msg = e.message
605+
if "built-in" in msg:
606+
raise TypeError("Cannot access source of <built-in function %s>" % self.current_line)
607+
else:
608+
raise TypeError("No source code found for %s" % self.current_line)
607609

608610
def set_docstring(self):
609611
self.docstring = None

bpython/test/test_args.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

bpython/test/test_curtsies_repl.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def setup_config(conf):
2323
config.loadini(config_struct, os.devnull)
2424
for key, value in conf.items():
2525
if not hasattr(config_struct, key):
26-
raise ValueError("%r is not a valid config attribute", (key,))
26+
raise ValueError("%r is not a valid config attribute" % (key,))
2727
setattr(config_struct, key, value)
2828
return config_struct
2929

@@ -99,7 +99,6 @@ def test_repl(self):
9999
repl.push('1 / 2')
100100
self.assertEqual(out.getvalue(), '0.5\n')
101101

102-
@skip('Failing - this is issue #369')
103102
def test_interactive(self):
104103
interp = code.InteractiveInterpreter(locals={})
105104
with captured_output() as (out, err):

doc/sphinx/source/authors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ Other contributors are (in alphabetical order):
2828
* Marien Zwart <marien dot zwart at gmail dot com>
2929

3030
A big thanks goes out to all the people who help us out by either submitting
31-
patches, helping us determine problems, our package maintainers and of course
31+
patches, helping us determine problems, our package maintainers, and of course
3232
everybody who creates issues for us to fix.

doc/sphinx/source/bpdb.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ This will drop you into bpdb instead of pdb, which works exactly like pdb except
1414
that you can additionally start bpython at the current stack frame by issuing
1515
the command `Bpython` or `B`.
1616

17-
You can exit bpython with `^D` to return to bpdb.
17+
You can exit bpython with `^d` to return to bpdb.

doc/sphinx/source/community.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ worry when you get no response (this does not usually happen) but we are all
1515
from Europe and when you get to the channel during our nighttime you might have
1616
to wait a while for a response.
1717

18-
Mailinglist
18+
Mailing List
1919
-----------
20-
We have a mailinglist at `google groups <http://groups.google.com/group/bpython>`_.
20+
We have a mailing list at `google groups <http://groups.google.com/group/bpython>`_.
2121
You can post questions there and releases are announced on the mailing
2222
list.
2323

2424
Website
2525
-------
2626
Our main website is http://bpython-interpreter.org/, our documentation can be
27-
found at http://docs.bpython-interpreter.org/ and our pastebin can be found at
27+
found at http://docs.bpython-interpreter.org/, and our pastebin can be found at
2828
http://bpaste.net/.

doc/sphinx/source/configuration-options.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The time between lines before pastemode is activated in seconds (default: 0.02).
3535

3636
hist_length
3737
^^^^^^^^^^^
38-
Number of lines to store in history (set to 0 to disable) (default: 100)
38+
Number of lines to store in history (set to 0 to disable) (default: 100).
3939

4040
tab_length
4141
^^^^^^^^^^
@@ -45,24 +45,24 @@ pastebin_url
4545
^^^^^^^^^^^^
4646
The pastebin url to post to (without a trailing slash). This pastebin has to be
4747
a pastebin which uses provides a similar interface to ``bpaste.net``'s JSON
48-
interface. (default: https://bpaste.net/json/new)
48+
interface (default: https://bpaste.net/json/new).
4949

5050
pastebin_show_url
5151
^^^^^^^^^^^^^^^^^
5252
The url under which the new paste can be reached. ``$paste_id`` will be replaced
53-
by the ID of the new paste. (default: https://bpaste.net/show/$paste_id/)
53+
by the ID of the new paste (default: https://bpaste.net/show/$paste_id/).
5454

5555
pastebin_removal_url
5656
^^^^^^^^^^^^^^^^^^^^
5757
The url under which a paste can be removed. ``$removal_id`` will be replaced
58-
by the removal ID of the paste. (default: https://bpaste.net/remova/$removal_id/)
58+
by the removal ID of the paste (default: https://bpaste.net/remova/$removal_id/).
5959

6060
.. versionadded:: 0.14
6161

6262
pastebin_expiry
6363
^^^^^^^^^^^^^^^
6464
Time duration after which a paste should expire. Valid values are ``1day``,
65-
``1week`` and ``1month``. (default: ``1week``)
65+
``1week`` and ``1month`` (default: ``1week``).
6666

6767
.. versionadded:: 0.14
6868

0 commit comments

Comments
 (0)