Skip to content

Commit b4424a3

Browse files
committed
Remove bpython.inspection.is_new_style which always returns True
1 parent 02b4d6b commit b4424a3

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

bpython/inspection.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,19 @@ def __enter__(self):
7272
# original methods. :-(
7373
# The upshot being that introspecting on an object to display its
7474
# attributes will avoid unwanted side-effects.
75-
if is_new_style(self.obj):
76-
__getattr__ = getattr(type_, "__getattr__", None)
77-
if __getattr__ is not None:
78-
try:
79-
setattr(type_, "__getattr__", (lambda *_, **__: None))
80-
except TypeError:
81-
__getattr__ = None
82-
__getattribute__ = getattr(type_, "__getattribute__", None)
83-
if __getattribute__ is not None:
84-
try:
85-
setattr(type_, "__getattribute__", object.__getattribute__)
86-
except TypeError:
87-
# XXX: This happens for e.g. built-in types
88-
__getattribute__ = None
75+
__getattr__ = getattr(type_, "__getattr__", None)
76+
if __getattr__ is not None:
77+
try:
78+
setattr(type_, "__getattr__", (lambda *_, **__: None))
79+
except TypeError:
80+
__getattr__ = None
81+
__getattribute__ = getattr(type_, "__getattribute__", None)
82+
if __getattribute__ is not None:
83+
try:
84+
setattr(type_, "__getattribute__", object.__getattribute__)
85+
except TypeError:
86+
# XXX: This happens for e.g. built-in types
87+
__getattribute__ = None
8988
self.attribs = (__getattribute__, __getattr__)
9089
# /Dark magic
9190

@@ -101,10 +100,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
101100
# /Dark magic
102101

103102

104-
def is_new_style(obj):
105-
return True
106-
107-
108103
class _Repr(object):
109104
"""
110105
Helper for `fixlongargs()`: Returns the given value in `__repr__()`.

bpython/test/test_inspection.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ def test_is_callable(self):
5757
self.assertFalse(inspection.is_callable(None))
5858
self.assertTrue(inspection.is_callable(CallableMethod().method))
5959

60-
def test_is_new_style_py3(self):
61-
self.assertTrue(inspection.is_new_style(spam))
62-
self.assertTrue(inspection.is_new_style(Noncallable))
63-
self.assertTrue(inspection.is_new_style(OldNoncallable))
64-
self.assertTrue(inspection.is_new_style(Noncallable()))
65-
self.assertTrue(inspection.is_new_style(OldNoncallable()))
66-
self.assertTrue(inspection.is_new_style(None))
67-
6860
def test_parsekeywordpairs(self):
6961
# See issue #109
7062
def fails(spam=["-a", "-b"]):

0 commit comments

Comments
 (0)