(Contributed by Victor Stinner in :issue:`45440`.)
* Building Python now requires a C99 ``<math.h>`` header file providing
- a ``NAN`` constant, or the ``__builtin_nan()`` built-in function. If a
- platform does not support Not-a-Number (NaN), the ``Py_NO_NAN`` macro can be
- defined in the ``pyconfig.h`` file.
+ a ``NAN`` constant, or the ``__builtin_nan()`` built-in function.
(Contributed by Victor Stinner in :issue:`46640`.)
+* Building Python now requires support for floating point Not-a-Number (NaN):
+ remove the ``Py_NO_NAN`` macro.
+ (Contributed by Victor Stinner in :issue:`46656`.)
+
* Freelists for object structs can now be disabled. A new :program:`configure`
option :option:`!--without-freelists` can be used to disable all freelists
except empty tuple singleton.
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
#define PyFloat_CheckExact(op) Py_IS_TYPE(op, &PyFloat_Type)
-#ifdef Py_NAN
-# define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
-#endif
+#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
#define Py_RETURN_INF(sign) \
do { \
# define Py_HUGE_VAL HUGE_VAL
#endif
-/* Py_NAN
- * A value that evaluates to a quiet Not-a-Number (NaN).
- * Define Py_NO_NAN in pyconfig.h if your platform doesn't support NaNs.
- */
-#if !defined(Py_NAN) && !defined(Py_NO_NAN)
+// Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN).
+#if !defined(Py_NAN)
# if _Py__has_builtin(__builtin_nan)
// Built-in implementation of the ISO C99 function nan(): quiet NaN.
# define Py_NAN (__builtin_nan(""))
Building Python now requires a C99 ``<math.h>`` header file providing a ``NAN``
-constant, or the ``__builtin_nan()`` built-in function. If a platform does not
-support Not-a-Number (NaN), the ``Py_NO_NAN`` macro can be defined in the
-``pyconfig.h`` file. Patch by Victor Stinner.
+constant, or the ``__builtin_nan()`` built-in function.
+Patch by Victor Stinner.
--- /dev/null
+Building Python now requires support for floating point Not-a-Number (NaN):
+remove the ``Py_NO_NAN`` macro. Patch by by Victor Stinner.
return r;
}
-#if _PY_SHORT_FLOAT_REPR == 1 || defined(Py_NAN)
+#if _PY_SHORT_FLOAT_REPR == 1
static double
m_nan(void)
PyComplex_FromCComplex(c_infj())) < 0) {
return -1;
}
-#if _PY_SHORT_FLOAT_REPR == 1 || defined(Py_NAN)
+#if _PY_SHORT_FLOAT_REPR == 1
if (PyModule_AddObject(mod, "nan", PyFloat_FromDouble(m_nan())) < 0) {
return -1;
}
/* Constant nan value, generated in the same way as float('nan'). */
/* We don't currently assume that Py_NAN is defined everywhere. */
-#if _PY_SHORT_FLOAT_REPR == 1 || defined(Py_NAN)
+#if _PY_SHORT_FLOAT_REPR == 1
static double
m_nan(void)
if (PyModule_AddObject(module, "inf", PyFloat_FromDouble(m_inf())) < 0) {
return -1;
}
-#if _PY_SHORT_FLOAT_REPR == 1 || defined(Py_NAN)
+#if _PY_SHORT_FLOAT_REPR == 1
if (PyModule_AddObject(module, "nan", PyFloat_FromDouble(m_nan())) < 0) {
return -1;
}
}
else {
/* NaN */
-#ifdef Py_NAN
return sign ? -Py_NAN : Py_NAN;
-#else
- PyErr_SetString(
- PyExc_ValueError,
- "can't unpack IEEE 754 NaN "
- "on platform that does not support NaNs");
- return -1;
-#endif // !defined(Py_NAN)
}
#else // _PY_SHORT_FLOAT_REPR == 1
if (f == 0) {
s += 5;
retval = negate ? -Py_HUGE_VAL : Py_HUGE_VAL;
}
-#ifdef Py_NAN
else if (case_insensitive_match(s, "nan")) {
s += 3;
retval = negate ? -Py_NAN : Py_NAN;
}
-#endif
else {
s = p;
retval = -1.0;