~ubuntu-branches/ubuntu/karmic/pypy/karmic

« back to all changes in this revision

Viewing changes to pypy/objspace/std/booltype.py

  • Committer: Bazaar Package Importer
  • Author(s): Alexandre Fayolle
  • Date: 2007-04-13 09:33:09 UTC
  • Revision ID: james.westby@ubuntu.com-20070413093309-yoojh4jcoocu2krz
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from pypy.objspace.std.stdtypedef import *
 
2
from pypy.objspace.std.inttype import int_typedef
 
3
 
 
4
# XXX should forbit subclassing of 'bool'
 
5
 
 
6
 
 
7
def descr__new__(space, w_booltype, w_obj=None):
 
8
    space.w_bool.check_user_subclass(w_booltype)
 
9
    if space.is_true(w_obj):
 
10
        return space.w_True
 
11
    else:
 
12
        return space.w_False
 
13
 
 
14
# ____________________________________________________________
 
15
 
 
16
bool_typedef = StdTypeDef("bool", int_typedef,
 
17
    __doc__ = '''bool(x) -> bool
 
18
 
 
19
Returns True when the argument x is true, False otherwise.
 
20
The builtins True and False are the only two instances of the class bool.
 
21
The class bool is a subclass of the class int, and cannot be subclassed.''',
 
22
    __new__ = newmethod(descr__new__),
 
23
    )
 
24
bool_typedef.acceptable_as_base_class = False