Skip to content

Commit ba1e0f4

Browse files
author
Skip Montanaro
committed
Issue 7147 - remove ability to attempt to build Python without complex number support (was broken anyway)
1 parent 6ead552 commit ba1e0f4

File tree

10 files changed

+4
-32
lines changed

10 files changed

+4
-32
lines changed

Include/Python.h

-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@
7373
#include "longintrepr.h"
7474
#include "boolobject.h"
7575
#include "floatobject.h"
76-
#ifndef WITHOUT_COMPLEX
7776
#include "complexobject.h"
78-
#endif
7977
#include "rangeobject.h"
8078
#include "memoryobject.h"
8179
#include "tupleobject.h"

Misc/NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 1?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue *7147: Remove support for compiling Python without complex number
16+
support.
17+
1518
- Issue #7120: logging: Removed import of multiprocessing which is causing
1619
crash in GAE.
1720

Objects/complexobject.c

-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include <ieeefp.h>
1313
#endif
1414

15-
#ifndef WITHOUT_COMPLEX
16-
1715
/* elementary operations on complex numbers */
1816

1917
static Py_complex c_1 = {1., 0.};
@@ -1108,5 +1106,3 @@ PyTypeObject PyComplex_Type = {
11081106
complex_new, /* tp_new */
11091107
PyObject_Del, /* tp_free */
11101108
};
1111-
1112-
#endif

Objects/object.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1536,10 +1536,9 @@ _Py_ReadyTypes(void)
15361536
if (PyType_Ready(&PyStaticMethod_Type) < 0)
15371537
Py_FatalError("Can't initialize static method type");
15381538

1539-
#ifndef WITHOUT_COMPLEX
15401539
if (PyType_Ready(&PyComplex_Type) < 0)
15411540
Py_FatalError("Can't initialize complex type");
1542-
#endif
1541+
15431542
if (PyType_Ready(&PyFloat_Type) < 0)
15441543
Py_FatalError("Can't initialize float type");
15451544

Parser/tokenizer.c

-6
Original file line numberDiff line numberDiff line change
@@ -1383,10 +1383,8 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
13831383
c = tok_nextc(tok);
13841384
if (c == '.')
13851385
goto fraction;
1386-
#ifndef WITHOUT_COMPLEX
13871386
if (c == 'j' || c == 'J')
13881387
goto imaginary;
1389-
#endif
13901388
if (c == 'x' || c == 'X') {
13911389

13921390
/* Hex */
@@ -1438,10 +1436,8 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
14381436
goto fraction;
14391437
else if (c == 'e' || c == 'E')
14401438
goto exponent;
1441-
#ifndef WITHOUT_COMPLEX
14421439
else if (c == 'j' || c == 'J')
14431440
goto imaginary;
1444-
#endif
14451441
else if (nonzero) {
14461442
tok->done = E_TOKEN;
14471443
tok_backup(tok, c);
@@ -1478,12 +1474,10 @@ tok_get(register struct tok_state *tok, char **p_start, char **p_end)
14781474
c = tok_nextc(tok);
14791475
} while (isdigit(c));
14801476
}
1481-
#ifndef WITHOUT_COMPLEX
14821477
if (c == 'j' || c == 'J')
14831478
/* Imaginary part */
14841479
imaginary:
14851480
c = tok_nextc(tok);
1486-
#endif
14871481
}
14881482
}
14891483
tok_backup(tok, c);

Python/ast.c

-6
Original file line numberDiff line numberDiff line change
@@ -3177,17 +3177,13 @@ parsenumber(struct compiling *c, const char *s)
31773177
const char *end;
31783178
long x;
31793179
double dx;
3180-
#ifndef WITHOUT_COMPLEX
31813180
Py_complex compl;
31823181
int imflag;
3183-
#endif
31843182

