electro-smith / pd2dsy

Utility for converting Pure Data (Vanilla) patches to Daisy projects.
GNU General Public License v3.0
77 stars 11 forks source link

`dsy_board_gen.py` Problems with Python 3.8.10 #16

Closed CorvusPrudens closed 2 years ago

CorvusPrudens commented 2 years ago

For some reason, the filter_map_ctrl function throws an exception when using python 3.8.10, which is the version shipped with my release of Ubuntu at the moment:

Traceback (most recent call last):
  File "daisy_board_gen.py", line 161, in <module>
    template_code = generate_target_struct(infile)
  File "daisy_board_gen.py", line 122, in generate_target_struct
    replacements['init_single'] = filter_map_ctrl(components, 'typename', 'daisy::AnalogControl', 'init_single')
  File "daisy_board_gen.py", line 51, in filter_map_ctrl
    return "\n\t\t".join(map(lambda x: x[init_key].format_map(x), set))
  File "daisy_board_gen.py", line 50, in <lambda>
    set = map(lambda x, i: x | {'i': i}, set, range(1000))
TypeError: unsupported operand type(s) for |: 'dict' and 'dict'

Oddly enough, doing a pointless list comprehension before the second line in the function fixes the issue ([x for x in set]). Maybe it's a bug in how python used to handle filter objects?

Anyway, this is all not very relevant since the latest python release is 3.10. I'm just putting this here in case this issue crops up in the future.

stephenhensley commented 2 years ago

good to be aware of. definitely don't see an immediate cause for this unless the normal retval within the lambda expression is non-dict, and this is an exception based on specific input. But if it only happens in python 3.8.10 then that seems unlikely.

Also, I wonder how relevant these helper functions will be when we get everything set back up to work with a jinja template. We may end up wanting to restructure the way we set up the data to keep that easy to manage.

stephenhensley commented 2 years ago

this is/has been moved outside of the scope of this repo