Json loader now returns str objects instead of unicode.#2524
Json loader now returns str objects instead of unicode.#2524tgamblin merged 1 commit intospack:developfrom
Conversation
|
|
|
@alalazo this is not about preserving old hash values. This fixes a bug in the |
|
@svenevs This could be the problem you mentioned when trying to active |
|
@skosukhin Apologies, I tried a couple of installation before writing the comment above, but didn't try to activate anything, and this bug seems extension specific. |
|
@skosukhin: Thanks! |
|
I tested the performance of this, the performance loss is negligible on my spack instance. (~5%, compared to the improvements JSON brought, which were 181X). |
|
@tgamblin @skosukhin @becker33 I was not aware of the rabbit hole that is python 2 default string encoding vs. python 3. I have a question about this: won't this PR go in the wrong direction if we want to be python 3 compatible? Do I understand it right that in principle it would be better to explicitly encode |
|
@alalazo: we probably want to use unicode everywhere when we switch to support 2 and 3. But I think that's harder than preserving the status quo at the moment. This PR makes JSON did what YAML did before. I think it's reasonably easy to switch this stuff to unicode when we're ready. And yes it is a sad rabbit hole 😭 |
We need something like this (at least for now) because now we get unicode objects when we load from the json database. This leads to the problem of hash evaluation of already installed packages.
For example, when we do 'spack activate <python_extension>' we get the following error:
Error: Can only (de)activate extensions for installed packages.
This happens because when spack evaluates hash code, it gives yaml unicode strings and the latter, instead of returning:
{python: {version: 2.7.12, arch:...gives this:
{!!python/unicode 'python': {version: 2.7.12, arch:The solution is based on this: http://stackoverflow.com/a/33571117