Skip to content

Commit ec0230c

Browse files
committed
Merge with tip.
2 parents a1ff54f + bfde98e commit ec0230c

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ Other contributors are (in alphabetical order):
88
* Federico Ceratto <federico dot ceratto at gmail dot com>
99
* Pavel Panchekha <pavpanchekha at gmail dot com>
1010
* Simon de Vlieger <simon at ikanobori dot jp>
11-
11+
* Marien Zwart <marien dot zwart at gmail dot com>
1212

1313
Many thanks for all contributions!

bpython/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,7 @@ def main(args=None, locals_=None, banner=None):
16101610

16111611

16121612
if __name__ == '__main__':
1613+
from bpython.cli import main
16131614
main()
16141615

16151616
# vim: sw=4 ts=4 sts=4 ai et

bpython/gtk_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,4 +695,5 @@ def main(args=None):
695695

696696

697697
if __name__ == '__main__':
698+
from bpython.gtk_ import main
698699
main()

bpython/importcompletion.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ def find_modules(path):
7575
# Possibly a package
7676
if '.' in name:
7777
continue
78+
elif os.path.isdir(os.path.join(path, name)):
79+
# Unfortunately, CPython just crashes if there is a directory
80+
# which ends with a python extension, so work around.
81+
continue
7882
name = os.path.splitext(name)[0]
7983
try:
8084
fo, pathname, _ = imp.find_module(name, [path])
@@ -99,6 +103,8 @@ def find_all_modules(path=None):
99103
path = sys.path
100104

101105
for p in path:
106+
if not path:
107+
path = os.curdir
102108
for module in find_modules(p):
103109
modules.add(module)
104110
yield

bpython/inspection.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#
2323

2424
from __future__ import with_statement
25+
import collections
2526
import inspect
2627
import pydoc
2728
import re
@@ -31,6 +32,17 @@
3132
from pygments.lexers import PythonLexer
3233
from pygments.token import Token
3334

35+
try:
36+
collections.Callable
37+
has_collections_callable = True
38+
try:
39+
import types
40+
types.InstanceType
41+
has_instance_type = True
42+
except AttributeError:
43+
has_instance_type = False
44+
except AttributeError:
45+
has_collections_callable = False
3446

3547
py3 = sys.version_info[0] == 3
3648

@@ -223,3 +235,13 @@ def is_eval_safe_name(string):
223235
return all(part.isidentifier() for part in string.split('.'))
224236
else:
225237
return all(_name.match(part) for part in string.split('.'))
238+
239+
240+
def is_callable(obj):
241+
if has_instance_type and isinstance(obj, types.InstanceType):
242+
# Work around a Python bug, see issue 7624
243+
return callable(obj)
244+
elif has_collections_callable:
245+
return isinstance(obj, collections.Callable)
246+
else:
247+
return callable(obj)

bpython/repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def attr_lookup(self, obj, expr, attr):
363363
def _callable_postfix(self, value, word):
364364
"""rlcompleter's _callable_postfix done right."""
365365
with inspection.AttrCleaner(value):
366-
if hasattr(value, '__call__'):
366+
if inspection.is_callable(value):
367367
word += '('
368368
return word
369369

0 commit comments

Comments
 (0)