Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dict_to_toml() is not Fault-aware #621

Open
Kunsi opened this issue Apr 10, 2021 · 1 comment
Open

dict_to_toml() is not Fault-aware #621

Kunsi opened this issue Apr 10, 2021 · 1 comment

Comments

@Kunsi
Copy link
Contributor

Kunsi commented Apr 10, 2021

I'm using dict_to_toml() to generate a config file, which contains Faults. I noticed dict_to_toml() doesn't convert Faults to strings.

I have patched my local installation as follows, but i'm not sure wether that's the best solution. That's why i'm filing an issue instead of a pull request.

diff --git a/bundlewrap/utils/dicts.py b/bundlewrap/utils/dicts.py
index d03859b2..f1353273 100644
--- a/bundlewrap/utils/dicts.py
+++ b/bundlewrap/utils/dicts.py
@@ -43,13 +43,15 @@ ATOMIC_TYPES = {
 
 def dict_to_toml(dict_obj):
     toml_doc = toml_document()
-    for key, value in dict_obj.items():
+    for key, value in sorted(dict_obj.items()):
         if isinstance(value, tuple):
             toml_doc[key] = list(value)
         elif isinstance(value, set):
             toml_doc[key] = sorted(value)
         elif isinstance(value, dict):
             toml_doc[key] = dict_to_toml(value)
+        elif isinstance(value, Fault):
+            toml_doc[key] = str(value)
         else:
             toml_doc[key] = value
     return toml_doc
@Kunsi
Copy link
Contributor Author

Kunsi commented Apr 10, 2021

Well, it's not that easy, since now we're resolving Faults too early :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant