cpython/Objects
Guido van Rossum 393661d15f Add warning mode for classic division, almost exactly as specified in
PEP 238.  Changes:

- add a new flag variable Py_DivisionWarningFlag, declared in
  pydebug.h, defined in object.c, set in main.c, and used in
  {int,long,float,complex}object.c.  When this flag is set, the
  classic division operator issues a DeprecationWarning message.

- add a new API PyRun_SimpleStringFlags() to match
  PyRun_SimpleString().  The main() function calls this so that
  commands run with -c can also benefit from -Dnew.

- While I was at it, I changed the usage message in main() somewhat:
  alphabetized the options, split it in *four* parts to fit in under
  512 bytes (not that I still believe this is necessary -- doc strings
  elsewhere are much longer), and perhaps most visibly, don't display
  the full list of options on each command line error.  Instead, the
  full list is only displayed when -h is used, and otherwise a brief
  reminder of -h is displayed.  When -h is used, write to stdout so
  that you can do `python -h | more'.

Notes:

- I don't want to use the -W option to control whether the classic
  division warning is issued or not, because the machinery to decide
  whether to display the warning or not is very expensive (it involves
  calling into the warnings.py module).  You can use -Werror to turn
  the warnings into exceptions though.

- The -Dnew option doesn't select future division for all of the
  program -- only for the __main__ module.  I don't know if I'll ever
  change this -- it would require changes to the .pyc file magic
  number to do it right, and a more global notion of compiler flags.

- You can usefully combine -Dwarn and -Dnew: this gives the __main__
  module new division, and warns about classic division everywhere
  else.
2001-08-31 17:40:15 +00:00
..
.cvsignore Ignore a bunch of generated files. 2000-05-02 18:34:30 +00:00
abstract.c Patch #445762: Support --disable-unicode 2001-08-17 18:39:25 +00:00
bufferobject.c repr's converted to using PyString_FromFormat() instead of sprintf'ing 2001-08-24 18:34:26 +00:00
cellobject.c Use new GC API. 2001-08-29 23:54:21 +00:00
classobject.c Use new GC API. 2001-08-29 23:54:21 +00:00
cobject.c REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
complexobject.c Add warning mode for classic division, almost exactly as specified in 2001-08-31 17:40:15 +00:00
descrobject.c Make getset subclassable. 2001-08-30 03:10:36 +00:00
dictobject.c Use new GC API. 2001-08-29 23:54:21 +00:00
fileobject.c repr's converted to using PyString_FromFormat() instead of sprintf'ing 2001-08-24 18:34:26 +00:00
floatobject.c Add warning mode for classic division, almost exactly as specified in 2001-08-31 17:40:15 +00:00
frameobject.c Squash new compiler wng in debug build. 2001-08-30 00:32:51 +00:00
funcobject.c Use new GC API. 2001-08-29 23:54:21 +00:00
intobject.c Add warning mode for classic division, almost exactly as specified in 2001-08-31 17:40:15 +00:00
iterobject.c Patch #427190: Implement and use METH_NOARGS and METH_O. 2001-08-16 13:15:00 +00:00
listobject.c Give the internal immutable list type .extend and .pop methods (they 2001-08-30 06:15:32 +00:00
longobject.c Add warning mode for classic division, almost exactly as specified in 2001-08-31 17:40:15 +00:00
methodobject.c Removed some unreachable break statements to silence SGI compiler. 2001-08-30 13:58:58 +00:00
moduleobject.c Use new GC API. 2001-08-29 23:54:21 +00:00
object.c Add warning mode for classic division, almost exactly as specified in 2001-08-31 17:40:15 +00:00
obmalloc.c Identifiers matching _[A-Z_]\w* are reserved for C implementations. 2001-03-11 18:36:13 +00:00
rangeobject.c repr's converted to using PyString_FromFormat() instead of sprintf'ing 2001-08-24 18:34:26 +00:00
sliceobject.c Merge of descr-branch back into trunk. 2001-08-02 04:15:00 +00:00
stringobject.c Fix a memory leak in str_subtype_new(). (All the other 2001-08-31 16:11:15 +00:00
tupleobject.c More stuff discovered while writing the simplest of testcases: 2001-08-30 18:31:30 +00:00
typeobject.c Give 'super' a decent repr(), and readonly attributes to access the 2001-08-30 23:13:11 +00:00
unicodectype.c removed "register const" from scalar arguments to the unicode 2001-06-27 22:08:26 +00:00
unicodeobject.c Make unicode subclassable. 2001-08-30 03:12:59 +00:00
unicodetype_db.h forgot to check in the new makeunicodedata.py script 2001-01-21 17:01:31 +00:00
xxobject.c REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00