1.1 --- a/generator.py Sun Oct 30 22:17:00 2016 +0100
1.2 +++ b/generator.py Sun Oct 30 22:33:22 2016 +0100
1.3 @@ -52,9 +52,11 @@
1.4
1.5 function_type = "__builtins__.core.function"
1.6
1.7 + # NOTE: These must be synchronised with the library.
1.8 +
1.9 predefined_constant_members = (
1.10 - ("__builtins__.bool", "False"),
1.11 - ("__builtins__.bool", "True"),
1.12 + ("__builtins__.boolean", "False"),
1.13 + ("__builtins__.boolean", "True"),
1.14 ("__builtins__.none", "None"),
1.15 ("__builtins__.notimplemented", "NotImplemented"),
1.16 )
2.1 --- a/lib/__builtins__/__init__.py Sun Oct 30 22:17:00 2016 +0100
2.2 +++ b/lib/__builtins__/__init__.py Sun Oct 30 22:33:22 2016 +0100
2.3 @@ -73,7 +73,7 @@
2.4
2.5 # Classes.
2.6
2.7 -from __builtins__.bool import bool, False, True
2.8 +from __builtins__.boolean import bool, False, True
2.9 from __builtins__.buffer import buffer
2.10 from __builtins__.complex import complex
2.11 from __builtins__.dict import dict
3.1 --- a/lib/__builtins__/bool.py Sun Oct 30 22:17:00 2016 +0100
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,35 +0,0 @@
3.4 -#!/usr/bin/env python
3.5 -
3.6 -"""
3.7 -Boolean objects.
3.8 -
3.9 -Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
3.10 -
3.11 -This program is free software; you can redistribute it and/or modify it under
3.12 -the terms of the GNU General Public License as published by the Free Software
3.13 -Foundation; either version 3 of the License, or (at your option) any later
3.14 -version.
3.15 -
3.16 -This program is distributed in the hope that it will be useful, but WITHOUT
3.17 -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3.18 -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3.19 -details.
3.20 -
3.21 -You should have received a copy of the GNU General Public License along with
3.22 -this program. If not, see <http://www.gnu.org/licenses/>.
3.23 -"""
3.24 -
3.25 -class boolean(object):
3.26 - def __bool__(self):
3.27 - "Identity operation."
3.28 - return self
3.29 - def __str__(self):
3.30 - return self is True and "True" or "False"
3.31 -
3.32 -False = boolean()
3.33 -True = boolean()
3.34 -
3.35 -def bool(obj):
3.36 - return obj.__bool__()
3.37 -
3.38 -# vim: tabstop=4 expandtab shiftwidth=4
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/lib/__builtins__/boolean.py Sun Oct 30 22:33:22 2016 +0100
4.3 @@ -0,0 +1,35 @@
4.4 +#!/usr/bin/env python
4.5 +
4.6 +"""
4.7 +Boolean objects.
4.8 +
4.9 +Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
4.10 +
4.11 +This program is free software; you can redistribute it and/or modify it under
4.12 +the terms of the GNU General Public License as published by the Free Software
4.13 +Foundation; either version 3 of the License, or (at your option) any later
4.14 +version.
4.15 +
4.16 +This program is distributed in the hope that it will be useful, but WITHOUT
4.17 +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4.18 +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4.19 +details.
4.20 +
4.21 +You should have received a copy of the GNU General Public License along with
4.22 +this program. If not, see <http://www.gnu.org/licenses/>.
4.23 +"""
4.24 +
4.25 +class boolean(object):
4.26 + def __bool__(self):
4.27 + "Identity operation."
4.28 + return self
4.29 + def __str__(self):
4.30 + return self is True and "True" or "False"
4.31 +
4.32 +False = boolean()
4.33 +True = boolean()
4.34 +
4.35 +def bool(obj):
4.36 + return obj.__bool__()
4.37 +
4.38 +# vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/modules.py Sun Oct 30 22:17:00 2016 +0100
5.2 +++ b/modules.py Sun Oct 30 22:33:22 2016 +0100
5.3 @@ -302,7 +302,7 @@
5.4 module_name = "__builtins__.%s" % name
5.5 if self.name != module_name:
5.6 self.queue_module(module_name, True)
5.7 - return Reference("<class>", "__builtins__.%s.%s" % (name, name == "bool" and "boolean" or name))
5.8 + return Reference("<class>", "__builtins__.%s.%s" % (name, name))
5.9
5.10 def get_object(self, path, defer=True):
5.11
6.1 --- a/templates/progops.c Sun Oct 30 22:17:00 2016 +0100
6.2 +++ b/templates/progops.c Sun Oct 30 22:33:22 2016 +0100
6.3 @@ -125,5 +125,5 @@
6.4
6.5 int __BOOL(__attr attr)
6.6 {
6.7 - return attr.value == __builtins___bool_True.value;
6.8 + return attr.value == __builtins___boolean_True.value;
6.9 }
7.1 --- a/translator.py Sun Oct 30 22:17:00 2016 +0100
7.2 +++ b/translator.py Sun Oct 30 22:33:22 2016 +0100
7.3 @@ -178,7 +178,7 @@
7.4
7.5 def __str__(self):
7.6 if self.value in ("False", "True"):
7.7 - return encode_path("__builtins__.bool.%s" % self.value)
7.8 + return encode_path("__builtins__.boolean.%s" % self.value)
7.9 elif self.value == "None":
7.10 return encode_path("__builtins__.none.%s" % self.value)
7.11 elif self.value == "NotImplemented":
7.12 @@ -287,7 +287,7 @@
7.13
7.14 # NOTE: This makes assumptions about the __builtins__ structure.
7.15
7.16 - return self.importer.get_object("__builtins__.%s.%s" % (name, name == "bool" and "boolean" or name))
7.17 + return self.importer.get_object("__builtins__.%s.%s" % (name, name))
7.18
7.19 def is_method(self, path):
7.20