[Python-checkins] CVS: python/dist/src/Misc NEWS,1.327,1.328

Tim Peters tim_one@users.sourceforge.net
Wed, 05 Dec 2001 22:23:28 -0800


Update of /cvsroot/python/python/dist/src/Misc
In directory usw-pr-cvs1:/tmp/cvs-serv9827/python/Misc

Modified Files:
	NEWS 
Log Message:
SF bug #488514: -Qnew needs work
Big Hammer to implement -Qnew as PEP 238 says it should work (a global
option affecting all instances of "/").

pydebug.h, main.c, pythonrun.c:  define a private _Py_QnewFlag flag, true
iff -Qnew is passed on the command line.  This should go away (as the
comments say) when true division becomes The Rule.  This is
deliberately not exposed to runtime inspection or modification:  it's
a one-way one-shot switch to pretend you're using Python 3.

ceval.c:  when _Py_QnewFlag is set, treat BINARY_DIVIDE as
BINARY_TRUE_DIVIDE.

test_{descr, generators, zipfile}.py:  fiddle so these pass under
-Qnew too.  This was just a matter of s!/!//! in test_generators and
test_zipfile.  test_descr was trickier, as testbinop() is passed
assumptions that "/" is the same as calling a "__div__" method; put
a temporary hack there to call "__truediv__" instead when the method
name is "__div__" and 1/2 evaluates to 0.5.

Three standard tests still fail under -Qnew (on Windows; somebody
please try the Linux tests with -Qnew too!  Linux runs a whole bunch
of tests Windows doesn't):
    test_augassign
    test_class
    test_coercion
I can't stay awake longer to stare at this (be my guest).  Offhand
cures weren't obvious, nor was it even obvious that cures are possible
without major hackery.

Question:  when -Qnew is in effect, should calls to __div__ magically
change into calls to __truediv__?  See "major hackery" at tail end of
last paragraph <wink>.


Index: NEWS
===================================================================
RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v
retrieving revision 1.327
retrieving revision 1.328
diff -C2 -d -r1.327 -r1.328
*** NEWS	2001/12/05 22:45:48	1.327
--- NEWS	2001/12/06 06:23:25	1.328
***************
*** 40,43 ****
--- 40,50 ----
  Core and builtins
  
+ - -Qnew now works as documented in PEP 238:  when -Qnew is passed on
+   the command line, all occurrences of "/" use true division instead
+   of classic division.  See the PEP for details.  Note that "all"
+   means all instances in library and 3rd-party modules, as well as in
+   your own code.  As the PEP says, -Qnew is intended for use only in
+   educational environments with control over the libraries in use.
+ 
  Extension modules
  
***************
*** 713,721 ****
    all uses of classic division for int and long arguments; -Qwarnall
    also warns about classic division for float and complex arguments
!   (for use with fixdiv.py).  Using -Qnew is questionable; it turns on
!   new division by default, but only in the __main__ module.  You can
!   usefully combine -Qwarn or -Qwarnall and -Qnew: this gives the
!   __main__ module new division, and warns about classic division
!   everywhere else.
  
  - Many built-in types can now be subclassed.  This applies to int,
--- 720,732 ----
    all uses of classic division for int and long arguments; -Qwarnall
    also warns about classic division for float and complex arguments
!   (for use with fixdiv.py).
!   [Note:  the remainder of this paragraph (preserved below) became
!    obsolete in 2.2c1 -- -Qnew has global effect in 2.2]
!   <obsolete>
!   Using -Qnew is questionable; it turns on new division by default, but
!   only in the __main__ module.  You can usefully combine -Qwarn or
!   -Qwarnall and -Qnew: this gives the __main__ module new division, and
!   warns about classic division everywhere else.
!   </obsolete>
  
  - Many built-in types can now be subclassed.  This applies to int,