Repository: conan-io/conan
Pull request #17534 (2024-12-27 20:54:59)

upgrade bottle version
Changelog: Fix: Allow latest bottle 0.13 release for ``conan_server`` to work with Python 3.13
Docs: Omit

Close https://github.com/conan-io/conan/issues/17533


Patch:
diff --git a/conan/tools/files/files.py b/conan/tools/files/files.py
index bbb96bf90..b3a05026b 100644
--- a/conan/tools/files/files.py
+++ b/conan/tools/files/files.py
@@ -451,6 +451,7 @@ def replace_in_file(conanfile, file_path, search, replace, strict=True, encoding
            string is not found, so nothing is actually replaced.
     :param encoding: (Optional, Defaulted to utf-8): Specifies the input and output files text
            encoding.
+    :return: ``True`` if the pattern was found, ``False`` otherwise if `strict` is ``False``.
     """
     output = conanfile.output
     content = load(conanfile, file_path, encoding=encoding)
@@ -463,6 +464,7 @@ def replace_in_file(conanfile, file_path, search, replace, strict=True, encoding
             return False
     content = content.replace(search, replace)
     save(conanfile, file_path, content, encoding=encoding)
+    return True
 
 
 def collect_libs(conanfile, folder=None):
diff --git a/conans/requirements_server.txt b/conans/requirements_server.txt
index f7a3f7ab0..d4147ed38 100644
--- a/conans/requirements_server.txt
+++ b/conans/requirements_server.txt
@@ -1,4 +1,4 @@
 # Server
-bottle>=0.12.8, < 0.13
+bottle>=0.12.8, < 0.14
 pluginbase>=0.5
 PyJWT>=2.4.0, <3.0.0


Test patch:
diff --git a/test/unittests/tools/files/test_file_read_and_write.py b/test/unittests/tools/files/test_file_read_and_write.py
index 4a6d12ab1..1fee30fbe 100644
--- a/test/unittests/tools/files/test_file_read_and_write.py
+++ b/test/unittests/tools/files/test_file_read_and_write.py
@@ -3,6 +3,9 @@
 
 import os
 
+import pytest
+
+from conan.errors import ConanException
 from conan.tools.files import replace_in_file, save, load
 from conan.test.utils.mocks import ConanFileMock
 from conan.test.utils.test_files import temp_folder
@@ -36,18 +39,18 @@ def test_replace_in_file():
 
     # By default utf-8 is used
     save(conanfile, file_path, "你很重，伙計")
-    replace_in_file(conanfile, file_path, "重", "0")
+    assert replace_in_file(conanfile, file_path, "重", "0")
     contents = load(conanfile, file_path)
     assert contents == "你很0，伙計"
 
     # Replacing with other encodings is also possible
     save(conanfile, file_path, "Ö¼", encoding="cp1252")
-    replace_in_file(conanfile, file_path, "¼", "0", encoding="cp1252")
+    assert replace_in_file(conanfile, file_path, "¼", "0", encoding="cp1252")
     contents = load(conanfile, file_path, encoding="cp1252")
     assert contents == "Ö0"
 
     save(conanfile, file_path, "Ö¼", encoding="ISO-8859-1")
-    replace_in_file(conanfile, file_path, "¼", "0", encoding="ISO-8859-1")
+    assert replace_in_file(conanfile, file_path, "¼", "0", encoding="ISO-8859-1")
     contents = load(conanfile, file_path, encoding="ISO-8859-1")
     assert contents == "Ö0"
 
@@ -57,3 +60,9 @@ def test_replace_in_file():
     replace_in_file(conanfile, file_path, "重", "0", encoding="utf-16")
     contents = load(conanfile, file_path, encoding="utf-16")
     assert contents == "你很0，伙計"
+
+    with pytest.raises(ConanException, match="didn't find pattern"):
+        replace_in_file(conanfile, file_path, "not existing", "0", encoding="utf-16")
+
+    assert not replace_in_file(conanfile, file_path, "not existing", "0",
+                               encoding="utf-16", strict=False)