Skip to content

Commit ee5af2d

Browse files
committed
Infinity is 9e999 not 1e999
1 parent e0b1af9 commit ee5af2d

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

apsw/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def format_sql_value(value: SQLiteValue) -> str:
305305
306306
Note that SQLite represents floating point `Nan
307307
<https://en.wikipedia.org/wiki/NaN>`__ as :code:`NULL`, infinity as
308-
:code:`1e999` and loses the sign on `negative zero
308+
:code:`9e999` and loses the sign on `negative zero
309309
<https://en.wikipedia.org/wiki/Signed_zero>`__."""
310310
...
311311

apsw/tests/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,8 +1425,8 @@ def testFormatSQLValue(self):
14251425
(wt[:77] + "'" + wt[77:], "'" + wt[:77] + "''" + wt[77:] + "'"),
14261426
# SQLite doesn't understand 'inf', 'nan' or negative zero
14271427
# so output what it does
1428-
(math.inf, "1e999"),
1429-
(-math.inf, "-1e999"),
1428+
(math.inf, "9e999"),
1429+
(-math.inf, "-9e999"),
14301430
(math.nan, "NULL"),
14311431
(-0.0, "0.0"),
14321432
)
@@ -9138,7 +9138,7 @@ def __init__(self):
91389138
def testnasty():
91399139
reset()
91409140
cmd("""create table if not exists nastydata(x,y);
9141-
insert into nastydata values(x'', 1e999); -- see issue 482 for zero sized blob
9141+
insert into nastydata values(x'', 9e999); -- see issue 482 for zero sized blob
91429142
insert into nastydata values(null,'xxx\\u1234\\uabcdyyy\r\n\t\"this is nasty\u0001stuff!');
91439143
""")
91449144
s.cmdloop()

src/apsw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ get_keywords(void)
14011401
14021402
Note that SQLite represents floating point `Nan
14031403
<https://en.wikipedia.org/wiki/NaN>`__ as :code:`NULL`, infinity as
1404-
:code:`1e999` and loses the sign on `negative zero
1404+
:code:`9e999` and loses the sign on `negative zero
14051405
<https://en.wikipedia.org/wiki/Signed_zero>`__.
14061406
*/
14071407
static PyObject *
@@ -1422,7 +1422,7 @@ formatsqlvalue(PyObject *Py_UNUSED(self), PyObject *value)
14221422
if (isnan(d))
14231423
return Py_NewRef(apst.sNULL);
14241424
if (isinf(d))
1425-
return Py_NewRef(signbit(d) ? apst.s_1e999 : apst.s1e999);
1425+
return Py_NewRef(signbit(d) ? apst.s_9e999 : apst.s9e999);
14261426
if (d == 0 && signbit(d))
14271427
return Py_NewRef(apst.s0_0);
14281428
return PyObject_Str(value);

src/stringconstants.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77

88
#undef closed
9-
#undef s_1e999
9+
#undef s_9e999
1010
#undef s0_0
11-
#undef s1e999
11+
#undef s9e999
1212
#undef no_change
1313
#undef Begin
1414
#undef BestIndex
@@ -92,9 +92,9 @@
9292
static struct _apsw_string_table
9393
{
9494
PyObject *closed;
95-
PyObject *s_1e999;
95+
PyObject *s_9e999;
9696
PyObject *s0_0;
97-
PyObject *s1e999;
97+
PyObject *s9e999;
9898
PyObject *no_change;
9999
PyObject *Begin;
100100
PyObject *BestIndex;
@@ -179,9 +179,9 @@ static void
179179
fini_apsw_strings(void)
180180
{
181181
Py_CLEAR(apst.closed);
182-
Py_CLEAR(apst.s_1e999);
182+
Py_CLEAR(apst.s_9e999);
183183
Py_CLEAR(apst.s0_0);
184-
Py_CLEAR(apst.s1e999);
184+
Py_CLEAR(apst.s9e999);
185185
Py_CLEAR(apst.no_change);
186186
Py_CLEAR(apst.Begin);
187187
Py_CLEAR(apst.BestIndex);
@@ -267,9 +267,9 @@ static int
267267
init_apsw_strings()
268268
{
269269
if ((!apst.closed && 0 == (apst.closed = PyUnicode_FromString("(closed)")))
270-
|| (!apst.s_1e999 && 0 == (apst.s_1e999 = PyUnicode_FromString("-1e999")))
270+
|| (!apst.s_9e999 && 0 == (apst.s_9e999 = PyUnicode_FromString("-9e999")))
271271
|| (!apst.s0_0 && 0 == (apst.s0_0 = PyUnicode_FromString("0.0")))
272-
|| (!apst.s1e999 && 0 == (apst.s1e999 = PyUnicode_FromString("1e999")))
272+
|| (!apst.s9e999 && 0 == (apst.s9e999 = PyUnicode_FromString("9e999")))
273273
|| (!apst.no_change && 0 == (apst.no_change = PyUnicode_FromString("<apsw.no_change>")))
274274
|| (!apst.Begin && 0 == (apst.Begin = PyUnicode_FromString("Begin")))
275275
|| (!apst.BestIndex && 0 == (apst.BestIndex = PyUnicode_FromString("BestIndex")))

tools/genstrings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
4040
step final value inverse
4141
42-
NULL 0.0 -1e999 1e999
42+
NULL 0.0 -9e999 9e999
4343
(closed)
4444
4545
release UPDATE INSERT DELETE
@@ -52,8 +52,8 @@ def mangle(name):
5252
return {
5353
"NULL": "sNULL",
5454
"0.0": "s0_0",
55-
"-1e999": "s_1e999",
56-
"1e999": "s1e999",
55+
"-9e999": "s_9e999",
56+
"9e999": "s9e999",
5757
"(closed)": "closed",
5858
"<apsw.no_change>": "no_change",
5959
}.get(name, name)

0 commit comments

Comments
 (0)