summaryrefslogtreecommitdiff
path: root/Include/pydebug.h
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-12-06 06:23:26 +0000
committerTim Peters <tim.peters@gmail.com>2001-12-06 06:23:26 +0000
commit1ff5ccdf0983c62db8e202041a6e09cf81f6fce8 (patch)
tree3149dd2c3f7ffb5de3fc44a892b0175bf18e47fc /Include/pydebug.h
parentca2b6592ec3de28764edad30ded0acbb012ed66e (diff)
downloadcpython-1ff5ccdf0983c62db8e202041a6e09cf81f6fce8.tar.gz
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>.
Diffstat (limited to 'Include/pydebug.h')
-rw-r--r--Include/pydebug.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Include/pydebug.h b/Include/pydebug.h
index 9ecd8a00d2..d92161cd64 100644
--- a/Include/pydebug.h
+++ b/Include/pydebug.h
@@ -16,6 +16,10 @@ extern DL_IMPORT(int) Py_TabcheckFlag;
extern DL_IMPORT(int) Py_UnicodeFlag;
extern DL_IMPORT(int) Py_IgnoreEnvironmentFlag;
extern DL_IMPORT(int) Py_DivisionWarningFlag;
+/* _XXX Py_QnewFlag should go away in 2.3. It's true iff -Qnew is passed,
+ on the command line, and is used in 2.2 by ceval.c to make all "/" divisions
+ true divisions (which they will be in 2.3). */
+extern DL_IMPORT(int) _Py_QnewFlag;
/* this is a wrapper around getenv() that pays attention to
Py_IgnoreEnvironmentFlag. It should be used for getting variables like