We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Error message broken on Zope-Root
http://localhost:8080/foo when `foo` does not exists (i.e. is not a Plone instance) results in a traceback.

In Plone 5.1 we used to get:
```
<h2>Site Error</h2> <p>An error was encountered while publishing this resource. </p> <p><strong>Resource not found</strong></p> Sorry, the requested resource does not exist.<p>Check the URL and try again.</p><p><b>Resource:</b> foo GET</p> <hr noshade="noshade"/> <p>Troubleshooting Suggestions</p> <ul> <li>The URL may be incorrect.</li> <li>The parameters passed to this resource may be incorrect.</li> <li>A resource that this resource relies on may be encountering an error.</li> </ul> <p>For more detailed information about the error, please refer to the error log. </p> <p>If the error persists please contact the site maintainer. Thank you for your patience. </p> 
```
That was ugly (escaped html) but the text was correct.

Plone 5.2 on the other hand tries to render the `ExceptionView` and fails sind the app has no method `Language()`. 

```
Traceback (innermost last):

    Module ZServer.ZPublisher.Publish, line 261, in publish_module_standard
    Module Products.PDBDebugMode.runcall, line 83, in pdb_publish
    Module ZServer.ZPublisher.Publish, line 182, in publish
    Module ZServer.ZPublisher.exceptionhook, line 117, in __call__
    Module Products.CMFPlone.browser.exceptions, line 49, in __call__
    Module Products.Five.browser.pagetemplatefile, line 125, in __call__
    Module Products.Five.browser.pagetemplatefile, line 60, in __call__
    Module zope.pagetemplate.pagetemplate, line 134, in pt_render
    Module Products.PageTemplates.engine, line 85, in __call__
    Module z3c.pt.pagetemplate, line 163, in render
    Module chameleon.zpt.template, line 261, in render
    Module chameleon.template, line 191, in render
    Module chameleon.template, line 171, in render
    Module 4195113b17720aee65cd4ca2a7e7ba2d.py, line 1095, in render
    Module 9fafff3b78c7ea63dcd15308ddf75fb8.py, line 652, in render_master
    Module Products.PageTemplates.expression, line 105, in __call__
    Module plone.app.layout.globals.portal, line 80, in language

AttributeError: 'RequestContainer' object has no attribute 'Language'

 - Expression: "portal_state/language"
 - Filename: ... one/Products/CMFPlone/browser/templates/main_template.pt
 - Location: (line 12: col 11)
 - Source: lang portal_state/language; 

 ^^^^^^^^^^^^^^^^^^^^^

 - Arguments: 
    repeat: {...} (0) 
    template: <ViewPageTemplateFile - at 0x10da74950> 
    views: <ViewMapper - at 0x10e47d9d0> 
    modules: <_SecureModuleImporter - at 0x10867bed0> 
    args: <tuple - at 0x1066a0050> 
    here: <ImplicitAcquisitionWrapper at 0x10d34b960> 
    user: <SpecialUser - at 0x108457290> 
    nothing: <NoneType - at 0x1065eeeb8> 
    container: <ImplicitAcquisitionWrapper at 0x10d34b960> 
    request: <HTTPRequest - at 0x10e5f1c90> 
    wrapped_repeat: <SafeMapping - at 0x10c50a5f0> 
    traverse_subpath: <list - at 0x10e88d488> 
    default: <object - at 0x1066f6ba0> 
    loop: {...} (0) context: <ImplicitAcquisitionWrapper at 0x10d34b960> 
    view: <SimpleViewClass from /Users/pbauer/workspace/coredev/src/Products.CMFPlone/Products/CMFPlone/browser/templates/error_message.pt index.html at 0x10c45f9d0> 
    translate: <function translate at 0x10e59f050> 
    root: <ImplicitAcquisitionWrapper at 0x10d34b960> 
    options: {...} (2) 
    target_language: <NoneType - at 0x1065eeeb8>
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `Products/CMFPlone/browser/exceptions.py`
Content:
```
1 from AccessControl import getSecurityManager
2 from Products.Five import BrowserView
3 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
4 from zExceptions.ExceptionFormatter import format_exception
5 import json
6 import sys
7 
8 
9 class ExceptionView(BrowserView):
10     basic_template = ViewPageTemplateFile('templates/basic_error_message.pt')
11 
12     def is_manager(self):
13         return getSecurityManager().checkPermission(
14             'Manage portal', self.context)
15 
16     def __call__(self):
17         exception = self.context
18         self.context = self.__parent__
19         request = self.request
20 
21         error_type = exception.__class__.__name__
22         exc_type, value, traceback = sys.exc_info()
23         error_tb = ''.join(
24             format_exception(exc_type, value, traceback, as_html=True))
25         request.response.setStatus(exc_type)
26 
27         # Indicate exception as JSON
28         if "text/html" not in request.getHeader('Accept', ''):
29             request.response.setHeader("Content-Type", "application/json")
30             return json.dumps({
31                 'error_type': error_type,
32             })
33 
34         # Use a simplified template if main_template is not available
35         try:
36             self.context.unrestrictedTraverse('main_template')
37         except:
38             template = self.basic_template
39         else:
40             template = self.index
41 
42         # Render page with user-facing error notice
43         request.set('disable_border', True)
44         request.set('disable_plone.leftcolumn', True)
45         request.set('disable_plone.rightcolumn', True)
46 
47         return template(
48             error_type=error_type,
49             error_tb=error_tb,
50         )
51
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/Products/CMFPlone/browser/exceptions.py b/Products/CMFPlone/browser/exceptions.py
--- a/Products/CMFPlone/browser/exceptions.py
+++ b/Products/CMFPlone/browser/exceptions.py
@@ -1,7 +1,10 @@
+# -*- coding: utf-8 -*-
 from AccessControl import getSecurityManager
 from Products.Five import BrowserView
 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
 from zExceptions.ExceptionFormatter import format_exception
