remove so-far superflous _getcode and pickle from builtins, some streamlining
--HG-- branch : trunk
This commit is contained in:
parent
99af33b26d
commit
45b98d4915
|
@ -152,12 +152,10 @@ initpkg(__name__,
|
|||
'builtin._isbytes' : ('./builtin/builtin31.py', '_isbytes'),
|
||||
'builtin._istext' : ('./builtin/builtin31.py', '_istext'),
|
||||
'builtin._getimself' : ('./builtin/builtin31.py', '_getimself'),
|
||||
'builtin._getcode' : ('./builtin/builtin31.py', '_getcode'),
|
||||
'builtin._getfuncdict' : ('./builtin/builtin31.py', '_getfuncdict'),
|
||||
'builtin.builtins' : ('./builtin/builtin31.py', 'builtins'),
|
||||
'builtin.execfile' : ('./builtin/builtin31.py', 'execfile'),
|
||||
'builtin.callable' : ('./builtin/builtin31.py', 'callable'),
|
||||
'builtin.pickle' : ('./builtin/builtin31.py', 'pickle'),
|
||||
|
||||
# gateways into remote contexts
|
||||
'execnet.__doc__' : ('./execnet/__init__.py', '__doc__'),
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
import sys
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
exec ("print_ = print ; exec_=exec")
|
||||
import builtins
|
||||
import pickle
|
||||
|
||||
# some backward compatibility helpers
|
||||
_basestring = str
|
||||
|
@ -22,9 +22,6 @@ if sys.version_info >= (3, 0):
|
|||
def _getimself(function):
|
||||
return getattr(function, '__self__', None)
|
||||
|
||||
def _getcode(function):
|
||||
return function.__code__
|
||||
|
||||
def _getfuncdict(function):
|
||||
return getattr(function, "__dict__", None)
|
||||
|
||||
|
@ -48,10 +45,7 @@ if sys.version_info >= (3, 0):
|
|||
return hasattr(obj, "__call__")
|
||||
|
||||
else:
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except ImportError:
|
||||
import pickle
|
||||
import __builtin__ as builtins
|
||||
_totext = unicode
|
||||
_basestring = basestring
|
||||
execfile = execfile
|
||||
|
@ -64,13 +58,9 @@ else:
|
|||
def _getimself(function):
|
||||
return getattr(function, 'im_self', None)
|
||||
|
||||
def _getcode(function):
|
||||
return function.func_code
|
||||
|
||||
def _getfuncdict(function):
|
||||
return getattr(function, "__dict__", None)
|
||||
|
||||
import __builtin__ as builtins
|
||||
def print_(*args, **kwargs):
|
||||
""" minimal backport of py3k print statement. """
|
||||
sep = ' '
|
||||
|
|
|
@ -45,8 +45,8 @@ def test_frozenset():
|
|||
assert len(s) == 1
|
||||
|
||||
def test_sorted():
|
||||
if sys.version_info >= (2,5):
|
||||
py.test.skip("python 2.5 needs no sorted tests")
|
||||
if sorted == py.builtin.sorted:
|
||||
return # don't test a real builtin
|
||||
for s in [py.builtin.sorted]:
|
||||
def test():
|
||||
assert s([3, 2, 1]) == [1, 2, 3]
|
||||
|
@ -98,7 +98,7 @@ def test_execfile(tmpdir):
|
|||
ns = {"y" : 42}
|
||||
py.builtin.execfile(str(test_file), ns)
|
||||
assert ns["x"] == 42
|
||||
assert py.builtin._getcode(ns["f"]).co_filename == str(test_file)
|
||||
assert py.code.getrawcode(ns["f"]).co_filename == str(test_file)
|
||||
class A:
|
||||
y = 3
|
||||
x = 4
|
||||
|
|
|
@ -136,14 +136,15 @@ newline will be removed from the end of each line. """
|
|||
""" (deprecated) return object unpickled from self.read() """
|
||||
f = self.open('rb')
|
||||
try:
|
||||
return py.error.checked_call(py.builtin.pickle.load, f)
|
||||
return py.error.checked_call(py.std.pickle.load, f)
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
def move(self, target):
|
||||
""" move this path to target. """
|
||||
if target.relto(self):
|
||||
raise py.error.EINVAL(target, "cannot move path into a subdirectory of itself")
|
||||
raise py.error.EINVAL(target,
|
||||
"cannot move path into a subdirectory of itself")
|
||||
try:
|
||||
self.rename(target)
|
||||
except py.error.EXDEV: # invalid cross-device link
|
||||
|
|
|
@ -355,7 +355,7 @@ class LocalPath(FSBase):
|
|||
""" pickle object into path location"""
|
||||
f = self.open('wb')
|
||||
try:
|
||||
py.error.checked_call(py.builtin.pickle.dump, obj, f, bin)
|
||||
py.error.checked_call(py.std.pickle.dump, obj, f, bin)
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class TestLocalPath(common.CommonFSTests):
|
|||
d = {'answer' : 42}
|
||||
path.dump(d, bin=bin)
|
||||
f = path.open('rb+')
|
||||
dnew = py.builtin.pickle.load(f)
|
||||
dnew = py.std.pickle.load(f)
|
||||
assert d == dnew
|
||||
finally:
|
||||
f.close()
|
||||
|
|
|
@ -345,8 +345,7 @@ class Function(FunctionMixin, py.test.collect.Item):
|
|||
|
||||
def readkeywords(self):
|
||||
d = super(Function, self).readkeywords()
|
||||
d.update(getattr(self.obj, '__dict__',
|
||||
getattr(self.obj, 'func_dict', {})))
|
||||
d.update(py.builtin._getfuncdict(self.obj))
|
||||
return d
|
||||
|
||||
def runtest(self):
|
||||
|
|
Loading…
Reference in New Issue