aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md18
-rw-r--r--src/Makefile32
-rw-r--r--src/intobject.c7
3 files changed, 55 insertions, 2 deletions
diff --git a/README.md b/README.md
index 06d6ecc..e36fc1c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,23 @@
# Python 0.9.1 (patched, QoL improvements)
+*by Arslaan Pathan*
+https://arslaancodes.com/
> Notice: This is not endorsed by the Python Software Foundation nor is it endorsed by Stichting Mathematisch Centrum/CWI or any of their subsidiaries.
This repository is a patched version of Python 0.9.1 which fixes the multiplication integer overflow bug on 64-bit systems, sets -std=c89 in CFLAGS by default to be compatible with GCC 15, and a couple of other QoL improvements.
+
+## QoL improvements
+- Fixed int_mul integer overflow bug in src/intobject.c on 64-bit systems
+- Added -std=c89 to CFLAGS in Makefile for compatibility with GCC 15+
+- Added a `make install` target that installs to /opt/python091 by default (python is at /opt/python091/bin/py091), this can be changed with the INSTALL_DIR env variable.
+
+## Some tips to get you started
+
+1. The syntax of Python 0.9.1 is quite similar to the syntax of Python 2, but with fewer features. The language is more lightweight overall.
+2. Start by attempting to write FizzBuzz and some basic scripts. If you know Python 3, this language is easy to learn. The language is best learnt by experimenting.
+2. The `os` module does not exist here; use `posix` instead.
+3. The singular `=` sign is used for both assignment AND comparison (a nightmare, I know.)
+4. Some things may be unstable, it is not fully tested. I'll have to read through the whole codebase later.
+
+
+> Original README is at README.original
diff --git a/src/Makefile b/src/Makefile
index e1f21cc..6308b45 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -180,7 +180,6 @@ DEFPYTHONPATH= .:/usr/local/lib/python:/ufs/guido/lib/python:../lib
#RL_LIBS= $(LIBREADLINE) $(LIBALLOCA) $(LIBTERMCAP)
#RL_LIBDEPS= $(LIBREADLINE) $(LIBALLOCA)
-
# STDWIN Option
# =============
#
@@ -378,6 +377,9 @@ GENSOURCES= acceler.c fgetsintr.c grammar1.c \
firstsets.c grammar.c metagrammar.c pgen.c \
pgenmain.c printgrammar.c
+# patched by Arslaan Pathan 2026-01-21
+# use -std=c89 so it compiles with modern cc/gcc
+CFLAGS="-std=c89"
# Main Targets
# ============
@@ -505,3 +507,31 @@ glmodule.c: cstubs cgen
#graminit.c graminit.h: Grammar python_gen
# python_gen Grammar
+
+
+# ALL CODE PAST HERE IS NOT WRITTEN NOR ENDORSED
+# BY THE PYTHON SOFTWARE FOUNDATION,
+# THE STICHTING MATHEMATISCH CENTRUM,
+# THE CWI,
+# OR ANY OF IT'S/THEIR SUBSIDIARIES
+
+# make install target added by Arslaan Pathan
+# 2026-01-21
+# installs into /opt/python091 by default
+
+INSTALL_DIR = /opt/python091
+
+install: python
+ install -d $(INSTALL_DIR)
+ install -d $(INSTALL_DIR)/bin
+ install -d $(INSTALL_DIR)/lib
+ install -m 755 python $(INSTALL_DIR)/bin/py091
+ install -m 644 ../lib/* $(INSTALL_DIR)/lib
+ @echo
+ @echo "----- Python 0.9.1 (patched, QoL improvements) -----"
+ @echo "----- by Arslaan Pathan -----"
+ @echo "Installed python 0.9.1 to $(INSTALL_DIR)"
+ @echo "Note: you may need to add $(INSTALL_DIR)/bin to your PATH"
+ @echo "Run the py091 command to get started!"
+
+
diff --git a/src/intobject.c b/src/intobject.c
index 6c700e8..e4ae02b 100644
--- a/src/intobject.c
+++ b/src/intobject.c
@@ -183,6 +183,8 @@ int_sub(v, w)
return newintobject(x);
}
+/* int_mul patched by Arslaan Pathan on 2026-01-21
+ to fix integer overflow on 64-bit systems */
static object *
int_mul(v, w)
intobject *v;
@@ -197,7 +199,10 @@ int_mul(v, w)
a = v->ob_ival;
b = ((intobject *)w) -> ob_ival;
x = (double)a * (double)b;
- if (x > 0x7fffffff || x < (double) (long) 0x80000000)
+ /* hardcode 32-bit integer limit as an integer
+ instead of using integer-width dependent
+ constants such as 0x7fffffff and 0x80000000 */
+ if (x > 2147483647 || x < (double) (long) -2147483648)
return err_ovf();
return newintobject(a * b);
}