We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`poetry publish` fails on 1.2.0
<!-- Checked checkbox should look like this: [x] -->
- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version.
- [x] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.
- [x] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).

- **OS version and name**: macOS
- **Poetry version**: `1.2.0a1` and `1.2.0a2`
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**:
```
[tool.poetry]
name = "foo"
version = "0.1.0"
description = "foo"
authors = ["Martin Liu <martin.xs.liu@gmail.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.6.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
```

## Issue
Running `poetry publish` throws the following exception. This reproduces for both `1.2.0a1` and `1.2.0a2`.
```
  Stack trace:

  8  .venv/lib/python3.9/site-packages/cleo/application.py:330 in run
      328│
      329│             try:
    → 330│                 exit_code = self._run(io)
      331│             except Exception as e:
      332│                 if not self._catch_exceptions:

  7  .venv/lib/python3.9/site-packages/poetry/console/application.py:180 in _run
      178│         self._load_plugins(io)
      179│
    → 180│         return super()._run(io)
      181│
      182│     def _configure_io(self, io: IO) -> None:

  6  .venv/lib/python3.9/site-packages/cleo/application.py:425 in _run
      423│                 io.set_input(ArgvInput(argv))
      424│
    → 425│         exit_code = self._run_command(command, io)
      426│         self._running_command = None
      427│

  5  .venv/lib/python3.9/site-packages/cleo/application.py:467 in _run_command
      465│
      466│         if error is not None:
    → 467│             raise error
      468│
      469│         return event.exit_code

  4  .venv/lib/python3.9/site-packages/cleo/application.py:451 in _run_command
      449│
      450│             if event.command_should_run():
    → 451│                 exit_code = command.run(io)
      452│             else:
      453│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

  3  .venv/lib/python3.9/site-packages/cleo/commands/base_command.py:118 in run
      116│         io.input.validate()
      117│
    → 118│         status_code = self.execute(io)
      119│
      120│         if status_code is None:

  2  .venv/lib/python3.9/site-packages/cleo/commands/command.py:85 in execute
       83│
       84│         try:
    →  85│             return self.handle()
       86│         except KeyboardInterrupt:
       87│             return 1

  1  .venv/lib/python3.9/site-packages/poetry/console/commands/publish.py:78 in handle
       76│         )
       77│
    →  78│         publisher.publish(
       79│             self.option("repository"),
       80│             self.option("username"),

  AttributeError

  'IO' object has no attribute 'ask'

  at .venv/lib/python3.9/site-packages/poetry/publishing/publisher.py:82 in publish
       78│         )
       79│         # Requesting missing credentials but only if there is not a client cert defined.
       80│         if not resolved_client_cert:
       81│             if username is None:
    →  82│                 username = self._io.ask("Username:")
       83│
       84│             # skip password input if no username is provided, assume unauthenticated
       85│             if username and password is None:
       86│                 password = self._io.ask_hidden("Password:")
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/poetry/publishing/publisher.py`
Content:
```
1 from __future__ import annotations
2 
3 import logging
4 
5 from typing import TYPE_CHECKING
6 
7 from poetry.publishing.uploader import Uploader
8 from poetry.utils.authenticator import Authenticator
9 
10 
11 if TYPE_CHECKING:
12     from pathlib import Path
13 
14     from cleo.io import BufferedIO
15     from cleo.io import ConsoleIO
16 
17     from poetry.poetry import Poetry
18 
19 logger = logging.getLogger(__name__)
20 
21 
22 class Publisher:
23     """
24     Registers and publishes packages to remote repositories.
25     """
26 
27     def __init__(self, poetry: Poetry, io: BufferedIO | ConsoleIO) -> None:
28         self._poetry = poetry
29         self._package = poetry.package
30         self._io = io
31         self._uploader = Uploader(poetry, io)
32         self._authenticator = Authenticator(poetry.config, self._io)
33 
34     @property
35     def files(self) -> list[Path]:
36         return self._uploader.files
37 
38     def publish(
39         self,
40         repository_name: str | None,
41         username: str | None,
42         password: str | None,
43         cert: Path | None = None,
44         client_cert: Path | None = None,
45         dry_run: bool = False,
46         skip_existing: bool = False,
47     ) -> None:
48         if not repository_name:
49             url = "https://upload.pypi.org/legacy/"
50             repository_name = "pypi"
51         else:
52             # Retrieving config information
53             url = self._poetry.config.get(f"repositories.{repository_name}.url")
54             if url is None:
55                 raise RuntimeError(f"Repository {repository_name} is not defined")
56 
57         if not (username and password):
58             # Check if we have a token first
59             token = self._authenticator.get_pypi_token(repository_name)
60             if token:
61                 logger.debug(f"Found an API token for {repository_name}.")
62                 username = "__token__"
63                 password = token
64             else:
65                 auth = self._authenticator.get_http_auth(repository_name)
66                 if auth:
67                     logger.debug(
68                         f"Found authentication information for {repository_name}."
69                     )
70                     username = auth.username
71                     password = auth.password
72 
73         certificates = self._authenticator.get_certs_for_repository(repository_name)
74         resolved_cert = cert or certificates.cert or certificates.verify
75         resolved_client_cert = client_cert or certificates.client_cert
76 
77         # Requesting missing credentials but only if there is not a client cert defined.
78         if not resolved_client_cert and hasattr(self._io, "ask"):
79             if username is None:
80                 username = self._io.ask("Username:")
81 
82             # skip password input if no username is provided, assume unauthenticated
83             if username and password is None:
84                 password = self._io.ask_hidden("Password:")
85 
86         self._uploader.auth(username, password)
87 
88         if repository_name == "pypi":
89             repository_name = "PyPI"
90         self._io.write_line(
91             f"Publishing <c1>{self._package.pretty_name}</c1>"
92             f" (<c2>{self._package.pretty_version}</c2>) to"
93             f" <info>{repository_name}</info>"
94         )
95 
96         self._uploader.upload(
97             url,
98             cert=resolved_cert,
99             client_cert=resolved_client_cert,
100             dry_run=dry_run,
101             skip_existing=skip_existing,
102         )
103
```
--- 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/src/poetry/publishing/publisher.py b/src/poetry/publishing/publisher.py
--- a/src/poetry/publishing/publisher.py
+++ b/src/poetry/publishing/publisher.py
@@ -74,15 +74,6 @@
         resolved_cert = cert or certificates.cert or certificates.verify
         resolved_client_cert = client_cert or certificates.client_cert
 
