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

Arrays with ints is broken #44

Open
jdhedden opened this issue May 9, 2022 · 1 comment
Open

Arrays with ints is broken #44

jdhedden opened this issue May 9, 2022 · 1 comment

Comments

@jdhedden
Copy link

jdhedden commented May 9, 2022

> echo -e '1\t2' | filter -c1 odd
Traceback (most recent call last):
  File "/home/jdhedden/bin/filter", line 6, in <module>
    Filter().run()
  File "/mnt/data/Computer/Linux/shell-functools/ft/ft/command.py", line 101, in run
    self.handle_input(value)
  File "/mnt/data/Computer/Linux/shell-functools/ft/ft/commands/filter.py", line 34, in handle_input
    self.print_formatted(value)
  File "/mnt/data/Computer/Linux/shell-functools/ft/ft/command.py", line 78, in print_formatted
    formatted = ftformat(result)
  File "/mnt/data/Computer/Linux/shell-functools/ft/ft/internal.py", line 17, in ftformat
    return "\t".join(map(ftformat, val.value))
TypeError: sequence item 0: expected str instance, int found

Offered fix:

diff --git a/ft/ft/internal.py b/ft/ft/internal.py
index 33ee227..b8a981f 100644
--- a/ft/ft/internal.py
+++ b/ft/ft/internal.py
@@ -13,7 +13,7 @@ def colored(inp, col):
 
 def ftformat(val):
     if val.fttype == T_ARRAY:
-        return "\t".join(map(ftformat, val.value))
+        return "\t".join(map(str, map(ftformat, val.value)))
     elif val.fttype == T_PATH:
         return colored(val.value, "cyan")
     elif val.fttype == T_STRING:

Result:

> echo -e '1\t2' | filter -c1 odd
1	2
@jdhedden jdhedden changed the title Arrays of Ints is broken Arrays with ints is broken May 9, 2022
@sharkdp
Copy link
Owner

sharkdp commented May 22, 2022

Thank you for reporting this. Note that I'm not using this project myself anymore, so I'm not really actively maintaining it. Happy to integrate a bugfix PR with tests though.

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

2 participants