From 271e89164e508ddbdd07091e0e7174012cd00120 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 2 Mar 2017 11:58:56 +0000 Subject: [PATCH] Add text/x-python3 content type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This derives from the text/x-python content type, and is attached to files with a .py3 extension, or which have a python3 shebang line. Otherwise, text/x-python is preferred. This is necessary because Python 3 is not compatible with Python 2, and introduces some new keywords (such as ‘nonlocal’) which need to be syntax highlighted differently (for example). Signed-off-by: Philip Withnall https://bugs.freedesktop.org/show_bug.cgi?id=100034 --- freedesktop.org.xml.in | 25 ++++++++++++++++++++++--- tests/list | 3 +++ tests/test.py3 | 19 +++++++++++++++++++ tests/test3.py | 19 +++++++++++++++++++ 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 tests/test.py3 create mode 100644 tests/test3.py diff --git a/freedesktop.org.xml.in b/freedesktop.org.xml.in index f03af62..61c3994 100644 --- a/freedesktop.org.xml.in +++ b/freedesktop.org.xml.in @@ -6015,6 +6015,25 @@ command to generate the output files. + + <_comment>Python 3 script + + + + + + + + + + + + + + + + + <_comment>Python script @@ -6031,9 +6050,9 @@ command to generate the output files. - - - + + + <_comment>Lua script diff --git a/tests/list b/tests/list index e41f533..d582913 100644 --- a/tests/list +++ b/tests/list @@ -311,6 +311,9 @@ test.jnlp application/x-java-jnlp-file # Python script test.py text/x-python test.pyx text/x-python ox +# Python 3 script +test3.py text/x-python3 x +test.py3 text/x-python3 # Perl test.pl application/x-perl test.pm application/x-perl diff --git a/tests/test.py3 b/tests/test.py3 new file mode 100644 index 0000000..0703c65 --- /dev/null +++ b/tests/test.py3 @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +from math import sin, pi + + +def f(x): + return sin(x ** 2) + + +def integrate_f(a, b, N): + s = 0 + dx = (b - a) / N + for i in range(N): + s += f(a + i * dx) + return s * dx + + +if __name__ == '__main__': + print(integrate_f(0, pi, 1000)) diff --git a/tests/test3.py b/tests/test3.py new file mode 100644 index 0000000..0703c65 --- /dev/null +++ b/tests/test3.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +from math import sin, pi + + +def f(x): + return sin(x ** 2) + + +def integrate_f(a, b, N): + s = 0 + dx = (b - a) / N + for i in range(N): + s += f(a + i * dx) + return s * dx + + +if __name__ == '__main__': + print(integrate_f(0, pi, 1000)) -- 2.9.3