Repository: conan-io/conan

Issue:
Autodetected arch is empty, producing wrong default profile
If platform.machine() returns empty (can do it in some cases, as when called from cmake), the arch is empty, leading to a:

```
arch=
```

In the default profile, which later can result in an error because "" is not a known architecture in settings.yml. It seems that not adding the ``arch=`` in the profile could be the way to go.



Discussion:

Patch:
diff --git a/conans/client/conf/detect.py b/conans/client/conf/detect.py
index c0909af9b..4bf3229f8 100644
--- a/conans/client/conf/detect.py
+++ b/conans/client/conf/detect.py
@@ -185,17 +185,19 @@ def _detect_os_arch(result, output):
     the_os = detected_os()
     result.append(("os", the_os))
     result.append(("os_build", the_os))
-    arch = architectures.get(platform.machine().lower(), platform.machine().lower())
-    if arch.startswith('arm'):
-        for a in ("armv6", "armv7hf", "armv7", "armv8"):
-            if arch.startswith(a):
-                arch = a
-                break
-        else:
-            output.error("Your ARM '%s' architecture is probably not defined in settings.yml\n"
-                         "Please check your conan.conf and settings.yml files" % arch)
-    result.append(("arch", arch))
-    result.append(("arch_build", arch))
+    platform_machine = platform.machine().lower()
+    if platform_machine:
+        arch = architectures.get(platform_machine, platform_machine)
+        if arch.startswith('arm'):
+            for a in ("armv6", "armv7hf", "armv7", "armv8"):
+                if arch.startswith(a):
+                    arch = a
+                    break
+            else:
+                output.error("Your ARM '%s' architecture is probably not defined in settings.yml\n"
+                             "Please check your conan.conf and settings.yml files" % arch)
+        result.append(("arch", arch))
+        result.append(("arch_build", arch))
 
 
 def detect_defaults_settings(output):


Test patch:
diff --git a/conans/test/util/detect_test.py b/conans/test/util/detect_test.py
index f71304e38..e4e9ae23b 100644
--- a/conans/test/util/detect_test.py
+++ b/conans/test/util/detect_test.py
@@ -1,6 +1,7 @@
 import platform
 import subprocess
 import unittest
+from mock import mock
 
 from conans import tools
 from conans.client.conf.detect import detect_defaults_settings
@@ -51,3 +52,10 @@ class DetectTest(unittest.TestCase):
         self.assertIsNone(result.get("compiler", None))
         self.assertIn("gcc detected as a frontend using apple-clang", output)
         self.assertIsNotNone(output.error)
+
+    @mock.patch("platform.machine", return_value="")
+    def test_detect_empty_arch(self, _):
+        result = detect_defaults_settings(output=TestBufferConanOutput())
+        result = dict(result)
+        self.assertTrue("arch" not in result)
+        self.assertTrue("arch_build" not in result)