31853183
assert(s != NULL);
31863184
errno = 0;
31873185
end = s + strlen(s) - 1;
3188-
#ifndef WITHOUT_COMPLEX
31893186
imflag = *end == 'j' || *end == 'J';
3190-
#endif
31913187
if (s[0] == '0') {
31923188
x = (long) PyOS_strtoul((char *)s, (char **)&end, 0);
31933189
if (x < 0 && errno == 0) {
@@ -3204,7 +3200,6 @@ parsenumber(struct compiling *c, const char *s)
32043200
return PyLong_FromLong(x);
32053201
}
32063202
/* XXX Huge floats may silently fail */
3207-
#ifndef WITHOUT_COMPLEX
32083203
if (imflag) {
32093204
compl.real = 0.;
32103205
compl.imag = PyOS_string_to_double(s, (char **)&end, NULL);
@@ -3213,7 +3208,6 @@ parsenumber(struct compiling *c, const char *s)
32133208
return PyComplex_FromCComplex(compl);
32143209
}
32153210
else
3216-
#endif
32173211
{
32183212
dx = PyOS_string_to_double(s, NULL, NULL);
32193213
if (dx == -1.0 && PyErr_Occurred())

Python/bltinmodule.c

-2
Original file line numberDiff line numberDiff line change
@@ -2302,9 +2302,7 @@ _PyBuiltin_Init(void)
23022302
SETBUILTIN("bytearray", &PyByteArray_Type);
23032303
SETBUILTIN("bytes", &PyBytes_Type);
23042304
SETBUILTIN("classmethod", &PyClassMethod_Type);
2305-
#ifndef WITHOUT_COMPLEX
23062305
SETBUILTIN("complex", &PyComplex_Type);
2307-
#endif
23082306
SETBUILTIN("dict", &PyDict_Type);
23092307
SETBUILTIN("enumerate", &PyEnum_Type);
23102308
SETBUILTIN("filter", &PyFilter_Type);

Python/getargs.c

-4
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
818818
break;
819819
}
820820

821-
#ifndef WITHOUT_COMPLEX
822821
case 'D': {/* complex double */
823822
Py_complex *p = va_arg(*p_va, Py_complex *);
824823
Py_complex cval;
@@ -829,7 +828,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
829828
*p = cval;
830829
break;
831830
}
832-
#endif /* WITHOUT_COMPLEX */
833831

834832
case 'c': {/* char */
835833
char *p = va_arg(*p_va, char *);
@@ -1772,9 +1770,7 @@ skipitem(const char **p_format, va_list *p_va, int flags)
17721770
#endif
17731771
case 'f': /* float */
17741772
case 'd': /* double */
1775-
#ifndef WITHOUT_COMPLEX
17761773
case 'D': /* complex double */
1777-
#endif
17781774
case 'c': /* char */
17791775
{
17801776
(void) va_arg(*p_va, void *);

Python/marshal.c

-4
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ w_object(PyObject *v, WFILE *p)
254254
PyMem_Free(buf);
255255
}
256256
}
257-
#ifndef WITHOUT_COMPLEX
258257
else if (PyComplex_CheckExact(v)) {
259258
if (p->version > 1) {
260259
unsigned char buf[8];
@@ -297,7 +296,6 @@ w_object(PyObject *v, WFILE *p)
297296
PyMem_Free(buf);
298297
}
299298
}
300-
#endif
301299
else if (PyBytes_CheckExact(v)) {
302300
w_byte(TYPE_STRING, p);
303301
n = PyBytes_GET_SIZE(v);
@@ -714,7 +712,6 @@ r_object(RFILE *p)
714712
break;
715713
}
716714

717-
#ifndef WITHOUT_COMPLEX
718715
case TYPE_COMPLEX:
719716
{
720717
char buf[256];
@@ -773,7 +770,6 @@ r_object(RFILE *p)
773770
retval = PyComplex_FromCComplex(c);
774771
break;
775772
}
776-
#endif
777773

778774
case TYPE_STRING:
779775
n = r_long(p);

Python/modsupport.c

-2
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,9 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
279279
return PyFloat_FromDouble(
280280
(double)va_arg(*p_va, va_double));
281281

282-
#ifndef WITHOUT_COMPLEX
283282
case 'D':
284283
return PyComplex_FromCComplex(
285284
*((Py_complex *)va_arg(*p_va, Py_complex *)));
286-
#endif /* WITHOUT_COMPLEX */
287285

288286
case 'c':
289287
{

0 commit comments

Comments
 (0)