From 4d8125a2fdb7ec66bc7e4a5d277d04fbbb7ff353 Mon Sep 17 00:00:00 2001 From: Martin Green Date: Wed, 22 Jun 2022 09:10:56 +0100 Subject: [PATCH] removed rest of endocings --- core/views/expo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/views/expo.py b/core/views/expo.py index 885eafd..66dffd0 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -121,19 +121,19 @@ def expofilesdir(request, dirpath, filepath): def expowebpage(request, expowebpath, path): '''Adds menus and serves an HTML page ''' - if not os.path.isfile(os.path.normpath(expowebpath / path).encode(sysdefaultencoding)): + if not os.path.isfile(expowebpath / path): # Should not get here if the path has suffix "_edit" print(f' - 404 error in expowebpage() {path}') return render(request, 'pagenotfound.html', {'path': path}, status="404") try: - with open(os.path.normpath(expowebpath / path).encode(sysdefaultencoding), "r", encoding='utf-8') as o: + with open(expowebpath / path, "r", encoding='utf-8') as o: html = o.read() except: # exception raised on debian with python 3.9.2 but not on WSL Ubuntu with python 3.9.5 # because debian was assuming default text encoding was 'ascii'. Now specified explicitly so should be OK try: - with open(os.path.normpath(expowebpath / path).encode(sysdefaultencoding), "rb") as o: + with open(expowebpath / path, "rb") as o: html = str(o.read()).replace("

","

BAD NON-UTF-8 characters here - ") html = html.replace("\\n","\n") html = html.replace("\\r","") @@ -156,7 +156,7 @@ def expowebpage(request, expowebpath, path): if m: editable = False else: - editable = os.access(os.path.normpath(expowebpath / path).encode(sysdefaultencoding), os.W_OK) # are file permissions writeable? + editable = os.access(expowebpath / path, os.W_OK) # are file permissions writeable? has_menu = False menumatch = re.match(r'(.*)