Skip to content

Future proofs by checking for Python versions >= 3 #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions bipython/inspection_standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
# inlining from bpython._py3compat import PythonLexer, py3
import sys

py3 = (sys.version_info[0] == 3)
not_py2 = (sys.version_info[0] >= 3)

if py3:
if not_py2:
from pygments.lexers import Python3Lexer as PythonLexer
else:
from pygments.lexers import PythonLexer
Expand All @@ -54,7 +54,7 @@
except AttributeError:
has_instance_type = False

if not py3:
if not not_py2:
_name = re.compile(r'[a-zA-Z_]\w*$')


Expand All @@ -80,7 +80,7 @@ def __enter__(self):
# original methods. :-(
# The upshot being that introspecting on an object to display its
# attributes will avoid unwanted side-effects.
if py3 or type_ != types.InstanceType:
if not_py2 or type_ != types.InstanceType:
__getattr__ = getattr(type_, '__getattr__', None)
if __getattr__ is not None:
try:
Expand Down Expand Up @@ -244,7 +244,7 @@ def getargspec(func, f):
# '__init__' throws xmlrpclib.Fault (see #202)
return None
try:
if py3:
if not_py2:
argspec = inspect.getfullargspec(f)
else:
argspec = inspect.getargspec(f)
Expand All @@ -264,7 +264,7 @@ def getargspec(func, f):


def is_eval_safe_name(string):
if py3:
if not_py2:
return all(part.isidentifier() and not keyword.iskeyword(part)
for part in string.split('.'))
else:
Expand Down