We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Update versions in README.md on Playwright roll


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `build_driver.py`
Content:
```
1 # Copyright (c) Microsoft Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import gzip
16 import os
17 import shutil
18 import subprocess
19 
20 driver_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "driver")
21 package_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "playwright")
22 drivers_path = os.path.join(package_path, "drivers")
23 
24 if os.path.exists(os.path.join(driver_path, "package-lock.json")):
25     os.remove(os.path.join(driver_path, "package-lock.json"))
26 if os.path.exists(os.path.join(driver_path, "node_modules")):
27     shutil.rmtree(os.path.join(driver_path, "node_modules"))
28 if os.path.exists(os.path.join(driver_path, "out")):
29     shutil.rmtree(os.path.join(driver_path, "out"))
30 
31 subprocess.run("npm i", cwd=driver_path, shell=True)
32 subprocess.run("npm run bake", cwd=driver_path, shell=True)
33 
34 for driver in ["driver-linux", "driver-macos", "driver-win.exe"]:
35     if os.path.exists(os.path.join(package_path, driver)):
36         os.remove(os.path.join(package_path, driver))
37 
38     in_path = os.path.join(driver_path, "out", driver)
39     out_path = os.path.join(drivers_path, driver + ".gz")
40     with open(in_path, "rb") as f_in, gzip.open(out_path, "wb") as f_out:
41         shutil.copyfileobj(f_in, f_out)
42 
43 shutil.copyfile(
44     os.path.join(driver_path, "node_modules", "playwright", "browsers.json"),
45     os.path.join(drivers_path, "browsers.json"),
46 )
47
```
--- 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/build_driver.py b/build_driver.py
--- a/build_driver.py
+++ b/build_driver.py
@@ -14,33 +14,52 @@
 
 import gzip
 import os
+import re
 import shutil
 import subprocess
+from pathlib import Path
 
-driver_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "driver")
-package_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "playwright")
-drivers_path = os.path.join(package_path, "drivers")
+_dirname = Path(os.path.dirname(os.path.abspath(__file__)))
 
-if os.path.exists(os.path.join(driver_path, "package-lock.json")):
-    os.remove(os.path.join(driver_path, "package-lock.json"))
-if os.path.exists(os.path.join(driver_path, "node_modules")):
-    shutil.rmtree(os.path.join(driver_path, "node_modules"))
-if os.path.exists(os.path.join(driver_path, "out")):
-    shutil.rmtree(os.path.join(driver_path, "out"))
+driver_path = _dirname / "driver"
+package_path = _dirname / "playwright"
+drivers_path = package_path / "drivers"
+
+if (driver_path / "package-lock.json").exists():
+    os.remove(driver_path / "package-lock.json")
+if (driver_path / "node_modules").exists():
+    shutil.rmtree(driver_path / "node_modules")
+if (driver_path / "out").exists():
+    shutil.rmtree(driver_path / "out")
 
 subprocess.run("npm i", cwd=driver_path, shell=True)
 subprocess.run("npm run bake", cwd=driver_path, shell=True)
 
 for driver in ["driver-linux", "driver-macos", "driver-win.exe"]:
-    if os.path.exists(os.path.join(package_path, driver)):
-        os.remove(os.path.join(package_path, driver))
+    if (package_path / driver).exists():
+        os.remove((package_path / driver))
 
-    in_path = os.path.join(driver_path, "out", driver)
-    out_path = os.path.join(drivers_path, driver + ".gz")
+    in_path = driver_path / "out" / driver
+    out_path = drivers_path / (driver + ".gz")
     with open(in_path, "rb") as f_in, gzip.open(out_path, "wb") as f_out:
         shutil.copyfileobj(f_in, f_out)
 
+node_modules_playwright = driver_path / "node_modules" / "playwright"
+
 shutil.copyfile(
-    os.path.join(driver_path, "node_modules", "playwright", "browsers.json"),
-    os.path.join(drivers_path, "browsers.json"),
+    node_modules_playwright / "browsers.json", drivers_path / "browsers.json",
 )
+
+upstream_readme = (node_modules_playwright / "README.md").read_text()
+pw_python_readme = (_dirname / "README.md").read_text()
+
+matches = re.findall(r"<!-- GEN:(.*?) -->(.*?)<!-- GEN:stop -->", upstream_readme)
+
+for key, value in matches:
+    pw_python_readme = re.sub(
+        rf"(<!-- GEN:{key} -->).*?(<!-- GEN:stop -->)",
+        f"<!-- GEN:{key} -->{value}<!-- GEN:stop -->",
+        pw_python_readme,
+    )
+
+(_dirname / "README.md").write_text(pw_python_readme)

{"golden_diff": "diff --git a/build_driver.py b/build_driver.py\n--- a/build_driver.py\n+++ b/build_driver.py\n@@ -14,33 +14,52 @@\n \n import gzip\n import os\n+import re\n import shutil\n import subprocess\n+from pathlib import Path\n \n-driver_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), \"driver\")\n-package_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), \"playwright\")\n-drivers_path = os.path.join(package_path, \"drivers\")\n+_dirname = Path(os.path.dirname(os.path.abspath(__file__)))\n \n-if os.path.exists(os.path.join(driver_path, \"package-lock.json\")):\n-    os.remove(os.path.join(driver_path, \"package-lock.json\"))\n-if os.path.exists(os.path.join(driver_path, \"node_modules\")):\n-    shutil.rmtree(os.path.join(driver_path, \"node_modules\"))\n-if os.path.exists(os.path.join(driver_path, \"out\")):\n-    shutil.rmtree(os.path.join(driver_path, \"out\"))\n+driver_path = _dirname / \"driver\"\n+package_path = _dirname / \"playwright\"\n+drivers_path = package_path / \"drivers\"\n+\n+if (driver_path / \"package-lock.json\").exists():\n+    os.remove(driver_path / \"package-lock.json\")\n+if (driver_path / \"node_modules\").exists():\n+    shutil.rmtree(driver_path / \"node_modules\")\n+if (driver_path / \"out\").exists():\n+    shutil.rmtree(driver_path / \"out\")\n \n subprocess.run(\"npm i\", cwd=driver_path, shell=True)\n subprocess.run(\"npm run bake\", cwd=driver_path, shell=True)\n \n for driver in [\"driver-linux\", \"driver-macos\", \"driver-win.exe\"]:\n-    if os.path.exists(os.path.join(package_path, driver)):\n-        os.remove(os.path.join(package_path, driver))\n+    if (package_path / driver).exists():\n+        os.remove((package_path / driver))\n \n-    in_path = os.path.join(driver_path, \"out\", driver)\n-    out_path = os.path.join(drivers_path, driver + \".gz\")\n+    in_path = driver_path / \"out\" / driver\n+    out_path = drivers_path / (driver + \".gz\")\n     with open(in_path, \"rb\") as f_in, gzip.open(out_path, \"wb\") as f_out:\n         shutil.copyfileobj(f_in, f_out)\n \n+node_modules_playwright = driver_path / \"node_modules\" / \"playwright\"\n+\n shutil.copyfile(\n-    os.path.join(driver_path, \"node_modules\", \"playwright\", \"browsers.json\"),\n-    os.path.join(drivers_path, \"browsers.json\"),\n+    node_modules_playwright / \"browsers.json\", drivers_path / \"browsers.json\",\n )\n+\n+upstream_readme = (node_modules_playwright / \"README.md\").read_text()\n+pw_python_readme = (_dirname / \"README.md\").read_text()\n+\n+matches = re.findall(r\"<!-- GEN:(.*?) -->(.*?)<!-- GEN:stop -->\", upstream_readme)\n+\n+for key, value in matches:\n+    pw_python_readme = re.sub(\n+        rf\"(<!-- GEN:{key} -->).*?(<!-- GEN:stop -->)\",\n+        f\"<!-- GEN:{key} -->{value}<!-- GEN:stop -->\",\n+        pw_python_readme,\n+    )\n+\n+(_dirname / \"README.md\").write_text(pw_python_readme)\n", "issue": "Update versions in README.md on Playwright roll\n\n", "before_files": [{"content": "# Copyright (c) Microsoft Corporation.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport gzip\nimport os\nimport shutil\nimport subprocess\n\ndriver_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), \"driver\")\npackage_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), \"playwright\")\ndrivers_path = os.path.join(package_path, \"drivers\")\n\nif os.path.exists(os.path.join(driver_path, \"package-lock.json\")):\n    os.remove(os.path.join(driver_path, \"package-lock.json\"))\nif os.path.exists(os.path.join(driver_path, \"node_modules\")):\n    shutil.rmtree(os.path.join(driver_path, \"node_modules\"))\nif os.path.exists(os.path.join(driver_path, \"out\")):\n    shutil.rmtree(os.path.join(driver_path, \"out\"))\n\nsubprocess.run(\"npm i\", cwd=driver_path, shell=True)\nsubprocess.run(\"npm run bake\", cwd=driver_path, shell=True)\n\nfor driver in [\"driver-linux\", \"driver-macos\", \"driver-win.exe\"]:\n    if os.path.exists(os.path.join(package_path, driver)):\n        os.remove(os.path.join(package_path, driver))\n\n    in_path = os.path.join(driver_path, \"out\", driver)\n    out_path = os.path.join(drivers_path, driver + \".gz\")\n    with open(in_path, \"rb\") as f_in, gzip.open(out_path, \"wb\") as f_out:\n        shutil.copyfileobj(f_in, f_out)\n\nshutil.copyfile(\n    os.path.join(driver_path, \"node_modules\", \"playwright\", \"browsers.json\"),\n    os.path.join(drivers_path, \"browsers.json\"),\n)\n", "path": "build_driver.py"}], "after_files": [{"content": "# Copyright (c) Microsoft Corporation.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport gzip\nimport os\nimport re\nimport shutil\nimport subprocess\nfrom pathlib import Path\n\n_dirname = Path(os.path.dirname(os.path.abspath(__file__)))\n\ndriver_path = _dirname / \"driver\"\npackage_path = _dirname / \"playwright\"\ndrivers_path = package_path / \"drivers\"\n\nif (driver_path / \"package-lock.json\").exists():\n    os.remove(driver_path / \"package-lock.json\")\nif (driver_path / \"node_modules\").exists():\n    shutil.rmtree(driver_path / \"node_modules\")\nif (driver_path / \"out\").exists():\n    shutil.rmtree(driver_path / \"out\")\n\nsubprocess.run(\"npm i\", cwd=driver_path, shell=True)\nsubprocess.run(\"npm run bake\", cwd=driver_path, shell=True)\n\nfor driver in [\"driver-linux\", \"driver-macos\", \"driver-win.exe\"]:\n    if (package_path / driver).exists():\n        os.remove((package_path / driver))\n\n    in_path = driver_path / \"out\" / driver\n    out_path = drivers_path / (driver + \".gz\")\n    with open(in_path, \"rb\") as f_in, gzip.open(out_path, \"wb\") as f_out:\n        shutil.copyfileobj(f_in, f_out)\n\nnode_modules_playwright = driver_path / \"node_modules\" / \"playwright\"\n\nshutil.copyfile(\n    node_modules_playwright / \"browsers.json\", drivers_path / \"browsers.json\",\n)\n\nupstream_readme = (node_modules_playwright / \"README.md\").read_text()\npw_python_readme = (_dirname / \"README.md\").read_text()\n\nmatches = re.findall(r\"<!-- GEN:(.*?) -->(.*?)<!-- GEN:stop -->\", upstream_readme)\n\nfor key, value in matches:\n    pw_python_readme = re.sub(\n        rf\"(<!-- GEN:{key} -->).*?(<!-- GEN:stop -->)\",\n        f\"<!-- GEN:{key} -->{value}<!-- GEN:stop -->\",\n        pw_python_readme,\n    )\n\n(_dirname / \"README.md\").write_text(pw_python_readme)\n", "path": "build_driver.py"}]}