+from zope.component.hooks import getSite
+
 import json
 import sys
 
@@ -31,13 +34,17 @@
                 'error_type': error_type,
             })
 
-        # Use a simplified template if main_template is not available
-        try:
-            self.context.unrestrictedTraverse('main_template')
-        except:
+        if getSite() is None:
+            # We cannot get the site, so we cannot render our nice template
             template = self.basic_template
         else:
-            template = self.index
+            # Use a simplified template if main_template is not available
+            try:
+                self.context.unrestrictedTraverse('main_template')
+            except:
+                template = self.basic_template
+            else:
+                template = self.index
 
         # Render page with user-facing error notice
         request.set('disable_border', True)

{"golden_diff": "diff --git a/Products/CMFPlone/browser/exceptions.py b/Products/CMFPlone/browser/exceptions.py\n--- a/Products/CMFPlone/browser/exceptions.py\n+++ b/Products/CMFPlone/browser/exceptions.py\n@@ -1,7 +1,10 @@\n+# -*- coding: utf-8 -*-\n from AccessControl import getSecurityManager\n from Products.Five import BrowserView\n from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile\n from zExceptions.ExceptionFormatter import format_exception\n+from zope.component.hooks import getSite\n+\n import json\n import sys\n \n@@ -31,13 +34,17 @@\n                 'error_type': error_type,\n             })\n \n-        # Use a simplified template if main_template is not available\n-        try:\n-            self.context.unrestrictedTraverse('main_template')\n-        except:\n+        if getSite() is None:\n+            # We cannot get the site, so we cannot render our nice template\n             template = self.basic_template\n         else:\n-            template = self.index\n+            # Use a simplified template if main_template is not available\n+            try:\n+                self.context.unrestrictedTraverse('main_template')\n+            except:\n+                template = self.basic_template\n+            else:\n+                template = self.index\n \n         # Render page with user-facing error notice\n         request.set('disable_border', True)\n", "issue": "Error message broken on Zope-Root\nhttp://localhost:8080/foo when `foo` does not exists (i.e. is not a Plone instance) results in a traceback.\r\n\r\nIn Plone 5.1 we used to get:\r\n```\r\n<h2>Site Error</h2> <p>An error was encountered while publishing this resource. </p> <p><strong>Resource not found</strong></p> Sorry, the requested resource does not exist.<p>Check the URL and try again.</p><p><b>Resource:</b> foo GET</p> <hr noshade=\"noshade\"/> <p>Troubleshooting Suggestions</p> <ul> <li>The URL may be incorrect.</li> <li>The parameters passed to this resource may be incorrect.</li> <li>A resource that this resource relies on may be encountering an error.</li> </ul> <p>For more detailed information about the error, please refer to the error log. </p> <p>If the error persists please contact the site maintainer. Thank you for your patience. </p> \r\n```\r\nThat was ugly (escaped html) but the text was correct.\r\n\r\nPlone 5.2 on the other hand tries to render the `ExceptionView` and fails sind the app has no method `Language()`. \r\n\r\n```\r\nTraceback (innermost last):\r\n\r\n    Module ZServer.ZPublisher.Publish, line 261, in publish_module_standard\r\n    Module Products.PDBDebugMode.runcall, line 83, in pdb_publish\r\n    Module ZServer.ZPublisher.Publish, line 182, in publish\r\n    Module ZServer.ZPublisher.exceptionhook, line 117, in __call__\r\n    Module Products.CMFPlone.browser.exceptions, line 49, in __call__\r\n    Module Products.Five.browser.pagetemplatefile, line 125, in __call__\r\n    Module Products.Five.browser.pagetemplatefile, line 60, in __call__\r\n    Module zope.pagetemplate.pagetemplate, line 134, in pt_render\r\n    Module Products.PageTemplates.engine, line 85, in __call__\r\n    Module z3c.pt.pagetemplate, line 163, in render\r\n    Module chameleon.zpt.template, line 261, in render\r\n    Module chameleon.template, line 191, in render\r\n    Module chameleon.template, line 171, in render\r\n    Module 4195113b17720aee65cd4ca2a7e7ba2d.py, line 1095, in render\r\n    Module 9fafff3b78c7ea63dcd15308ddf75fb8.py, line 652, in render_master\r\n    Module Products.PageTemplates.expression, line 105, in __call__\r\n    Module plone.app.layout.globals.portal, line 80, in language\r\n\r\nAttributeError: 'RequestContainer' object has no attribute 'Language'\r\n\r\n - Expression: \"portal_state/language\"\r\n - Filename: ... one/Products/CMFPlone/browser/templates/main_template.pt\r\n - Location: (line 12: col 11)\r\n - Source: lang portal_state/language; \r\n\r\n ^^^^^^^^^^^^^^^^^^^^^\r\n\r\n - Arguments: \r\n    repeat: {...} (0) \r\n    template: <ViewPageTemplateFile - at 0x10da74950> \r\n    views: <ViewMapper - at 0x10e47d9d0> \r\n    modules: <_SecureModuleImporter - at 0x10867bed0> \r\n    args: <tuple - at 0x1066a0050> \r\n    here: <ImplicitAcquisitionWrapper at 0x10d34b960> \r\n    user: <SpecialUser - at 0x108457290> \r\n    nothing: <NoneType - at 0x1065eeeb8> \r\n    container: <ImplicitAcquisitionWrapper at 0x10d34b960> \r\n    request: <HTTPRequest - at 0x10e5f1c90> \r\n    wrapped_repeat: <SafeMapping - at 0x10c50a5f0> \r\n    traverse_subpath: <list - at 0x10e88d488> \r\n    default: <object - at 0x1066f6ba0> \r\n    loop: {...} (0) context: <ImplicitAcquisitionWrapper at 0x10d34b960> \r\n    view: <SimpleViewClass from /Users/pbauer/workspace/coredev/src/Products.CMFPlone/Products/CMFPlone/browser/templates/error_message.pt index.html at 0x10c45f9d0> \r\n    translate: <function translate at 0x10e59f050> \r\n    root: <ImplicitAcquisitionWrapper at 0x10d34b960> \r\n    options: {...} (2) \r\n    target_language: <NoneType - at 0x1065eeeb8>\r\n```\n", "before_files": [{"content": "from AccessControl import getSecurityManager\nfrom Products.Five import BrowserView\nfrom Products.Five.browser.pagetemplatefile import ViewPageTemplateFile\nfrom zExceptions.ExceptionFormatter import format_exception\nimport json\nimport sys\n\n\nclass ExceptionView(BrowserView):\n    basic_template = ViewPageTemplateFile('templates/basic_error_message.pt')\n\n    def is_manager(self):\n        return getSecurityManager().checkPermission(\n            'Manage portal', self.context)\n\n    def __call__(self):\n        exception = self.context\n        self.context = self.__parent__\n        request = self.request\n\n        error_type = exception.__class__.__name__\n        exc_type, value, traceback = sys.exc_info()\n        error_tb = ''.join(\n            format_exception(exc_type, value, traceback, as_html=True))\n        request.response.setStatus(exc_type)\n\n        # Indicate exception as JSON\n        if \"text/html\" not in request.getHeader('Accept', ''):\n            request.response.setHeader(\"Content-Type\", \"application/json\")\n            return json.dumps({\n                'error_type': error_type,\n            })\n\n        # Use a simplified template if main_template is not available\n        try:\n            self.context.unrestrictedTraverse('main_template')\n        except:\n            template = self.basic_template\n        else:\n            template = self.index\n\n        # Render page with user-facing error notice\n        request.set('disable_border', True)\n        request.set('disable_plone.leftcolumn', True)\n        request.set('disable_plone.rightcolumn', True)\n\n        return template(\n            error_type=error_type,\n            error_tb=error_tb,\n        )\n", "path": "Products/CMFPlone/browser/exceptions.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nfrom AccessControl import getSecurityManager\nfrom Products.Five import BrowserView\nfrom Products.Five.browser.pagetemplatefile import ViewPageTemplateFile\nfrom zExceptions.ExceptionFormatter import format_exception\nfrom zope.component.hooks import getSite\n\nimport json\nimport sys\n\n\nclass ExceptionView(BrowserView):\n    basic_template = ViewPageTemplateFile('templates/basic_error_message.pt')\n\n    def is_manager(self):\n        return getSecurityManager().checkPermission(\n            'Manage portal', self.context)\n\n    def __call__(self):\n        exception = self.context\n        self.context = self.__parent__\n        request = self.request\n\n        error_type = exception.__class__.__name__\n        exc_type, value, traceback = sys.exc_info()\n        error_tb = ''.join(\n            format_exception(exc_type, value, traceback, as_html=True))\n        request.response.setStatus(exc_type)\n\n        # Indicate exception as JSON\n        if \"text/html\" not in request.getHeader('Accept', ''):\n            request.response.setHeader(\"Content-Type\", \"application/json\")\n            return json.dumps({\n                'error_type': error_type,\n            })\n\n        if getSite() is None:\n            # We cannot get the site, so we cannot render our nice template\n            template = self.basic_template\n        else:\n            # Use a simplified template if main_template is not available\n            try:\n                self.context.unrestrictedTraverse('main_template')\n            except:\n                template = self.basic_template\n            else:\n                template = self.index\n\n        # Render page with user-facing error notice\n        request.set('disable_border', True)\n        request.set('disable_plone.leftcolumn', True)\n        request.set('disable_plone.rightcolumn', True)\n\n        return template(\n            error_type=error_type,\n            error_tb=error_tb,\n        )\n", "path": "Products/CMFPlone/browser/exceptions.py"}]}