prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  UTF-8 Check fails on windows in Powershell
  ### Description
  The current version of sopel in pip (py3.9.6) and from git master both prompt this message upon running sopel even with a utf8 configuration:
  
  > WARNING!!! You are running with a non-UTF8 locale environment variable (e.g. LC_ALL is set to "C"), which makes Python 3 do stupid things. If you get strange errors, please set it to something like "en_US.UTF-8".
  
  Despite having a "English_United States", "utf8" locale from python.
  
  ### Reproduction steps
  Pull into a fresh python dev environment on windows 10.
  Install sopel via pip or from source.
  Run sopel.
  
  ### Expected behavior
  To not get a warning about UTF-8 since it's configured.
  
  ### Logs
  ```
  (.venv) PS C:\Users\Michael\Documents\Visual Studio Projects\Python\sopel> $PSVersionTable     
  
  Name                           Value
  ----                           -----
  PSVersion                      7.1.4
  PSEdition                      Core
  GitCommitId                    7.1.4
  OS                             Microsoft Windows 10.0.19041
  Platform                       Win32NT
  PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
  PSRemotingProtocolVersion      2.3
  SerializationVersion           1.1.0.1
  WSManStackVersion              3.0
  
  (.venv) PS C:\Users\Michael\Documents\Visual Studio Projects\Python\sopel> Get-WinSystemLocale 
  
  LCID             Name             DisplayName
  ----             ----             -----------
  1033             en-US            English (United States)
  
  (.venv) PS C:\Users\Michael\Documents\Visual Studio Projects\Python\sopel> echo $OutputEncoding
  
  Preamble          :      
  BodyName          : utf-8
  EncodingName      : Unicode (UTF-8)
  HeaderName        : utf-8
  WebName           : utf-8
  WindowsCodePage   : 1200
  IsBrowserDisplay  : True
  IsBrowserSave     : True
  IsMailNewsDisplay : True
  IsMailNewsSave    : True
  IsSingleByte      : False
  EncoderFallback   : System.Text.EncoderReplacementFallback
  DecoderFallback   : System.Text.DecoderReplacementFallback
  IsReadOnly        : True
  CodePage          : 65001
  
  
  (.venv) PS C:\Users\Michael\Documents\Visual Studio Projects\Python\sopel> py
  Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import locale
  >>> locale.getlocale()
  ('English_United States', 'utf8')
  >>> exit()
  ```
  
  ### Environment
  - Sopel `.version`: 8.0.0
  - Sopel installed via: pip && source
  - Python version: 3.9.6
  - Operating system: Windows 10
  - IRCd `/version`: N/A
  - Relevant plugins: N/A
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sopel/__init__.py`
  Content:
  ```
  1 # ASCII ONLY IN THIS FILE THOUGH!!!!!!!
  2 # Python does some stupid bullshit of respecting LC_ALL over the encoding on the
  3 # file, so in order to undo Python's ridiculous fucking idiocy, we have to have
  4 # our own check.
  5 
  6 # Copyright 2008, Sean B. Palmer, inamidst.com
  7 # Copyright 2012, Elsie Powell, http://embolalia.com
  8 # Copyright 2012, Elad Alfassa <elad@fedoraproject.org>
  9 #
  10 # Licensed under the Eiffel Forum License 2.
  11 
  12 from __future__ import generator_stop
  13 
  14 from collections import namedtuple
  15 import locale
  16 import re
  17 import sys
  18 
  19 import pkg_resources
  20 
  21 __all__ = [
  22     'bot',
  23     'config',
  24     'db',
  25     'formatting',
  26     'irc',
  27     'loader',
  28     'logger',
  29     'module',  # deprecated in 7.1, removed in 9.0
  30     'plugin',
  31     'tools',
  32     'trigger',
  33     'version_info',
  34 ]
  35 
  36 loc = locale.getlocale()
  37 if not loc[1] or 'UTF-8' not in loc[1]:
  38     print('WARNING!!! You are running with a non-UTF8 locale environment '
  39           'variable (e.g. LC_ALL is set to "C"), which makes Python 3 do '
  40           'stupid things. If you get strange errors, please set it to '
  41           'something like "en_US.UTF-8".', file=sys.stderr)
  42 
  43 
  44 __version__ = pkg_resources.get_distribution('sopel').version
  45 
  46 
  47 def _version_info(version=__version__):
  48     regex = re.compile(r'(\d+)\.(\d+)\.(\d+)(?:[\-\.]?(a|b|rc)(\d+))?.*')
  49     version_groups = regex.match(version).groups()
  50     major, minor, micro = (int(piece) for piece in version_groups[0:3])
  51     level = version_groups[3]
  52     serial = int(version_groups[4] or 0)
  53     if level == 'a':
  54         level = 'alpha'
  55     elif level == 'b':
  56         level = 'beta'
  57     elif level == 'rc':
  58         level = 'candidate'
  59     elif not level and version_groups[4] is None:
  60         level = 'final'
  61     else:
  62         level = 'alpha'
  63     version_type = namedtuple('version_info',
  64                               'major, minor, micro, releaselevel, serial')
  65     return version_type(major, minor, micro, level, serial)
  66 
  67 
  68 version_info = _version_info()
  69
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/sopel/__init__.py b/sopel/__init__.py
  --- a/sopel/__init__.py
  +++ b/sopel/__init__.py
  @@ -34,7 +34,7 @@
   ]
   
   loc = locale.getlocale()
  -if not loc[1] or 'UTF-8' not in loc[1]:
  +if not loc[1] or ('UTF-8' not in loc[1] and 'utf8' not in loc[1]):
       print('WARNING!!! You are running with a non-UTF8 locale environment '
             'variable (e.g. LC_ALL is set to "C"), which makes Python 3 do '
             'stupid things. If you get strange errors, please set it to '
  
verification_info: {"golden_diff": "diff --git a/sopel/__init__.py b/sopel/__init__.py\n--- a/sopel/__init__.py\n+++ b/sopel/__init__.py\n@@ -34,7 +34,7 @@\n ]\n \n loc = locale.getlocale()\n-if not loc[1] or 'UTF-8' not in loc[1]:\n+if not loc[1] or ('UTF-8' not in loc[1] and 'utf8' not in loc[1]):\n     print('WARNING!!! You are running with a non-UTF8 locale environment '\n           'variable (e.g. LC_ALL is set to \"C\"), which makes Python 3 do '\n           'stupid things. If you get strange errors, please set it to '\n", "issue": "UTF-8 Check fails on windows in Powershell\n### Description\r\nThe current version of sopel in pip (py3.9.6) and from git master both prompt this message upon running sopel even with a utf8 configuration:\r\n\r\n> WARNING!!! You are running with a non-UTF8 locale environment variable (e.g. LC_ALL is set to \"C\"), which makes Python 3 do stupid things. If you get strange errors, please set it to something like \"en_US.UTF-8\".\r\n\r\nDespite having a \"English_United States\", \"utf8\" locale from python.\r\n\r\n### Reproduction steps\r\nPull into a fresh python dev environment on windows 10.\r\nInstall sopel via pip or from source.\r\nRun sopel.\r\n\r\n### Expected behavior\r\nTo not get a warning about UTF-8 since it's configured.\r\n\r\n### Logs\r\n```\r\n(.venv) PS C:\\Users\\Michael\\Documents\\Visual Studio Projects\\Python\\sopel> $PSVersionTable     \r\n\r\nName                           Value\r\n----                           -----\r\nPSVersion                      7.1.4\r\nPSEdition                      Core\r\nGitCommitId                    7.1.4\r\nOS                             Microsoft Windows 10.0.19041\r\nPlatform                       Win32NT\r\nPSCompatibleVersions           {1.0, 2.0, 3.0, 4.0\u2026}\r\nPSRemotingProtocolVersion      2.3\r\nSerializationVersion           1.1.0.1\r\nWSManStackVersion              3.0\r\n\r\n(.venv) PS C:\\Users\\Michael\\Documents\\Visual Studio Projects\\Python\\sopel> Get-WinSystemLocale \r\n\r\nLCID             Name             DisplayName\r\n----             ----             -----------\r\n1033             en-US            English (United States)\r\n\r\n(.venv) PS C:\\Users\\Michael\\Documents\\Visual Studio Projects\\Python\\sopel> echo $OutputEncoding\r\n\r\nPreamble          :      \r\nBodyName          : utf-8\r\nEncodingName      : Unicode (UTF-8)\r\nHeaderName        : utf-8\r\nWebName           : utf-8\r\nWindowsCodePage   : 1200\r\nIsBrowserDisplay  : True\r\nIsBrowserSave     : True\r\nIsMailNewsDisplay : True\r\nIsMailNewsSave    : True\r\nIsSingleByte      : False\r\nEncoderFallback   : System.Text.EncoderReplacementFallback\r\nDecoderFallback   : System.Text.DecoderReplacementFallback\r\nIsReadOnly        : True\r\nCodePage          : 65001\r\n\r\n\r\n(.venv) PS C:\\Users\\Michael\\Documents\\Visual Studio Projects\\Python\\sopel> py\r\nPython 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import locale\r\n>>> locale.getlocale()\r\n('English_United States', 'utf8')\r\n>>> exit()\r\n```\r\n\r\n### Environment\r\n- Sopel `.version`: 8.0.0\r\n- Sopel installed via: pip && source\r\n- Python version: 3.9.6\r\n- Operating system: Windows 10\r\n- IRCd `/version`: N/A\r\n- Relevant plugins: N/A\r\n\n", "before_files": [{"content": "# ASCII ONLY IN THIS FILE THOUGH!!!!!!!\n# Python does some stupid bullshit of respecting LC_ALL over the encoding on the\n# file, so in order to undo Python's ridiculous fucking idiocy, we have to have\n# our own check.\n\n# Copyright 2008, Sean B. Palmer, inamidst.com\n# Copyright 2012, Elsie Powell, http://embolalia.com\n# Copyright 2012, Elad Alfassa <elad@fedoraproject.org>\n#\n# Licensed under the Eiffel Forum License 2.\n\nfrom __future__ import generator_stop\n\nfrom collections import namedtuple\nimport locale\nimport re\nimport sys\n\nimport pkg_resources\n\n__all__ = [\n    'bot',\n    'config',\n    'db',\n    'formatting',\n    'irc',\n    'loader',\n    'logger',\n    'module',  # deprecated in 7.1, removed in 9.0\n    'plugin',\n    'tools',\n    'trigger',\n    'version_info',\n]\n\nloc = locale.getlocale()\nif not loc[1] or 'UTF-8' not in loc[1]:\n    print('WARNING!!! You are running with a non-UTF8 locale environment '\n          'variable (e.g. LC_ALL is set to \"C\"), which makes Python 3 do '\n          'stupid things. If you get strange errors, please set it to '\n          'something like \"en_US.UTF-8\".', file=sys.stderr)\n\n\n__version__ = pkg_resources.get_distribution('sopel').version\n\n\ndef _version_info(version=__version__):\n    regex = re.compile(r'(\\d+)\\.(\\d+)\\.(\\d+)(?:[\\-\\.]?(a|b|rc)(\\d+))?.*')\n    version_groups = regex.match(version).groups()\n    major, minor, micro = (int(piece) for piece in version_groups[0:3])\n    level = version_groups[3]\n    serial = int(version_groups[4] or 0)\n    if level == 'a':\n        level = 'alpha'\n    elif level == 'b':\n        level = 'beta'\n    elif level == 'rc':\n        level = 'candidate'\n    elif not level and version_groups[4] is None:\n        level = 'final'\n    else:\n        level = 'alpha'\n    version_type = namedtuple('version_info',\n                              'major, minor, micro, releaselevel, serial')\n    return version_type(major, minor, micro, level, serial)\n\n\nversion_info = _version_info()\n", "path": "sopel/__init__.py"}], "after_files": [{"content": "# ASCII ONLY IN THIS FILE THOUGH!!!!!!!\n# Python does some stupid bullshit of respecting LC_ALL over the encoding on the\n# file, so in order to undo Python's ridiculous fucking idiocy, we have to have\n# our own check.\n\n# Copyright 2008, Sean B. Palmer, inamidst.com\n# Copyright 2012, Elsie Powell, http://embolalia.com\n# Copyright 2012, Elad Alfassa <elad@fedoraproject.org>\n#\n# Licensed under the Eiffel Forum License 2.\n\nfrom __future__ import generator_stop\n\nfrom collections import namedtuple\nimport locale\nimport re\nimport sys\n\nimport pkg_resources\n\n__all__ = [\n    'bot',\n    'config',\n    'db',\n    'formatting',\n    'irc',\n    'loader',\n    'logger',\n    'module',  # deprecated in 7.1, removed in 9.0\n    'plugin',\n    'tools',\n    'trigger',\n    'version_info',\n]\n\nloc = locale.getlocale()\nif not loc[1] or ('UTF-8' not in loc[1] and 'utf8' not in loc[1]):\n    print('WARNING!!! You are running with a non-UTF8 locale environment '\n          'variable (e.g. LC_ALL is set to \"C\"), which makes Python 3 do '\n          'stupid things. If you get strange errors, please set it to '\n          'something like \"en_US.UTF-8\".', file=sys.stderr)\n\n\n__version__ = pkg_resources.get_distribution('sopel').version\n\n\ndef _version_info(version=__version__):\n    regex = re.compile(r'(\\d+)\\.(\\d+)\\.(\\d+)(?:[\\-\\.]?(a|b|rc)(\\d+))?.*')\n    version_groups = regex.match(version).groups()\n    major, minor, micro = (int(piece) for piece in version_groups[0:3])\n    level = version_groups[3]\n    serial = int(version_groups[4] or 0)\n    if level == 'a':\n        level = 'alpha'\n    elif level == 'b':\n        level = 'beta'\n    elif level == 'rc':\n        level = 'candidate'\n    elif not level and version_groups[4] is None:\n        level = 'final'\n    else:\n        level = 'alpha'\n    version_type = namedtuple('version_info',\n                              'major, minor, micro, releaselevel, serial')\n    return version_type(major, minor, micro, level, serial)\n\n\nversion_info = _version_info()\n", "path": "sopel/__init__.py"}]}