Skip to content

Commit c149c0e

Browse files
committed
Remove length restrictions
Microsoft's compilers are a lot less limited now
1 parent e80c4ce commit c149c0e

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

setup.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -749,31 +749,17 @@ def add_doc(archive, topdir):
749749

750750
def create_c_file(src, dest):
751751
# Transforms Python src into C dest as a sequence of strings.
752-
# Because of the pathetic microsoft compiler we have to break it
753-
# up into small chunks
754752
out = ["/* Automatically generated by setup.py from " + src + " */", ""]
755-
percents = 1
756-
size = 0
757753
for line in read_whole_file(src, "rt").split("\n"):
758754
if "if__name__=='__main__':" in line.replace(" ", ""):
759755
break
760756
if line.strip().startswith('#'): # full line comment
761757
continue
762758
if line.strip() == "import apsw":
763759
continue
764-
size = size + len(line)
765-
comma = size > 32000
766-
if comma:
767-
size = 0
768-
percents += 1
769760
line=line.replace("\\", "\\\\").\
770761
replace('"', '\\"')
771762
out.append(' "' + line.rstrip() + '\\n"')
772-
if comma:
773-
out[-1] = out[-1] + ","
774-
if out[-1].endswith(","):
775-
out[-1] = out[-1][:-1]
776-
out[1] = '"%s",' % ("%s" * percents, )
777763
write_whole_file(dest, "wt", "\n".join(out))
778764

779765

src/apsw.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,9 @@ modules etc. For example::
19331933
return NULL;
19341934
}
19351935

1936+
static const char *apsw_shell_code =
1937+
#include "shell.c"
1938+
;
19361939
static void
19371940
add_shell(PyObject *apswmodule)
19381941
{
@@ -1943,22 +1946,13 @@ add_shell(PyObject *apswmodule)
19431946
PyDict_SetItemString(apswdict, "__builtins__", PyDict_GetItemString(maindict, "__builtins__"));
19441947
PyDict_SetItemString(apswdict, "apsw", apswmodule);
19451948

1946-
/* the toy compiler from microsoft falls over on string constants
1947-
bigger than will fit in a 16 bit quantity. You remember 16 bits?
1948-
All the rage in the early 1980s. So we have to compose chunks
1949-
into a bytes and use that instead. The format string is as many
1950-
%s as there are chunks. It is generated in setup.py.
1951-
*/
1952-
msvciscrap = PyBytes_FromFormat(
1953-
#include "shell.c"
1954-
);
1955-
if (msvciscrap)
1956-
res = PyRun_StringFlags(PyBytes_AS_STRING(msvciscrap), Py_file_input, apswdict, apswdict, NULL);
1957-
if (!res)
1949+
res = PyRun_StringFlags(apsw_shell_code, Py_file_input, apswdict, apswdict, NULL);
1950+
if (!res) {
19581951
PyErr_Print();
1959-
assert(res);
1960-
Py_XDECREF(res);
1961-
Py_XDECREF(msvciscrap);
1952+
return;
1953+
}
1954+
1955+
Py_DECREF(res);
19621956
}
19631957

19641958
#ifdef APSW_TESTFIXTURES

0 commit comments

Comments
 (0)