diff --git a/conans/client/loader.py b/conans/client/loader.py index da078b61bc6..24146dfed6d 100644 --- a/conans/client/loader.py +++ b/conans/client/loader.py @@ -323,7 +323,8 @@ def _load_python_file(conan_file_path): raise NotFoundException("%s not found!" % conan_file_path) def new_print(*args, **kwargs): # Make sure that all user python files print() goes to stderr - print(*args, **kwargs, file=sys.stderr) + kwargs['file'] = sys.stderr + print(*args, **kwargs) module_id = str(uuid.uuid1()) current_dir = os.path.dirname(conan_file_path) diff --git a/conans/test/unittests/model/conanfile_test.py b/conans/test/unittests/model/conanfile_test.py index a139d1bbe67..1ec20ae6a4f 100644 --- a/conans/test/unittests/model/conanfile_test.py +++ b/conans/test/unittests/model/conanfile_test.py @@ -37,3 +37,15 @@ def package_info(self): client.save({"conanfile.py": conanfile.replace("pass", "requires = 'pkgb/0.1@user/testing'")}) client.run("create . --name=pkgc --version=0.1 --user=user --channel=testing") + + def test_conanfile_new_print(self): + client = TestClient() + conanfile = """from conan import ConanFile +import sys +class Pkg(ConanFile): + def source(self): + print("Test", file=sys.stderr) + print("Test") +""" + client.save({"conanfile.py": conanfile}) + client.run("source .") \ No newline at end of file