Skip to content

Specifying Multi-Extension File Types [was: Crash on MacOS / M1] #27

Closed

Description

@nickzoic

(reported by Abbye)

Crashing when trying to open file dialog to add FASTQ or CSV.
Crash happens as soon as you hit the "+" button to add files.
Behaviour is same in VS Code or in virtualenv.

CPU: Mac M1
OS: Ventura 13.3
Python: 3.10.12

Crash dump:
coutness_crash.rtf.txt

The important bit looks to me to be:

Application Specific Backtrace 0:\
0   CoreFoundation                      0x000000019ffbf19c __exceptionPreprocess + 176\
1   libobjc.A.dylib                     0x000000019fade4d4 objc_exception_throw + 60\
2   CoreFoundation                      0x00000001a00a99d4 -[__NSCFString characterAtIndex:].cold.1 + 0\
3   CoreFoundation                      0x00000001a00a5fe8 -[__NSArrayM insertObject:atIndex:].cold.2 + 0\
4   CoreFoundation                      0x000000019fee7340 -[__NSArrayM insertObject:atIndex:] + 912\
5   libtk8.6.dylib                      0x00000001048cac88 setAllowedFileTypes + 240\
6   libtk8.6.dylib                      0x00000001048cb6b4 Tk_GetOpenFileObjCmd + 1252\
7   libtcl8.6.dylib                     0x00000001036349f4 Tcl_EvalObjv + 340\
8   _tkinter.cpython-310-darwin.so      0x000000010344efec Tkapp_Call + 404\

[... etc]

code is in countess/gui/config.py:

        if isinstance(self.parameter, FileArrayParam):
            file_types = self.parameter.file_types
            filenames = filedialog.askopenfilenames(filetypes=file_types)

where file_types is something like:

file_types = [("FASTQ", "*.fastq"), ("FASTQ (gzipped)", "*.fastq.gz")]

or

file_types = [
        ("CSV", "*.csv *.csv.gz *.csv.bz2"),
        ("TSV", "*.tsv *.tsv.gz *.tsv.bz2"),
        ("TXT", "*.txt *.txt.gz *.txt.bz2"),
    ]

I'm not totally clear on what the correct format for file_types is, some examples have '*'s and some do not and macs may need some additional information according to https://tcl.tk/man/tcl8.6/TkCmd/getOpenFile.htm#M16

Activity

  1. nickzoic commented on Oct 4, 2023

    @nickzoic
    CollaboratorAuthor

    OK using macincloud.com I can replicate this, and confirm that just askopenfilenames() doesn't trigger the bug.
    Changing the file_types to a single type like:

        file_types = [
            ("CSV", ".csv"),
            ("TSV", ".tsv"),
            ("TXT", ".txt"),
        ]
    

    also works, although the file dialog is a bit eccentric: selecting "CSV" offers up just CSV and "TSV" just TSV but selecting "TXT" offers up all three. Hmmm.

    okay so this works:

            ("CSV", [ ".csv", ".gz"]),
            ("TSV", ".tsv"),
            ("TXT", ".txt"),
        ]
    

    and even looks right

    x

    but this still doesn't!

            ("CSV", [".csv", ".csv.gz"]),
            ("TSV", ".tsv"),
            ("TXT", ".txt"),
        ]
    
  2. nickzoic commented on Oct 4, 2023

    @nickzoic
    CollaboratorAuthor

    This format for the file_types works in linux too so I guess it's okay but the inability to handle multiple extensions is problematic.

  3. added 2 commits that reference this issue on Oct 4, 2023
  4. nickzoic commented on Mar 19, 2024

    @nickzoic
    CollaboratorAuthor

    consider checking platform.system() == 'Darwin' or similar

  5. changed the title [-]Crash on MacOS / M1[/-] [+]Specifying Multi-Extension File Types [was: Crash on MacOS / M1][/+] on Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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