Repository: conan-io/conan

Issue:
Conan displays ValueError: too many values to unpack
To help us debug your issue please explain:

- [x] I've read the [CONTRIBUTING guide](https://raw.githubusercontent.com/conan-io/conan/develop/.github/CONTRIBUTING.md).
- [x] I've specified the Conan version, operating system version and any tool that can be relevant.
- [x] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.

Hello,

This morning I tried to build one of my packages and was greeted with the following error:
```ValueError: too many values to unpack```

After a bit of digging, I got this stack trace
```
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): artifactory.avira.org
DEBUG:urllib3.connectionpool:<artifactory-url> "GET /artifactory/api/conan/conan-local/v1/conans/<dependency-of-the-recipe>/download_urls HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:<artifactory-url> "GET /artifactory/api/conan/conan-local/v1/files/<dependency-of-the-recipe>/conaninfo.txt HTTP/1.1" 200 1197
Traceback (most recent call last):
  File "/Users/user/venv/lib/python3.6/site-packages/conans/client/remote_manager.py", line 252, in _call_remote
    return getattr(self._auth_manager, method)(*argc, **argv)
  File "/Users/user/venv/lib/python3.6/site-packages/conans/client/rest/auth_manager.py", line 32, in wrapper
    ret = func(self, *args, **kwargs)
  File "/Users/user/venv/lib/python3.6/site-packages/conans/client/rest/auth_manager.py", line 157, in get_package_info
    return self._rest_client.get_package_info(package_reference)
  File "/Users/user/venv/lib/python3.6/site-packages/conans/client/rest/rest_client.py", line 132, in get_package_info
    return ConanInfo.loads(contents[CONANINFO])
  File "/Users/user/venv/lib/python3.6/site-packages/conans/model/info.py", line 264, in loads
    result.settings = Values.loads(parser.settings)
  File "/Users/user/venv/lib/python3.6/site-packages/conans/model/values.py", line 66, in loads
    name, value = line.split("=")
ValueError: too many values to unpack (expected 2)
```

Upon closer inspection of the ```conaninfo.txt``` file the offending line was evident:
```
[settings]
    arch=x86_64
    build_type=Release
    compiler=apple-clang
    compiler.version=macosx-version-min=10.8
    os=Macos
```
The issue occurs when the line ```compiler.version``` is parsed.
This version is set because I have defined the following ```package_id```:
```
def package_id(self):
    compiler_version = Version(str(self.settings.compiler.version))
    if self.settings.compiler == "apple-clang" and compiler_version >= "7.0":
        if "deployment_target" in self.options:
            self.info.settings.compiler.version = "macosx-version-min=%s" % self.options.deployment_target
        else:
            self.info.settings.compiler.version = "Modern Apple Clang"
```

On the documentation page [Define package ABI compatibility](http://docs.conan.io/en/latest/creating_packages/define_abi_compatibility.html#define-abi-compatibility) it is stated:
> We have set the self.info.settings.compiler.version with an arbitrary string, it’s not really important, could be any string.

Software information:
I'm currently using Conan ```version 1.2.1``` on
```
ProductName:	Mac OS X
ProductVersion:	10.13.4
BuildVersion:	17E199
```
with
```
Xcode 9.3
Build version 9E145
```
and ```Python 3.6.5``` installed from brew


Discussion:
Hi @T1T4N!

yes, seems this error comes from the parsing of the setting value with the ``=`` symbol.

Could you please indicate the command line you used when you came across this issue? just a normal ``conan create``?

I dont think it is related but make sure you have that ``compiler.version`` in your *settings.yaml* in order to consume your packages afterwards.

Thanks!
Hi @danimtb,

Thanks for the quick reply.

Yes, just a normal ```conan create``` outputs the ```ValueError: too many values to unpack``` message.

The issue only happens when fetching a dependency from a server. When I have the package with the offending line in my local cache, ```conan create``` executes successfully.

But in general, I think that the logic in ```Values.loads``` is incorrect, since it should be splitting at the first occurrence of ```=``` and not do ```name, value = line.split("=")```.

Thanks a lot for the clear answer. I was able to reproduce your issue.
I also found another issue related to this with the ``conan search``.

Let me include the steps here:

*conanfile.py*
```
from conans import ConanFile

class TestConan(ConanFile):
    name = "test"
    version = "0.1"
    settings = "os", "compiler", "arch", "build_type"
    exports_sources = "header.h"

    def package_id(self):
        self.info.settings.compiler.version = "kk=kk"

    def package(self):
        self.copy("header.h", dst="include", keep_path=True)
```

Commands:

```
$ conan create conanfile.py danimtb/testing
...


$ conan search test/0.1@danimtb/testing
There are no packages for reference 'test/0.1@danimtb/testing', but package recipe found.


$ conan upload test/0.1@danimtb/testing -r upload_repo --all
Uploading test/0.1@danimtb/testing
...
Uploaded conan recipe 'test/0.1@danimtb/testing' to 'upload_repo': https://bintray.com/danimtb/public-conan
Uploading package 1/1: 28e290a896cddcc145d27050b8127de35d71157e
...


$ conan remove test/0.1@danimtb/testing
Are you sure you want to delete from 'test/0.1@danimtb/testing' (yes/no): y


$ conan install test/0.1@danimtb/testing -r upload_repo
test/0.1@danimtb/testing: Not found, retrieving from server 'upload_repo'
test/0.1@danimtb/testing: Trying with 'upload_repo'...
Downloading conanmanifest.txt
[==================================================] 115B/115B
Downloading conanfile.py
[==================================================] 349B/349B
test/0.1@danimtb/testing: Installing package
Requirements
    test/0.1@danimtb/testing from 'upload_repo'
Packages
    test/0.1@danimtb/testing:28e290a896cddcc145d27050b8127de35d71157e

ERROR: too many values to unpack (expected 2)
```

Resolving patch:
diff --git a/conans/model/values.py b/conans/model/values.py
--- a/conans/model/values.py
+++ b/conans/model/values.py
@@ -63,7 +63,7 @@ def loads(cls, text):
         for line in text.splitlines():
             if not line.strip():
                 continue
-            name, value = line.split("=")
+            name, value = line.split("=", 1)
             result.append((name.strip(), value.strip()))
         return cls.from_list(result)
 


Test patch:
diff --git a/conans/test/functional/package_id_test.py b/conans/test/functional/package_id_test.py
new file mode 100644
--- /dev/null
+++ b/conans/test/functional/package_id_test.py
@@ -0,0 +1,35 @@
+import unittest
+from conans.test.utils.tools import TestClient, TestServer
+
+class PackageIdTest(unittest.TestCase):
+
+    def value_parse_test(self):
+        # https://github.com/conan-io/conan/issues/2816
+        conanfile = """
+from conans import ConanFile
+
+class TestConan(ConanFile):
+    name = "test"
+    version = "0.1"
+    settings = "os", "compiler", "arch", "build_type"
+    exports_sources = "header.h"
+
+    def package_id(self):
+        self.info.settings.compiler.version = "kk=kk"
+
+    def package(self):
+        self.copy("header.h", dst="include", keep_path=True)
+"""
+        server = TestServer([("*/*@*/*", "*")], [("*/*@*/*", "*")], users={"lasote": "mypass"})
+        servers = {"default": server}
+        client = TestClient(servers=servers, users={"default": [("lasote", "mypass")]})
+        client.save({"conanfile.py": conanfile,
+                     "header.h": "header content"})
+        client.run("create . danimtb/testing")
+        client.run("search test/0.1@danimtb/testing")
+        self.assertIn("compiler.version: kk=kk", client.out)
+        client.run("upload test/0.1@danimtb/testing --all")
+        client.run("remove test/0.1@danimtb/testing --force")
+        client.run("install test/0.1@danimtb/testing")
+        client.run("search test/0.1@danimtb/testing")
+        self.assertIn("compiler.version: kk=kk", client.out)