[pypy-svn] r8490 - in pypy/dist/pypy/interpreter: . test
odie at codespeak.net
odie at codespeak.net
Sun Jan 23 15:07:59 CET 2005
Author: odie
Date: Sun Jan 23 15:07:58 2005
New Revision: 8490
Modified:
pypy/dist/pypy/interpreter/module.py
pypy/dist/pypy/interpreter/test/test_module.py
Log:
Modules can have docstring at construction time.
Modified: pypy/dist/pypy/interpreter/module.py
==============================================================================
--- pypy/dist/pypy/interpreter/module.py (original)
+++ pypy/dist/pypy/interpreter/module.py Sun Jan 23 15:07:58 2005
@@ -14,6 +14,8 @@
self.w_dict = w_dict
self.w_name = w_name
space.setitem(w_dict, space.wrap('__name__'), w_name)
+ if not space.is_true(space.contains(w_dict, space.wrap('__doc__'))):
+ space.setitem(w_dict, space.wrap('__doc__'), space.w_None)
def getdict(self):
return self.w_dict
@@ -26,7 +28,9 @@
module.__init__(space, space.wrap('?'))
return space.wrap(module)
- def descr_module__init__(self, w_name):
+ def descr_module__init__(self, w_name, w_doc=None):
space = self.space
self.w_name = w_name
space.setitem(self.w_dict, space.wrap('__name__'), w_name)
+ if w_doc is not None:
+ space.setitem(self.w_dict, space.wrap('__doc__'), w_doc)
Modified: pypy/dist/pypy/interpreter/test/test_module.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_module.py (original)
+++ pypy/dist/pypy/interpreter/test/test_module.py Sun Jan 23 15:07:58 2005
@@ -37,3 +37,10 @@
delattr(m, 'x')
raises(AttributeError, getattr, m, 'x')
raises(AttributeError, delattr, m, 'x')
+ def test_docstring(self):
+ import sys
+ foo = type(sys)('foo')
+ assert foo.__name__ == 'foo'
+ assert foo.__doc__ is None
+ bar = type(sys)('bar','docstring')
+ assert bar.__doc__ == 'docstring'
More information about the Pypy-commit
mailing list