From d094352ddf5ccc480633142dea59e11d944db9dd Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Wed, 7 Apr 2021 15:20:32 +0200 Subject: [PATCH 1/3] Issue #1761 - Enable use of Tauthon instead of Python 2.7 at build Make essential Tauthon's builtins and modules available in sandboxes, without disrupting building with Python 2.7. 1. Allow new builtins and modules. "__build_class__" is for building... new-style classes (to handle the new metaclass syntax imported from 3.x). "_oserror" is necessary because of internal changes to raise errors deriving from OSError (which are reported as IOError if not caught). 2. Look for modules and packages in the right places. This was tested on FreeBSD, and should work out of the box on Linux. --- .../mozbuild/mozbuild/configure/__init__.py | 5 ++-- python/mozbuild/mozbuild/frontend/sandbox.py | 5 +++- python/virtualenv/site.py | 24 +++++++++++-------- python/virtualenv/virtualenv.py | 12 +++++++--- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/python/mozbuild/mozbuild/configure/__init__.py b/python/mozbuild/mozbuild/configure/__init__.py index 0fe640caee..a59876fcae 100644 --- a/python/mozbuild/mozbuild/configure/__init__.py +++ b/python/mozbuild/mozbuild/configure/__init__.py @@ -192,8 +192,9 @@ class ConfigureSandbox(dict): b: __builtins__[b] for b in ('None', 'False', 'True', 'int', 'bool', 'any', 'all', 'len', 'list', 'tuple', 'set', 'dict', 'isinstance', 'getattr', - 'hasattr', 'enumerate', 'range', 'zip') - }, __import__=forbidden_import, str=unicode) + 'hasattr', 'enumerate', 'range', 'zip', '__build_class__') + if b in __builtins__}, + __import__=forbidden_import, str=unicode) # Expose a limited set of functions from os.path OS = ReadOnlyNamespace(path=ReadOnlyNamespace(**{ diff --git a/python/mozbuild/mozbuild/frontend/sandbox.py b/python/mozbuild/mozbuild/frontend/sandbox.py index 0bf1599f20..3638ec807c 100644 --- a/python/mozbuild/mozbuild/frontend/sandbox.py +++ b/python/mozbuild/mozbuild/frontend/sandbox.py @@ -115,7 +115,10 @@ class Sandbox(dict): def __init__(self, context, builtins=None, finder=default_finder): """Initialize a Sandbox ready for execution. """ - self._builtins = builtins or self.BUILTINS + self._builtins = ReadOnlyDict( + (builtins or self.BUILTINS).viewitems() | + {b: __builtins__[b] for b in ('__build_class__',) + if b in __builtins__}.viewitems()) dict.__setitem__(self, '__builtins__', self._builtins) assert isinstance(self._builtins, ReadOnlyDict) diff --git a/python/virtualenv/site.py b/python/virtualenv/site.py index 4e426cdb66..bf23c19204 100644 --- a/python/virtualenv/site.py +++ b/python/virtualenv/site.py @@ -65,6 +65,7 @@ ImportError exception, it is silently ignored. import sys import os +import platform try: import __builtin__ as builtins @@ -85,11 +86,14 @@ USER_SITE = None USER_BASE = None _is_64bit = (getattr(sys, 'maxsize', None) or getattr(sys, 'maxint')) > 2**32 +_is_tauthon = platform.python_implementation() == "Tauthon" _is_pypy = hasattr(sys, 'pypy_version_info') _is_jython = sys.platform[:4] == 'java' if _is_jython: ModuleType = type(os) +_python_libdir = "tauthon" if _is_tauthon else "python" + def makepath(*paths): dir = os.path.join(*paths) if _is_jython and (dir == '__classpath__' or @@ -228,16 +232,16 @@ def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_pre else: # any other Python distros on OSX work this way sitedirs = [os.path.join(prefix, "lib", - "python" + sys.version[:3], "site-packages")] + _python_libdir + sys.version[:3], "site-packages")] elif os.sep == '/': sitedirs = [os.path.join(prefix, "lib", - "python" + sys.version[:3], + _python_libdir + sys.version[:3], "site-packages"), os.path.join(prefix, "lib", "site-python"), - os.path.join(prefix, "python" + sys.version[:3], "lib-dynload")] - lib64_dir = os.path.join(prefix, "lib64", "python" + sys.version[:3], "site-packages") + os.path.join(prefix, _python_libdir + sys.version[:3], "lib-dynload")] + lib64_dir = os.path.join(prefix, "lib64", _python_libdir + sys.version[:3], "site-packages") if (os.path.exists(lib64_dir) and os.path.realpath(lib64_dir) not in [os.path.realpath(p) for p in sitedirs]): if _is_64bit: @@ -252,15 +256,15 @@ def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_pre pass # Debian-specific dist-packages directories: sitedirs.append(os.path.join(prefix, "local/lib", - "python" + sys.version[:3], + _python_libdir + sys.version[:3], "dist-packages")) if sys.version[0] == '2': sitedirs.append(os.path.join(prefix, "lib", - "python" + sys.version[:3], + _python_libdir + sys.version[:3], "dist-packages")) else: sitedirs.append(os.path.join(prefix, "lib", - "python" + sys.version[0], + _python_libdir + sys.version[0], "dist-packages")) sitedirs.append(os.path.join(prefix, "lib", "dist-python")) else: @@ -583,9 +587,9 @@ def virtual_install_main_packages(): elif sys.platform == 'win32' and os.sep == '\\': paths = [os.path.join(sys.real_prefix, 'Lib'), os.path.join(sys.real_prefix, 'DLLs')] else: - paths = [os.path.join(sys.real_prefix, 'lib', 'python'+sys.version[:3])] + paths = [os.path.join(sys.real_prefix, 'lib', _python_libdir + sys.version[:3])] hardcoded_relative_dirs = paths[:] # for the special 'darwin' case below - lib64_path = os.path.join(sys.real_prefix, 'lib64', 'python'+sys.version[:3]) + lib64_path = os.path.join(sys.real_prefix, 'lib64', _python_libdir + sys.version[:3]) if os.path.exists(lib64_path): if _is_64bit: paths.insert(0, lib64_path) @@ -602,7 +606,7 @@ def virtual_install_main_packages(): # This is a non-multiarch aware Python. Fallback to the old way. arch = sys.platform plat_path = os.path.join(sys.real_prefix, 'lib', - 'python'+sys.version[:3], + _python_libdir + sys.version[:3], 'plat-%s' % arch) if os.path.exists(plat_path): paths.append(plat_path) diff --git a/python/virtualenv/virtualenv.py b/python/virtualenv/virtualenv.py index e363021cc1..655e25cf01 100644 --- a/python/virtualenv/virtualenv.py +++ b/python/virtualenv/virtualenv.py @@ -44,13 +44,14 @@ if sys.version_info < (2, 6): print('ERROR: this script requires Python 2.6 or greater.') sys.exit(101) +import platform + try: basestring except NameError: basestring = str -py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1]) - +is_tauthon = platform.python_implementation() == "Tauthon" is_jython = sys.platform.startswith('java') is_pypy = hasattr(sys, 'pypy_version_info') is_win = (sys.platform == 'win32' and os.sep == '\\') @@ -59,6 +60,9 @@ is_msys2 = (sys.platform == 'win32' and os.sep == '/') is_darwin = (sys.platform == 'darwin') abiflags = getattr(sys, 'abiflags', '') +py_version = '%s%s.%s' % ("tauthon" if is_tauthon else "python", + sys.version_info[0], sys.version_info[1]) + user_dir = os.path.expanduser('~') if is_win: default_storage_dir = os.path.join(user_dir, 'virtualenv') @@ -121,7 +125,7 @@ REQUIRED_MODULES = ['os', 'posix', 'posixpath', 'nt', 'ntpath', 'genericpath', 'fnmatch', 'locale', 'encodings', 'codecs', 'stat', 'UserDict', 'readline', 'copy_reg', 'types', 're', 'sre', 'sre_parse', 'sre_constants', 'sre_compile', - 'zlib'] + 'zlib', 'platform', 'string'] REQUIRED_FILES = ['lib-dynload', 'config'] @@ -131,6 +135,8 @@ if majver == 2: REQUIRED_MODULES.extend(['warnings', 'linecache', '_abcoll', 'abc']) if minver >= 7: REQUIRED_MODULES.extend(['_weakrefset']) + if is_tauthon: + REQUIRED_MODULES.extend(['_oserror']) if is_msys2: REQUIRED_MODULES.extend(['functools']) elif majver == 3: From 437f41ff19d793747470cf88bb0b79edc7fa9784 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sat, 3 Apr 2021 07:38:30 +0000 Subject: [PATCH 2/3] [Pale-Moon] Feed Twitter a native UA so it'll stop blocking. --- application/palemoon/branding/shared/pref/uaoverrides.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/palemoon/branding/shared/pref/uaoverrides.inc b/application/palemoon/branding/shared/pref/uaoverrides.inc index fe21e9707b..7a56551ac6 100644 --- a/application/palemoon/branding/shared/pref/uaoverrides.inc +++ b/application/palemoon/branding/shared/pref/uaoverrides.inc @@ -31,7 +31,6 @@ pref("@GUAO_PREF@.live.com","Mozilla/5.0 (%OS_SLICE% rv:@GK_VERSION@) @GK_SLICE@ pref("@GUAO_PREF@.msn.com","Mozilla/5.0 (%OS_SLICE% rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@GUAO_PREF@.netteller.com","Mozilla/5.0 (%OS_SLICE% rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@"); pref("@GUAO_PREF@.patientaccess.com","Mozilla/5.0 (%OS_SLICE% rv:60.0) @GK_SLICE@ Firefox/60.0 @PM_SLICE@"); -pref("@GUAO_PREF@.twitter.com","Mozilla/5.0 (%OS_SLICE% rv:86.0) @GK_SLICE@ Firefox/86.0"); pref("@GUAO_PREF@.outlook.com","Mozilla/5.0 (%OS_SLICE% rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@GUAO_PREF@.web.de","Mozilla/5.0 (%OS_SLICE% rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); pref("@GUAO_PREF@.yahoo.com","Mozilla/5.0 (%OS_SLICE% rv:99.9) @GK_SLICE@ Firefox/99.9"); @@ -55,6 +54,7 @@ pref("@GUAO_PREF@.mozilla.org","Mozilla/5.0 (%OS_SLICE% rv:@GRE_VERSION@) @GRE_D pref("@GUAO_PREF@.mozilla.com","Mozilla/5.0 (%OS_SLICE% rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); pref("@GUAO_PREF@.github.com","Mozilla/5.0 (%OS_SLICE% rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); pref("@GUAO_PREF@.spotify.com","Mozilla/5.0 (%OS_SLICE% rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); +pref("@GUAO_PREF@.twitter.com","Mozilla/5.0 (%OS_SLICE% rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); // UA-Sniffing domains below have indicated no interest in supporting Pale Moon (BOO!) pref("@GUAO_PREF@.humblebundle.com","Mozilla/5.0 (%OS_SLICE% rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); From 700f7804bdfe9f8d6dbb9b5dae825a297dd16a34 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 9 Apr 2021 12:25:44 +0000 Subject: [PATCH 3/3] [Pale-Moon] Issue #1866 - Add controls for preferred color scheme. --- .../components/preferences/colors.xul | 20 +++++++++++++++++++ .../chrome/browser/preferences/colors.dtd | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/application/palemoon/components/preferences/colors.xul b/application/palemoon/components/preferences/colors.xul index 055b7dcaa4..caf8c8c0ec 100644 --- a/application/palemoon/components/preferences/colors.xul +++ b/application/palemoon/components/preferences/colors.xul @@ -27,6 +27,7 @@ + @@ -90,5 +91,24 @@ + + + + + + + + + + &prefersColorSchemeWarning; + + diff --git a/application/palemoon/locales/en-US/chrome/browser/preferences/colors.dtd b/application/palemoon/locales/en-US/chrome/browser/preferences/colors.dtd index 6d6e8d8e0a..ba14b86e01 100644 --- a/application/palemoon/locales/en-US/chrome/browser/preferences/colors.dtd +++ b/application/palemoon/locales/en-US/chrome/browser/preferences/colors.dtd @@ -28,3 +28,13 @@ + + + + + + + + + +