[pypy-svn] r38610 - in pypy/dist/pypy: . lib module/__builtin__ module/__builtin__/test
arigo at codespeak.net
arigo at codespeak.net
Mon Feb 12 18:28:47 CET 2007
Author: arigo
Date: Mon Feb 12 18:28:45 2007
New Revision: 38610
Modified:
pypy/dist/pypy/conftest.py
pypy/dist/pypy/lib/stackless_new.py
pypy/dist/pypy/module/__builtin__/importing.py
pypy/dist/pypy/module/__builtin__/test/test_import.py
Log:
Run all tests in the app_test directory even with the -A option, as
they are meant to be testing the lib/ directory directly.
Fix a crash in the import logic if __name__ is set to a non-string
object.
Fix a TypeError in stackless_new.py (previously hidden by invalid
shortcuts in the pypy interpreter).
Modified: pypy/dist/pypy/conftest.py
==============================================================================
--- pypy/dist/pypy/conftest.py (original)
+++ pypy/dist/pypy/conftest.py Mon Feb 12 18:28:45 2007
@@ -145,16 +145,23 @@
option.conf_iocapture = "sys" # pypy cannot do FD-based
super(Module, self).__init__(*args, **kwargs)
- def funcnamefilter(self, name):
+ def accept_regular_test(self):
+ if option.runappdirect:
+ # only collect regular tests if we are in an 'app_test' directory
+ return self.fspath.dirpath().basename == 'app_test'
+ else:
+ return True
+
+ def funcnamefilter(self, name):
if name.startswith('test_'):
- return not option.runappdirect
+ return self.accept_regular_test()
if name.startswith('app_test_'):
return True
return False
def classnamefilter(self, name):
if name.startswith('Test'):
- return not option.runappdirect
+ return self.accept_regular_test()
if name.startswith('AppTest'):
return True
return False
Modified: pypy/dist/pypy/lib/stackless_new.py
==============================================================================
--- pypy/dist/pypy/lib/stackless_new.py (original)
+++ pypy/dist/pypy/lib/stackless_new.py Mon Feb 12 18:28:45 2007
@@ -380,7 +380,7 @@
_main_coroutine = _main_tasklet
_main_tasklet = TaskletProxy(_main_tasklet)
assert _main_tasklet.is_alive and not _main_tasklet.is_zombie
- tasklet._init(_main_tasklet, label='main')
+ tasklet._init.im_func(_main_tasklet, label='main')
_squeue = deque()
_scheduler_append(_main_tasklet)
Modified: pypy/dist/pypy/module/__builtin__/importing.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/importing.py (original)
+++ pypy/dist/pypy/module/__builtin__/importing.py Mon Feb 12 18:28:45 2007
@@ -155,23 +155,29 @@
space.wrap("__import__() argument 1 must be string" + helper))
w = space.wrap
+ ctxt_name = None
if w_globals is not None and not space.is_w(w_globals, space.w_None):
ctxt_w_name = try_getitem(space, w_globals, w('__name__'))
ctxt_w_path = try_getitem(space, w_globals, w('__path__'))
+ if ctxt_w_name is not None:
+ try:
+ ctxt_name = space.str_w(ctxt_w_name)
+ except OperationError, e:
+ if not e.match(space, space.w_TypeError):
+ raise
else:
- ctxt_w_name = None
ctxt_w_path = None
rel_modulename = None
- if ctxt_w_name is not None:
+ if ctxt_name is not None:
- ctxt_name_prefix_parts = space.str_w(ctxt_w_name).split('.')
+ ctxt_name_prefix_parts = ctxt_name.split('.')
if ctxt_w_path is None: # context is a plain module
ctxt_name_prefix_parts = ctxt_name_prefix_parts[:-1]
if ctxt_name_prefix_parts:
rel_modulename = '.'.join(ctxt_name_prefix_parts+[modulename])
else: # context is a package module
- rel_modulename = space.str_w(ctxt_w_name)+'.'+modulename
+ rel_modulename = ctxt_name+'.'+modulename
if rel_modulename is not None:
w_mod = check_sys_modules(space, w(rel_modulename))
if (w_mod is None or
Modified: pypy/dist/pypy/module/__builtin__/test/test_import.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/test/test_import.py (original)
+++ pypy/dist/pypy/module/__builtin__/test/test_import.py Mon Feb 12 18:28:45 2007
@@ -247,6 +247,12 @@
finally:
os.chmod(p, 0775)
+ def test_invalid__name__(self):
+ glob = {}
+ exec "__name__ = None; import sys" in glob
+ import sys
+ assert glob['sys'] is sys
+
def _getlong(data):
x = marshal.dumps(data)
return x[-4:]
More information about the Pypy-commit
mailing list