Skip to content

Commit

Permalink
Merge pull request numpy#15362 from mwtoews/def23
Browse files Browse the repository at this point in the history
MAINT: remove internal functions required to handle Python2/3 logic
  • Loading branch information
mattip authored Jan 23, 2020
2 parents 61c5c5d + 81e7706 commit 883de8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 38 deletions.
35 changes: 9 additions & 26 deletions numpy/core/setup_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,32 +311,15 @@ def pyod(filename):
We only implement enough to get the necessary information for long double
representation, this is not intended as a compatible replacement for od.
"""
def _pyod2():
out = []

with open(filename, 'rb') as fid:
yo = [int(oct(int(binascii.b2a_hex(o), 16))) for o in fid.read()]
for i in range(0, len(yo), 16):
line = ['%07d' % int(oct(i))]
line.extend(['%03d' % c for c in yo[i:i+16]])
out.append(" ".join(line))
return out

def _pyod3():
out = []

with open(filename, 'rb') as fid:
yo2 = [oct(o)[2:] for o in fid.read()]
for i in range(0, len(yo2), 16):
line = ['%07d' % int(oct(i)[2:])]
line.extend(['%03d' % int(c) for c in yo2[i:i+16]])
out.append(" ".join(line))
return out

if sys.version_info[0] < 3:
return _pyod2()
else:
return _pyod3()
out = []
with open(filename, 'rb') as fid:
yo2 = [oct(o)[2:] for o in fid.read()]
for i in range(0, len(yo2), 16):
line = ['%07d' % int(oct(i)[2:])]
line.extend(['%03d' % int(c) for c in yo2[i:i+16]])
out.append(" ".join(line))
return out


_BEFORE_SEQ = ['000', '000', '000', '000', '000', '000', '000', '000',
'001', '043', '105', '147', '211', '253', '315', '357']
Expand Down
14 changes: 2 additions & 12 deletions numpy/distutils/misc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,18 +923,8 @@ def _get_configuration_from_setup_py(self, setup_py,
else:
pn = dot_join(*([parent_name] + subpackage_name.split('.')[:-1]))
args = (pn,)
def fix_args_py2(args):
if setup_module.configuration.__code__.co_argcount > 1:
args = args + (self.top_path,)
return args
def fix_args_py3(args):
if setup_module.configuration.__code__.co_argcount > 1:
args = args + (self.top_path,)
return args
if sys.version_info[0] < 3:
args = fix_args_py2(args)
else:
args = fix_args_py3(args)
if setup_module.configuration.__code__.co_argcount > 1:
args = args + (self.top_path,)
config = setup_module.configuration(*args)
if config.name!=dot_join(parent_name, subpackage_name):
self.warn('Subpackage %r configuration returned as %r' % \
Expand Down

0 comments on commit 883de8f

Please sign in to comment.