Issue1501770

classification
Title: Implementation of the bool type for the 2.3 branch
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: fwierzbicki, jeffnorton
Priority: normal Keywords: patch

Created on 2006-06-06.17:23:58 by jeffnorton, last changed 2006-06-12.01:41:59 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
jy23boolpatch.diff jeffnorton, 2006-06-06.17:23:58 Patch file for the 2.3 branch containing implementation for the bool type
Messages
msg2490 (view) Author: Jeff Norton (jeffnorton) Date: 2006-06-06.17:23:58
The primary implementation is in the PyBoolean.java 
class which is a subclass of PyInteger.  PyInteger was 
refactored slightly to allow PyBoolean to inherit as 
much as possible of the implementation.  Most notably 
references to "value" were changed to "asInt(0)" so 
PyBoolean subclass values would be processed correctly.

Added the Py.True and Py.False statics and changed 
usages of Py.One and Py.Zero to them where appropriate.

Added bool to __builtin__.java and BooleanType to 
types.java

Finally taught the marshaller about the bool type.

Created the bool.expose and bool.derived templates but 
these are not included in this patch as they are not 
stored in the 2.3 branch but are in the jt sandbox.

Testing:
* Ran regrtest.py and got identical results after my 
changes in the number of tests passing (82), failing 
(90), and skipped (97).
* test_bool:  One of the failing tests -- still fails 
but does much better.  The only failure is that bool 
currently allows subclassing -- which it shouldn't.  
There are 5 ERRORs due to missing implementation in 
pickle, etc.  Output:

> jy23 regrtest.py -v test_bool
test_bool
test_boolean (test_bool.BoolTest) ... ok
test_callable (test_bool.BoolTest) ... ok
test_convert (test_bool.BoolTest) ... ok
test_convert_to_bool (test_bool.BoolTest) ... ERROR
test_cpickle (test_bool.BoolTest) ... ERROR
test_fileclosed (test_bool.BoolTest) ... ok
test_hasattr (test_bool.BoolTest) ... ok
test_haskey (test_bool.BoolTest) ... ok
test_int (test_bool.BoolTest) ... ok
test_isinstance (test_bool.BoolTest) ... ok
test_issubclass (test_bool.BoolTest) ... ok
test_marshal (test_bool.BoolTest) ... ok
test_math (test_bool.BoolTest) ... ok
test_mixedpickle (test_bool.BoolTest) ... ERROR
test_operator (test_bool.BoolTest) ... ERROR
test_pickle (test_bool.BoolTest) ... ERROR
test_picklevalues (test_bool.BoolTest) ... ERROR
test_print (test_bool.BoolTest) ... ok
test_repr (test_bool.BoolTest) ... ok
test_str (test_bool.BoolTest) ... ok
test_string (test_bool.BoolTest) ... ok
test_subclass (test_bool.BoolTest) ... FAIL

=======================================================
===============
ERROR: test_convert_to_bool (test_bool.BoolTest)
-------------------------------------------------------
---------------
Traceback (most recent call last):
  File "C:\svn\jy23\dist\Lib\unittest.py", line 229, 
in __call__
  File "C:\svn\jy23\dist\Lib\test\test_bool.py", line 
331, in test_convert_to_bool
  File "C:\svn\jy23\dist\Lib\test\test_bool.py", line 
327, in <lambda>
  File "C:\svn\jy23\dist\Lib\unittest.py", line 289, 
in failUnlessRaises
java.lang.StackOverflowError: 
java.lang.StackOverflowError

=======================================================
===============
ERROR: test_cpickle (test_bool.BoolTest)
-------------------------------------------------------
---------------
Traceback (most recent call last):
  File "C:\svn\jy23\dist\Lib\unittest.py", line 229, 
in __call__
  File "C:\svn\jy23\dist\Lib\test\test_bool.py", line 
293, in test_cpickle
AttributeError: module 'copy_reg' has no 
attribute 'safe_constructors'

=======================================================
===============
ERROR: test_mixedpickle (test_bool.BoolTest)
-------------------------------------------------------
---------------
Traceback (most recent call last):
  File "C:\svn\jy23\dist\Lib\unittest.py", line 229, 
in __call__
  File "C:\svn\jy23\dist\Lib\test\test_bool.py", line 
299, in test_mixedpickle
  File "C:\svn\jy23\dist\Lib\pickle.py", line 29, in ?
ImportError: cannot import name safe_constructors

=======================================================
===============
ERROR: test_operator (test_bool.BoolTest)
-------------------------------------------------------
---------------
Traceback (most recent call last):
  File "C:\svn\jy23\dist\Lib\unittest.py", line 229, 
in __call__
  File "C:\svn\jy23\dist\Lib\test\test_bool.py", line 
274, in test_operator
AttributeError: class 'org.python.modules.operator' 
has no attribute 'is_'

=======================================================
===============
ERROR: test_pickle (test_bool.BoolTest)
-------------------------------------------------------
---------------
Traceback (most recent call last):
  File "C:\svn\jy23\dist\Lib\unittest.py", line 229, 
in __call__
  File "C:\svn\jy23\dist\Lib\test\test_bool.py", line 
286, in test_pickle
AttributeError: module 'pickle' has no 
attribute 'loads'

=======================================================
===============
ERROR: test_picklevalues (test_bool.BoolTest)
-------------------------------------------------------
---------------
Traceback (most recent call last):
  File "C:\svn\jy23\dist\Lib\unittest.py", line 229, 
in __call__
  File "C:\svn\jy23\dist\Lib\test\test_bool.py", line 
314, in test_picklevalues
AttributeError: module 'pickle' has no 
attribute 'dumps'

=======================================================
===============
FAIL: test_subclass (test_bool.BoolTest)
-------------------------------------------------------
---------------
Traceback (most recent call last):
  File "C:\svn\jy23\dist\Lib\unittest.py", line 229, 
in __call__
  File "C:\svn\jy23\dist\Lib\test\test_bool.py", line 
23, in test_subclass
  File "C:\svn\jy23\dist\Lib\unittest.py", line 270, 
in fail
AssertionError: bool should not be subclassable

-------------------------------------------------------
---------------
Ran 22 tests in 0.344s

FAILED (failures=1, errors=6)
test test_bool failed -- errors occurred in 
test_bool.BoolTest
1 test failed:
    [C:\svn\jy23\dist\Lib\test]test_bool
msg2491 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2006-06-12.01:41:59
Logged In: YES 
user_id=193969

Accepted with modifications -- see patch 1503004
History
Date User Action Args
2006-06-06 17:23:58jeffnortoncreate