aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Lamy <ronan.lamy@gmail.com>2014-04-12 21:31:36 +0100
committerRonan Lamy <ronan.lamy@gmail.com>2014-04-12 21:31:36 +0100
commit916acb5e03a8f9f20746015d703429493ce0e7cc (patch)
tree017695471ef62c5da47035720801e6c2bad068c3 /py/_builtin.py
parentA bit more tweaking of details of specialization of some strange jmp (diff)
downloadpypy-916acb5e03a8f9f20746015d703429493ce0e7cc.tar.gz
pypy-916acb5e03a8f9f20746015d703429493ce0e7cc.tar.bz2
pypy-916acb5e03a8f9f20746015d703429493ce0e7cc.zip
sync to pytest 2.5.2 and pylib 1.4.20
Diffstat (limited to 'py/_builtin.py')
-rw-r--r--py/_builtin.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/py/_builtin.py b/py/_builtin.py
index 67971f0afc..fa3b797c44 100644
--- a/py/_builtin.py
+++ b/py/_builtin.py
@@ -107,6 +107,12 @@ except NameError:
_sysex = (KeyboardInterrupt, SystemExit, MemoryError, GeneratorExit)
+try:
+ callable = callable
+except NameError:
+ def callable(obj):
+ return hasattr(obj, "__call__")
+
if sys.version_info >= (3, 0):
exec ("print_ = print ; exec_=exec")
import builtins
@@ -128,6 +134,10 @@ if sys.version_info >= (3, 0):
def _istext(x):
return isinstance(x, str)
+ text = str
+ bytes = bytes
+
+
def _getimself(function):
return getattr(function, '__self__', None)
@@ -153,13 +163,12 @@ if sys.version_info >= (3, 0):
co = compile(source, fn, "exec", dont_inherit=True)
exec_(co, globs, locs)
- def callable(obj):
- return hasattr(obj, "__call__")
-
else:
import __builtin__ as builtins
_totext = unicode
_basestring = basestring
+ text = unicode
+ bytes = str
execfile = execfile
callable = callable
def _isbytes(x):
@@ -231,7 +240,9 @@ def _tryimport(*names):
assert names
for name in names:
try:
- return __import__(name, None, None, '__doc__')
+ __import__(name)
except ImportError:
excinfo = sys.exc_info()
+ else:
+ return sys.modules[name]
_reraise(*excinfo)