cpython/Include
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
..
Python.h Merge of descr-branch back into trunk. 2001-08-02 04:15:00 +00:00
abstract.h Implement PEP 238 in its (almost) full glory. 2001-08-08 05:00:18 +00:00
bitset.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
bufferobject.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
cStringIO.h Cast the result of xxxPyCObject_Import to PycStringIO_CAPI*. 2001-06-09 07:59:43 +00:00
cellobject.h PEP 227 implementation 2001-01-25 20:04:14 +00:00
ceval.h Merge of descr-branch back into trunk. 2001-08-02 04:15:00 +00:00
classobject.h Merge of descr-branch back into trunk. 2001-08-02 04:15:00 +00:00
cobject.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
codecs.h Changing the CNRI copyright notice according to CNRI's instructions. 2000-08-03 16:24:25 +00:00
compile.h Refactor future feature handling 2001-08-10 21:38:04 +00:00
complexobject.h Make the PyXXX_Check() macros for the numeric types inheritance-aware. 2001-08-29 15:45:32 +00:00
descrobject.h Add new built-in type 'getset' (PyGetSet_Type). 2001-08-23 21:40:38 +00:00
dictobject.h Add PyDict_Merge(a, b, override): 2001-08-10 20:28:28 +00:00
errcode.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
eval.h Merge of descr-branch back into trunk. 2001-08-02 04:15:00 +00:00
fileobject.h Fix the Py_FileSystemDefaultEncoding checkin - declare the variable in a fileobject.h, and initialize it in bltinmodule. 2001-05-14 12:17:34 +00:00
floatobject.h Make the PyXXX_Check() macros for the numeric types inheritance-aware. 2001-08-29 15:45:32 +00:00
frameobject.h Make frames a PyVarObject instead of a PyObject. 2001-08-29 23:45:25 +00:00
funcobject.h Merge of descr-branch back into trunk. 2001-08-02 04:15:00 +00:00
graminit.h Merging the gen-branch into the main line, at Guido's direction. Yay! 2001-06-18 22:08:13 +00:00
grammar.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
import.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
intobject.h Make the PyXXX_Check() macros for the numeric types inheritance-aware. 2001-08-29 15:45:32 +00:00
intrcheck.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
iterobject.h Mondo changes to the iterator stuff, without changing how Python code 2001-04-23 14:08:49 +00:00
listobject.h Merge of descr-branch back into trunk. 2001-08-02 04:15:00 +00:00
longintrepr.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
longobject.h Make the PyXXX_Check() macros for the numeric types inheritance-aware. 2001-08-29 15:45:32 +00:00
marshal.h It's unclear whether PyMarshal_XXX() are part of the public or private API. 2001-01-28 00:27:39 +00:00
metagrammar.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
methodobject.h Remove much dead code from ceval.c 2001-08-12 21:52:24 +00:00
modsupport.h Merge of descr-branch back into trunk. 2001-08-02 04:15:00 +00:00
moduleobject.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
node.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
object.h Change the GC type flag since the API has changed. Allow types using 2001-08-29 23:46:35 +00:00
objimpl.h Change the GC type flag since the API has changed. Allow types using 2001-08-29 23:49:28 +00:00
opcode.h Implement PEP 238 in its (almost) full glory. 2001-08-08 05:00:18 +00:00
osdefs.h RISCOS patch by dschwertberger 2001-03-02 06:10:17 +00:00
parsetok.h Ugly. A pile of new xxxFlags() functions, to communicate to the parser 2001-07-16 05:37:24 +00:00
patchlevel.h Merge changes from r22a2-branch back into trunk. Also, change patch 2001-08-22 19:24:42 +00:00
pgenheaders.h Repair more now-obsolete references to config.h. 2001-07-26 21:34:59 +00:00
py_curses.h Added header file for C API exported by _cursesmodule.c 2000-12-22 21:51:10 +00:00
pydebug.h Add warning mode for classic division, almost exactly as specified in 2001-08-31 17:40:15 +00:00
pyerrors.h Introduce OverflowWarning -- to be issued when short int operations 2001-08-23 02:56:07 +00:00
pyfpe.h Some patches to Lee Busby's fpectl mods that accidentally didn't make it 1997-10-20 23:50:01 +00:00
pygetopt.h Move our own getopt() implementation to _PyOS_GetOpt(), and use it 2000-11-03 08:18:37 +00:00
pymactoolbox.h Split macglue.c into two: a new mactoolboxglue.c (in ./Python) 2001-08-08 13:17:31 +00:00
pymem.h Repair more now-obsolete references to config.h. 2001-07-26 21:34:59 +00:00
pyport.h SF bug [#456252] Python should never stomp on [u]intptr_t. 2001-08-29 21:37:10 +00:00
pystate.h Add a low-level API to access interpreters, for David Beazley. 2001-07-19 12:19:27 +00:00
pythonrun.h Add warning mode for classic division, almost exactly as specified in 2001-08-31 17:40:15 +00:00
pythread.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
rangeobject.h Re-add 'advanced' xrange features, adding DeprecationWarnings as discussed 2001-07-09 12:30:54 +00:00
sliceobject.h ANSI-fication and Py_PROTO extermination. 2000-07-09 00:55:06 +00:00
stringobject.h Make the Py<type>_Check() macro use PyObject_TypeCheck(). 2001-08-30 03:08:07 +00:00
structmember.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
symtable.h Remove st_nested_scopes from struct symtable, 2001-08-11 21:51:24 +00:00
sysmodule.h Add declarations for PySys_ResetWarnOptions() and 2000-12-15 22:01:39 +00:00
token.h Implement PEP 238 in its (almost) full glory. 2001-08-08 05:00:18 +00:00
traceback.h REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
tupleobject.h Make the Py<type>_Check() macro use PyObject_TypeCheck(). 2001-08-30 03:08:07 +00:00
ucnhash.h refactored the unicodeobject/ucnhash interface, to hide the 2001-01-19 09:45:02 +00:00
unicodeobject.h Make the Py<type>_Check() macro use PyObject_TypeCheck(). 2001-08-30 03:08:07 +00:00