We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`cookiecutter --version` prints out the wrong Python version on 3.10
``` console
$ cookiecutter --version
Cookiecutter 1.7.3 from /usr/lib/python3.10/site-packages (Python 3.1)
```

It should end with `(Python 3.10)` not `(Python 3.1)`. This seems to be the problematic code:

https://github.com/cookiecutter/cookiecutter/blob/f821895a0cb536a907ac2937471d7d4ac36fec75/cookiecutter/cli.py#L26-L31

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `cookiecutter/cli.py`
Content:
```
1 """Main `cookiecutter` CLI."""
2 import collections
3 import json
4 import os
5 import sys
6 
7 import click
8 
9 from cookiecutter import __version__
10 from cookiecutter.exceptions import (
11     ContextDecodingException,
12     FailedHookException,
13     InvalidModeException,
14     InvalidZipRepository,
15     OutputDirExistsException,
16     RepositoryCloneFailed,
17     RepositoryNotFound,
18     UndefinedVariableInTemplate,
19     UnknownExtension,
20 )
21 from cookiecutter.log import configure_logger
22 from cookiecutter.main import cookiecutter
23 from cookiecutter.config import get_user_config
24 
25 
26 def version_msg():
27     """Return the Cookiecutter version, location and Python powering it."""
28     python_version = sys.version[:3]
29     location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
30     message = 'Cookiecutter %(version)s from {} (Python {})'
31     return message.format(location, python_version)
32 
33 
34 def validate_extra_context(ctx, param, value):
35     """Validate extra context."""
36     for s in value:
37         if '=' not in s:
38             raise click.BadParameter(
39                 'EXTRA_CONTEXT should contain items of the form key=value; '
40                 "'{}' doesn't match that form".format(s)
41             )
42 
43     # Convert tuple -- e.g.: ('program_name=foobar', 'startsecs=66')
44     # to dict -- e.g.: {'program_name': 'foobar', 'startsecs': '66'}
45     return collections.OrderedDict(s.split('=', 1) for s in value) or None
46 
47 
48 def list_installed_templates(default_config, passed_config_file):
49     """List installed (locally cloned) templates. Use cookiecutter --list-installed."""
50     config = get_user_config(passed_config_file, default_config)
51     cookiecutter_folder = config.get('cookiecutters_dir')
52     if not os.path.exists(cookiecutter_folder):
53         click.echo(
54             'Error: Cannot list installed templates. Folder does not exist: '
55             '{}'.format(cookiecutter_folder)
56         )
57         sys.exit(-1)
58 
59     template_names = [
60         folder
61         for folder in os.listdir(cookiecutter_folder)
62         if os.path.exists(
63             os.path.join(cookiecutter_folder, folder, 'cookiecutter.json')
64         )
65     ]
66     click.echo('{} installed templates: '.format(len(template_names)))
67     for name in template_names:
68         click.echo(' * {}'.format(name))
69 
70 
71 @click.command(context_settings=dict(help_option_names=['-h', '--help']))
72 @click.version_option(__version__, '-V', '--version', message=version_msg())
73 @click.argument('template', required=False)
74 @click.argument('extra_context', nargs=-1, callback=validate_extra_context)
75 @click.option(
76     '--no-input',
77     is_flag=True,
78     help='Do not prompt for parameters and only use cookiecutter.json file content',
79 )
80 @click.option(
81     '-c',
82     '--checkout',
83     help='branch, tag or commit to checkout after git clone',
84 )
85 @click.option(
86     '--directory',
87     help='Directory within repo that holds cookiecutter.json file '
88     'for advanced repositories with multi templates in it',
89 )
90 @click.option(
91     '-v', '--verbose', is_flag=True, help='Print debug information', default=False
92 )
93 @click.option(
94     '--replay',
95     is_flag=True,
96     help='Do not prompt for parameters and only use information entered previously',
97 )
98 @click.option(
99     '--replay-file',
100     type=click.Path(),
101     default=None,
102     help='Use this file for replay instead of the default.',
103 )
104 @click.option(
105     '-f',
106     '--overwrite-if-exists',
107     is_flag=True,
108     help='Overwrite the contents of the output directory if it already exists',
109 )
110 @click.option(
111     '-s',
112     '--skip-if-file-exists',
113     is_flag=True,
114     help='Skip the files in the corresponding directories if they already exist',
115     default=False,
116 )
117 @click.option(
118     '-o',
119     '--output-dir',
120     default='.',
121     type=click.Path(),
122     help='Where to output the generated project dir into',
123 )
124 @click.option(
125     '--config-file', type=click.Path(), default=None, help='User configuration file'
126 )
127 @click.option(
128     '--default-config',
129     is_flag=True,
130     help='Do not load a config file. Use the defaults instead',
131 )
132 @click.option(
133     '--debug-file',
134     type=click.Path(),
135     default=None,
136     help='File to be used as a stream for DEBUG logging',
137 )
138 @click.option(
139     '--accept-hooks',
140     type=click.Choice(['yes', 'ask', 'no']),
141     default='yes',
142     help='Accept pre/post hooks',
143 )
144 @click.option(
145     '-l', '--list-installed', is_flag=True, help='List currently installed templates.'
146 )
147 def main(
148     template,
149     extra_context,
150     no_input,
151     checkout,
152     verbose,
153     replay,
154     overwrite_if_exists,
155     output_dir,
156     config_file,
157     default_config,
158     debug_file,
159     directory,
160     skip_if_file_exists,
161     accept_hooks,
162     replay_file,
163     list_installed,
164 ):
165     """Create a project from a Cookiecutter project template (TEMPLATE).
166 
167     Cookiecutter is free and open source software, developed and managed by
168     volunteers. If you would like to help out or fund the project, please get
169     in touch at https://github.com/cookiecutter/cookiecutter.
170     """
171     # Commands that should work without arguments
172     if list_installed:
173         list_installed_templates(default_config, config_file)
174         sys.exit(0)
175 
176     # Raising usage, after all commands that should work without args.
177     if not template or template.lower() == 'help':
178         click.echo(click.get_current_context().get_help())
179         sys.exit(0)
180 
181     configure_logger(stream_level='DEBUG' if verbose else 'INFO', debug_file=debug_file)
182 
183     # If needed, prompt the user to ask whether or not they want to execute
184     # the pre/post hooks.
185     if accept_hooks == "ask":
186         _accept_hooks = click.confirm("Do you want to execute hooks?")
187     else:
188         _accept_hooks = accept_hooks == "yes"
189 
190     if replay_file:
191         replay = replay_file
192 
193     try:
194         cookiecutter(
195             template,
196             checkout,
197             no_input,
198             extra_context=extra_context,
199             replay=replay,
200             overwrite_if_exists=overwrite_if_exists,
201             output_dir=output_dir,
202             config_file=config_file,
203             default_config=default_config,
204             password=os.environ.get('COOKIECUTTER_REPO_PASSWORD'),
205             directory=directory,
206             skip_if_file_exists=skip_if_file_exists,
207             accept_hooks=_accept_hooks,
208         )
209     except (
210         ContextDecodingException,
211         OutputDirExistsException,
212         InvalidModeException,
213         FailedHookException,
214         UnknownExtension,
215         InvalidZipRepository,
216         RepositoryNotFound,
217         RepositoryCloneFailed,
218     ) as e:
219         click.echo(e)
220         sys.exit(1)
221     except UndefinedVariableInTemplate as undefined_err:
222         click.echo('{}'.format(undefined_err.message))
223         click.echo('Error message: {}'.format(undefined_err.error.message))
224 
225         context_str = json.dumps(undefined_err.context, indent=4, sort_keys=True)
226         click.echo('Context: {}'.format(context_str))
227         sys.exit(1)
228 
229 
230 if __name__ == "__main__":
231     main()
232
```
--- 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/cookiecutter/cli.py b/cookiecutter/cli.py
--- a/cookiecutter/cli.py
+++ b/cookiecutter/cli.py
@@ -25,7 +25,7 @@
 
 def version_msg():
     """Return the Cookiecutter version, location and Python powering it."""
-    python_version = sys.version[:3]
+    python_version = sys.version
     location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
     message = 'Cookiecutter %(version)s from {} (Python {})'
     return message.format(location, python_version)

{"golden_diff": "diff --git a/cookiecutter/cli.py b/cookiecutter/cli.py\n--- a/cookiecutter/cli.py\n+++ b/cookiecutter/cli.py\n@@ -25,7 +25,7 @@\n \n def version_msg():\n     \"\"\"Return the Cookiecutter version, location and Python powering it.\"\"\"\n-    python_version = sys.version[:3]\n+    python_version = sys.version\n     location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n     message = 'Cookiecutter %(version)s from {} (Python {})'\n     return message.format(location, python_version)\n", "issue": "`cookiecutter --version` prints out the wrong Python version on 3.10\n``` console\r\n$ cookiecutter --version\r\nCookiecutter 1.7.3 from /usr/lib/python3.10/site-packages (Python 3.1)\r\n```\r\n\r\nIt should end with `(Python 3.10)` not `(Python 3.1)`. This seems to be the problematic code:\r\n\r\nhttps://github.com/cookiecutter/cookiecutter/blob/f821895a0cb536a907ac2937471d7d4ac36fec75/cookiecutter/cli.py#L26-L31\n", "before_files": [{"content": "\"\"\"Main `cookiecutter` CLI.\"\"\"\nimport collections\nimport json\nimport os\nimport sys\n\nimport click\n\nfrom cookiecutter import __version__\nfrom cookiecutter.exceptions import (\n    ContextDecodingException,\n    FailedHookException,\n    InvalidModeException,\n    InvalidZipRepository,\n    OutputDirExistsException,\n    RepositoryCloneFailed,\n    RepositoryNotFound,\n    UndefinedVariableInTemplate,\n    UnknownExtension,\n)\nfrom cookiecutter.log import configure_logger\nfrom cookiecutter.main import cookiecutter\nfrom cookiecutter.config import get_user_config\n\n\ndef version_msg():\n    \"\"\"Return the Cookiecutter version, location and Python powering it.\"\"\"\n    python_version = sys.version[:3]\n    location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n    message = 'Cookiecutter %(version)s from {} (Python {})'\n    return message.format(location, python_version)\n\n\ndef validate_extra_context(ctx, param, value):\n    \"\"\"Validate extra context.\"\"\"\n    for s in value:\n        if '=' not in s:\n            raise click.BadParameter(\n                'EXTRA_CONTEXT should contain items of the form key=value; '\n                \"'{}' doesn't match that form\".format(s)\n            )\n\n    # Convert tuple -- e.g.: ('program_name=foobar', 'startsecs=66')\n    # to dict -- e.g.: {'program_name': 'foobar', 'startsecs': '66'}\n    return collections.OrderedDict(s.split('=', 1) for s in value) or None\n\n\ndef list_installed_templates(default_config, passed_config_file):\n    \"\"\"List installed (locally cloned) templates. Use cookiecutter --list-installed.\"\"\"\n    config = get_user_config(passed_config_file, default_config)\n    cookiecutter_folder = config.get('cookiecutters_dir')\n    if not os.path.exists(cookiecutter_folder):\n        click.echo(\n            'Error: Cannot list installed templates. Folder does not exist: '\n            '{}'.format(cookiecutter_folder)\n        )\n        sys.exit(-1)\n\n    template_names = [\n        folder\n        for folder in os.listdir(cookiecutter_folder)\n        if os.path.exists(\n            os.path.join(cookiecutter_folder, folder, 'cookiecutter.json')\n        )\n    ]\n    click.echo('{} installed templates: '.format(len(template_names)))\n    for name in template_names:\n        click.echo(' * {}'.format(name))\n\n\n@click.command(context_settings=dict(help_option_names=['-h', '--help']))\n@click.version_option(__version__, '-V', '--version', message=version_msg())\n@click.argument('template', required=False)\n@click.argument('extra_context', nargs=-1, callback=validate_extra_context)\n@click.option(\n    '--no-input',\n    is_flag=True,\n    help='Do not prompt for parameters and only use cookiecutter.json file content',\n)\n@click.option(\n    '-c',\n    '--checkout',\n    help='branch, tag or commit to checkout after git clone',\n)\n@click.option(\n    '--directory',\n    help='Directory within repo that holds cookiecutter.json file '\n    'for advanced repositories with multi templates in it',\n)\n@click.option(\n    '-v', '--verbose', is_flag=True, help='Print debug information', default=False\n)\n@click.option(\n    '--replay',\n    is_flag=True,\n    help='Do not prompt for parameters and only use information entered previously',\n)\n@click.option(\n    '--replay-file',\n    type=click.Path(),\n    default=None,\n    help='Use this file for replay instead of the default.',\n)\n@click.option(\n    '-f',\n    '--overwrite-if-exists',\n    is_flag=True,\n    help='Overwrite the contents of the output directory if it already exists',\n)\n@click.option(\n    '-s',\n    '--skip-if-file-exists',\n    is_flag=True,\n    help='Skip the files in the corresponding directories if they already exist',\n    default=False,\n)\n@click.option(\n    '-o',\n    '--output-dir',\n    default='.',\n    type=click.Path(),\n    help='Where to output the generated project dir into',\n)\n@click.option(\n    '--config-file', type=click.Path(), default=None, help='User configuration file'\n)\n@click.option(\n    '--default-config',\n    is_flag=True,\n    help='Do not load a config file. Use the defaults instead',\n)\n@click.option(\n    '--debug-file',\n    type=click.Path(),\n    default=None,\n    help='File to be used as a stream for DEBUG logging',\n)\n@click.option(\n    '--accept-hooks',\n    type=click.Choice(['yes', 'ask', 'no']),\n    default='yes',\n    help='Accept pre/post hooks',\n)\n@click.option(\n    '-l', '--list-installed', is_flag=True, help='List currently installed templates.'\n)\ndef main(\n    template,\n    extra_context,\n    no_input,\n    checkout,\n    verbose,\n    replay,\n    overwrite_if_exists,\n    output_dir,\n    config_file,\n    default_config,\n    debug_file,\n    directory,\n    skip_if_file_exists,\n    accept_hooks,\n    replay_file,\n    list_installed,\n):\n    \"\"\"Create a project from a Cookiecutter project template (TEMPLATE).\n\n    Cookiecutter is free and open source software, developed and managed by\n    volunteers. If you would like to help out or fund the project, please get\n    in touch at https://github.com/cookiecutter/cookiecutter.\n    \"\"\"\n    # Commands that should work without arguments\n    if list_installed:\n        list_installed_templates(default_config, config_file)\n        sys.exit(0)\n\n    # Raising usage, after all commands that should work without args.\n    if not template or template.lower() == 'help':\n        click.echo(click.get_current_context().get_help())\n        sys.exit(0)\n\n    configure_logger(stream_level='DEBUG' if verbose else 'INFO', debug_file=debug_file)\n\n    # If needed, prompt the user to ask whether or not they want to execute\n    # the pre/post hooks.\n    if accept_hooks == \"ask\":\n        _accept_hooks = click.confirm(\"Do you want to execute hooks?\")\n    else:\n        _accept_hooks = accept_hooks == \"yes\"\n\n    if replay_file:\n        replay = replay_file\n\n    try:\n        cookiecutter(\n            template,\n            checkout,\n            no_input,\n            extra_context=extra_context,\n            replay=replay,\n            overwrite_if_exists=overwrite_if_exists,\n            output_dir=output_dir,\n            config_file=config_file,\n            default_config=default_config,\n            password=os.environ.get('COOKIECUTTER_REPO_PASSWORD'),\n            directory=directory,\n            skip_if_file_exists=skip_if_file_exists,\n            accept_hooks=_accept_hooks,\n        )\n    except (\n        ContextDecodingException,\n        OutputDirExistsException,\n        InvalidModeException,\n        FailedHookException,\n        UnknownExtension,\n        InvalidZipRepository,\n        RepositoryNotFound,\n        RepositoryCloneFailed,\n    ) as e:\n        click.echo(e)\n        sys.exit(1)\n    except UndefinedVariableInTemplate as undefined_err:\n        click.echo('{}'.format(undefined_err.message))\n        click.echo('Error message: {}'.format(undefined_err.error.message))\n\n        context_str = json.dumps(undefined_err.context, indent=4, sort_keys=True)\n        click.echo('Context: {}'.format(context_str))\n        sys.exit(1)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "cookiecutter/cli.py"}], "after_files": [{"content": "\"\"\"Main `cookiecutter` CLI.\"\"\"\nimport collections\nimport json\nimport os\nimport sys\n\nimport click\n\nfrom cookiecutter import __version__\nfrom cookiecutter.exceptions import (\n    ContextDecodingException,\n    FailedHookException,\n    InvalidModeException,\n    InvalidZipRepository,\n    OutputDirExistsException,\n    RepositoryCloneFailed,\n    RepositoryNotFound,\n    UndefinedVariableInTemplate,\n    UnknownExtension,\n)\nfrom cookiecutter.log import configure_logger\nfrom cookiecutter.main import cookiecutter\nfrom cookiecutter.config import get_user_config\n\n\ndef version_msg():\n    \"\"\"Return the Cookiecutter version, location and Python powering it.\"\"\"\n    python_version = sys.version\n    location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n    message = 'Cookiecutter %(version)s from {} (Python {})'\n    return message.format(location, python_version)\n\n\ndef validate_extra_context(ctx, param, value):\n    \"\"\"Validate extra context.\"\"\"\n    for s in value:\n        if '=' not in s:\n            raise click.BadParameter(\n                'EXTRA_CONTEXT should contain items of the form key=value; '\n                \"'{}' doesn't match that form\".format(s)\n            )\n\n    # Convert tuple -- e.g.: ('program_name=foobar', 'startsecs=66')\n    # to dict -- e.g.: {'program_name': 'foobar', 'startsecs': '66'}\n    return collections.OrderedDict(s.split('=', 1) for s in value) or None\n\n\ndef list_installed_templates(default_config, passed_config_file):\n    \"\"\"List installed (locally cloned) templates. Use cookiecutter --list-installed.\"\"\"\n    config = get_user_config(passed_config_file, default_config)\n    cookiecutter_folder = config.get('cookiecutters_dir')\n    if not os.path.exists(cookiecutter_folder):\n        click.echo(\n            'Error: Cannot list installed templates. Folder does not exist: '\n            '{}'.format(cookiecutter_folder)\n        )\n        sys.exit(-1)\n\n    template_names = [\n        folder\n        for folder in os.listdir(cookiecutter_folder)\n        if os.path.exists(\n            os.path.join(cookiecutter_folder, folder, 'cookiecutter.json')\n        )\n    ]\n    click.echo('{} installed templates: '.format(len(template_names)))\n    for name in template_names:\n        click.echo(' * {}'.format(name))\n\n\n@click.command(context_settings=dict(help_option_names=['-h', '--help']))\n@click.version_option(__version__, '-V', '--version', message=version_msg())\n@click.argument('template', required=False)\n@click.argument('extra_context', nargs=-1, callback=validate_extra_context)\n@click.option(\n    '--no-input',\n    is_flag=True,\n    help='Do not prompt for parameters and only use cookiecutter.json file content',\n)\n@click.option(\n    '-c',\n    '--checkout',\n    help='branch, tag or commit to checkout after git clone',\n)\n@click.option(\n    '--directory',\n    help='Directory within repo that holds cookiecutter.json file '\n    'for advanced repositories with multi templates in it',\n)\n@click.option(\n    '-v', '--verbose', is_flag=True, help='Print debug information', default=False\n)\n@click.option(\n    '--replay',\n    is_flag=True,\n    help='Do not prompt for parameters and only use information entered previously',\n)\n@click.option(\n    '--replay-file',\n    type=click.Path(),\n    default=None,\n    help='Use this file for replay instead of the default.',\n)\n@click.option(\n    '-f',\n    '--overwrite-if-exists',\n    is_flag=True,\n    help='Overwrite the contents of the output directory if it already exists',\n)\n@click.option(\n    '-s',\n    '--skip-if-file-exists',\n    is_flag=True,\n    help='Skip the files in the corresponding directories if they already exist',\n    default=False,\n)\n@click.option(\n    '-o',\n    '--output-dir',\n    default='.',\n    type=click.Path(),\n    help='Where to output the generated project dir into',\n)\n@click.option(\n    '--config-file', type=click.Path(), default=None, help='User configuration file'\n)\n@click.option(\n    '--default-config',\n    is_flag=True,\n    help='Do not load a config file. Use the defaults instead',\n)\n@click.option(\n    '--debug-file',\n    type=click.Path(),\n    default=None,\n    help='File to be used as a stream for DEBUG logging',\n)\n@click.option(\n    '--accept-hooks',\n    type=click.Choice(['yes', 'ask', 'no']),\n    default='yes',\n    help='Accept pre/post hooks',\n)\n@click.option(\n    '-l', '--list-installed', is_flag=True, help='List currently installed templates.'\n)\ndef main(\n    template,\n    extra_context,\n    no_input,\n    checkout,\n    verbose,\n    replay,\n    overwrite_if_exists,\n    output_dir,\n    config_file,\n    default_config,\n    debug_file,\n    directory,\n    skip_if_file_exists,\n    accept_hooks,\n    replay_file,\n    list_installed,\n):\n    \"\"\"Create a project from a Cookiecutter project template (TEMPLATE).\n\n    Cookiecutter is free and open source software, developed and managed by\n    volunteers. If you would like to help out or fund the project, please get\n    in touch at https://github.com/cookiecutter/cookiecutter.\n    \"\"\"\n    # Commands that should work without arguments\n    if list_installed:\n        list_installed_templates(default_config, config_file)\n        sys.exit(0)\n\n    # Raising usage, after all commands that should work without args.\n    if not template or template.lower() == 'help':\n        click.echo(click.get_current_context().get_help())\n        sys.exit(0)\n\n    configure_logger(stream_level='DEBUG' if verbose else 'INFO', debug_file=debug_file)\n\n    # If needed, prompt the user to ask whether or not they want to execute\n    # the pre/post hooks.\n    if accept_hooks == \"ask\":\n        _accept_hooks = click.confirm(\"Do you want to execute hooks?\")\n    else:\n        _accept_hooks = accept_hooks == \"yes\"\n\n    if replay_file:\n        replay = replay_file\n\n    try:\n        cookiecutter(\n            template,\n            checkout,\n            no_input,\n            extra_context=extra_context,\n            replay=replay,\n            overwrite_if_exists=overwrite_if_exists,\n            output_dir=output_dir,\n            config_file=config_file,\n            default_config=default_config,\n            password=os.environ.get('COOKIECUTTER_REPO_PASSWORD'),\n            directory=directory,\n            skip_if_file_exists=skip_if_file_exists,\n            accept_hooks=_accept_hooks,\n        )\n    except (\n        ContextDecodingException,\n        OutputDirExistsException,\n        InvalidModeException,\n        FailedHookException,\n        UnknownExtension,\n        InvalidZipRepository,\n        RepositoryNotFound,\n        RepositoryCloneFailed,\n    ) as e:\n        click.echo(e)\n        sys.exit(1)\n    except UndefinedVariableInTemplate as undefined_err:\n        click.echo('{}'.format(undefined_err.message))\n        click.echo('Error message: {}'.format(undefined_err.error.message))\n\n        context_str = json.dumps(undefined_err.context, indent=4, sort_keys=True)\n        click.echo('Context: {}'.format(context_str))\n        sys.exit(1)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "cookiecutter/cli.py"}]}