-        # Requesting missing credentials but only if there is not a client cert defined.
-        if not resolved_client_cert and hasattr(self._io, "ask"):
-            if username is None:
-                username = self._io.ask("Username:")
-
-            # skip password input if no username is provided, assume unauthenticated
-            if username and password is None:
-                password = self._io.ask_hidden("Password:")
-
         self._uploader.auth(username, password)
 
         if repository_name == "pypi":

{"golden_diff": "diff --git a/src/poetry/publishing/publisher.py b/src/poetry/publishing/publisher.py\n--- a/src/poetry/publishing/publisher.py\n+++ b/src/poetry/publishing/publisher.py\n@@ -74,15 +74,6 @@\n         resolved_cert = cert or certificates.cert or certificates.verify\n         resolved_client_cert = client_cert or certificates.client_cert\n \n-        # Requesting missing credentials but only if there is not a client cert defined.\n-        if not resolved_client_cert and hasattr(self._io, \"ask\"):\n-            if username is None:\n-                username = self._io.ask(\"Username:\")\n-\n-            # skip password input if no username is provided, assume unauthenticated\n-            if username and password is None:\n-                password = self._io.ask_hidden(\"Password:\")\n-\n         self._uploader.auth(username, password)\n \n         if repository_name == \"pypi\":\n", "issue": "`poetry publish` fails on 1.2.0\n<!-- Checked checkbox should look like this: [x] -->\r\n- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version.\r\n- [x] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.\r\n- [x] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).\r\n\r\n- **OS version and name**: macOS\r\n- **Poetry version**: `1.2.0a1` and `1.2.0a2`\r\n- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**:\r\n```\r\n[tool.poetry]\r\nname = \"foo\"\r\nversion = \"0.1.0\"\r\ndescription = \"foo\"\r\nauthors = [\"Martin Liu <martin.xs.liu@gmail.com>\"]\r\nreadme = \"README.md\"\r\n\r\n[tool.poetry.dependencies]\r\npython = \"^3.6.2\"\r\n\r\n[build-system]\r\nrequires = [\"poetry-core>=1.0.0\"]\r\nbuild-backend = \"poetry.core.masonry.api\"\r\n```\r\n\r\n## Issue\r\nRunning `poetry publish` throws the following exception. This reproduces for both `1.2.0a1` and `1.2.0a2`.\r\n```\r\n  Stack trace:\r\n\r\n  8  .venv/lib/python3.9/site-packages/cleo/application.py:330 in run\r\n      328\u2502\r\n      329\u2502             try:\r\n    \u2192 330\u2502                 exit_code = self._run(io)\r\n      331\u2502             except Exception as e:\r\n      332\u2502                 if not self._catch_exceptions:\r\n\r\n  7  .venv/lib/python3.9/site-packages/poetry/console/application.py:180 in _run\r\n      178\u2502         self._load_plugins(io)\r\n      179\u2502\r\n    \u2192 180\u2502         return super()._run(io)\r\n      181\u2502\r\n      182\u2502     def _configure_io(self, io: IO) -> None:\r\n\r\n  6  .venv/lib/python3.9/site-packages/cleo/application.py:425 in _run\r\n      423\u2502                 io.set_input(ArgvInput(argv))\r\n      424\u2502\r\n    \u2192 425\u2502         exit_code = self._run_command(command, io)\r\n      426\u2502         self._running_command = None\r\n      427\u2502\r\n\r\n  5  .venv/lib/python3.9/site-packages/cleo/application.py:467 in _run_command\r\n      465\u2502\r\n      466\u2502         if error is not None:\r\n    \u2192 467\u2502             raise error\r\n      468\u2502\r\n      469\u2502         return event.exit_code\r\n\r\n  4  .venv/lib/python3.9/site-packages/cleo/application.py:451 in _run_command\r\n      449\u2502\r\n      450\u2502             if event.command_should_run():\r\n    \u2192 451\u2502                 exit_code = command.run(io)\r\n      452\u2502             else:\r\n      453\u2502                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED\r\n\r\n  3  .venv/lib/python3.9/site-packages/cleo/commands/base_command.py:118 in run\r\n      116\u2502         io.input.validate()\r\n      117\u2502\r\n    \u2192 118\u2502         status_code = self.execute(io)\r\n      119\u2502\r\n      120\u2502         if status_code is None:\r\n\r\n  2  .venv/lib/python3.9/site-packages/cleo/commands/command.py:85 in execute\r\n       83\u2502\r\n       84\u2502         try:\r\n    \u2192  85\u2502             return self.handle()\r\n       86\u2502         except KeyboardInterrupt:\r\n       87\u2502             return 1\r\n\r\n  1  .venv/lib/python3.9/site-packages/poetry/console/commands/publish.py:78 in handle\r\n       76\u2502         )\r\n       77\u2502\r\n    \u2192  78\u2502         publisher.publish(\r\n       79\u2502             self.option(\"repository\"),\r\n       80\u2502             self.option(\"username\"),\r\n\r\n  AttributeError\r\n\r\n  'IO' object has no attribute 'ask'\r\n\r\n  at .venv/lib/python3.9/site-packages/poetry/publishing/publisher.py:82 in publish\r\n       78\u2502         )\r\n       79\u2502         # Requesting missing credentials but only if there is not a client cert defined.\r\n       80\u2502         if not resolved_client_cert:\r\n       81\u2502             if username is None:\r\n    \u2192  82\u2502                 username = self._io.ask(\"Username:\")\r\n       83\u2502\r\n       84\u2502             # skip password input if no username is provided, assume unauthenticated\r\n       85\u2502             if username and password is None:\r\n       86\u2502                 password = self._io.ask_hidden(\"Password:\")\r\n```\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nimport logging\n\nfrom typing import TYPE_CHECKING\n\nfrom poetry.publishing.uploader import Uploader\nfrom poetry.utils.authenticator import Authenticator\n\n\nif TYPE_CHECKING:\n    from pathlib import Path\n\n    from cleo.io import BufferedIO\n    from cleo.io import ConsoleIO\n\n    from poetry.poetry import Poetry\n\nlogger = logging.getLogger(__name__)\n\n\nclass Publisher:\n    \"\"\"\n    Registers and publishes packages to remote repositories.\n    \"\"\"\n\n    def __init__(self, poetry: Poetry, io: BufferedIO | ConsoleIO) -> None:\n        self._poetry = poetry\n        self._package = poetry.package\n        self._io = io\n        self._uploader = Uploader(poetry, io)\n        self._authenticator = Authenticator(poetry.config, self._io)\n\n    @property\n    def files(self) -> list[Path]:\n        return self._uploader.files\n\n    def publish(\n        self,\n        repository_name: str | None,\n        username: str | None,\n        password: str | None,\n        cert: Path | None = None,\n        client_cert: Path | None = None,\n        dry_run: bool = False,\n        skip_existing: bool = False,\n    ) -> None:\n        if not repository_name:\n            url = \"https://upload.pypi.org/legacy/\"\n            repository_name = \"pypi\"\n        else:\n            # Retrieving config information\n            url = self._poetry.config.get(f\"repositories.{repository_name}.url\")\n            if url is None:\n                raise RuntimeError(f\"Repository {repository_name} is not defined\")\n\n        if not (username and password):\n            # Check if we have a token first\n            token = self._authenticator.get_pypi_token(repository_name)\n            if token:\n                logger.debug(f\"Found an API token for {repository_name}.\")\n                username = \"__token__\"\n                password = token\n            else:\n                auth = self._authenticator.get_http_auth(repository_name)\n                if auth:\n                    logger.debug(\n                        f\"Found authentication information for {repository_name}.\"\n                    )\n                    username = auth.username\n                    password = auth.password\n\n        certificates = self._authenticator.get_certs_for_repository(repository_name)\n        resolved_cert = cert or certificates.cert or certificates.verify\n        resolved_client_cert = client_cert or certificates.client_cert\n\n        # Requesting missing credentials but only if there is not a client cert defined.\n        if not resolved_client_cert and hasattr(self._io, \"ask\"):\n            if username is None:\n                username = self._io.ask(\"Username:\")\n\n            # skip password input if no username is provided, assume unauthenticated\n            if username and password is None:\n                password = self._io.ask_hidden(\"Password:\")\n\n        self._uploader.auth(username, password)\n\n        if repository_name == \"pypi\":\n            repository_name = \"PyPI\"\n        self._io.write_line(\n            f\"Publishing <c1>{self._package.pretty_name}</c1>\"\n            f\" (<c2>{self._package.pretty_version}</c2>) to\"\n            f\" <info>{repository_name}</info>\"\n        )\n\n        self._uploader.upload(\n            url,\n            cert=resolved_cert,\n            client_cert=resolved_client_cert,\n            dry_run=dry_run,\n            skip_existing=skip_existing,\n        )\n", "path": "src/poetry/publishing/publisher.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport logging\n\nfrom typing import TYPE_CHECKING\n\nfrom poetry.publishing.uploader import Uploader\nfrom poetry.utils.authenticator import Authenticator\n\n\nif TYPE_CHECKING:\n    from pathlib import Path\n\n    from cleo.io import BufferedIO\n    from cleo.io import ConsoleIO\n\n    from poetry.poetry import Poetry\n\nlogger = logging.getLogger(__name__)\n\n\nclass Publisher:\n    \"\"\"\n    Registers and publishes packages to remote repositories.\n    \"\"\"\n\n    def __init__(self, poetry: Poetry, io: BufferedIO | ConsoleIO) -> None:\n        self._poetry = poetry\n        self._package = poetry.package\n        self._io = io\n        self._uploader = Uploader(poetry, io)\n        self._authenticator = Authenticator(poetry.config, self._io)\n\n    @property\n    def files(self) -> list[Path]:\n        return self._uploader.files\n\n    def publish(\n        self,\n        repository_name: str | None,\n        username: str | None,\n        password: str | None,\n        cert: Path | None = None,\n        client_cert: Path | None = None,\n        dry_run: bool = False,\n        skip_existing: bool = False,\n    ) -> None:\n        if not repository_name:\n            url = \"https://upload.pypi.org/legacy/\"\n            repository_name = \"pypi\"\n        else:\n            # Retrieving config information\n            url = self._poetry.config.get(f\"repositories.{repository_name}.url\")\n            if url is None:\n                raise RuntimeError(f\"Repository {repository_name} is not defined\")\n\n        if not (username and password):\n            # Check if we have a token first\n            token = self._authenticator.get_pypi_token(repository_name)\n            if token:\n                logger.debug(f\"Found an API token for {repository_name}.\")\n                username = \"__token__\"\n                password = token\n            else:\n                auth = self._authenticator.get_http_auth(repository_name)\n                if auth:\n                    logger.debug(\n                        f\"Found authentication information for {repository_name}.\"\n                    )\n                    username = auth.username\n                    password = auth.password\n\n        certificates = self._authenticator.get_certs_for_repository(repository_name)\n        resolved_cert = cert or certificates.cert or certificates.verify\n        resolved_client_cert = client_cert or certificates.client_cert\n\n        self._uploader.auth(username, password)\n\n        if repository_name == \"pypi\":\n            repository_name = \"PyPI\"\n        self._io.write_line(\n            f\"Publishing <c1>{self._package.pretty_name}</c1>\"\n            f\" (<c2>{self._package.pretty_version}</c2>) to\"\n            f\" <info>{repository_name}</info>\"\n        )\n\n        self._uploader.upload(\n            url,\n            cert=resolved_cert,\n            client_cert=resolved_client_cert,\n            dry_run=dry_run,\n            skip_existing=skip_existing,\n        )\n", "path": "src/poetry/publishing/publisher.py"}]}