Skip to content

[BUG] Seems like output dir tree printing in dcm2bids_scaffold assumes UTF-8 encoding which breaks logging on windows #317

@kenanoestreich

Description

@kenanoestreich

The core function of dcm2bids_scaffold seems to still be working fine by inspecting the files and directories.

I ran dcm2bids_scaffold -o ~/bids_dir on git bash on Windows 11, and I received a logging error for each file or directory created; each looked like this, with small changes depending on which file or directory it tried to log.

Not a big issue, but might be solved if you can figure out the unicode encoding of the native system. Not sure how all that works.

Here's the error:

--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\username\miniconda3\envs\dcm2bids\Lib\logging\__init__.py", line 1113, in emit
    stream.write(msg + self.terminator)
  File "C:\Users\username\miniconda3\envs\dcm2bids\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode characters in position 55-57: character maps to <undefined>
Call stack:
  File "C:\Users\username\miniconda3\envs\dcm2bids\Scripts\dcm2bids_scaffold-script.py", line 9, in <module>
    sys.exit(main())
  File "C:\Users\username\miniconda3\envs\dcm2bids\Lib\site-packages\dcm2bids\cli\dcm2bids_scaffold.py", line 110, in main
    TreePrinter(args.output_dir).print_tree()
  File "C:\Users\username\miniconda3\envs\dcm2bids\Lib\site-packages\dcm2bids\utils\utils.py", line 209, in print_tree
    logger.info(item)
Message: '\u251c\u2500\u2500 CHANGES'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions