Skip to content

music21.converter.parse() fails if the input compressed MusicXML (MXL) contains only one XML file with filename exactly as ".xml" #1832

@dszeto

Description

@dszeto

music21 version

9.9.1

Operating System(s) checked
macOS, Linux (platform-agnostic issue)

Problem summary

When music21.converter.parse opens a compressed MusicXML (MXL) that contains only one XML file with the filename exactly as .xml, it throws an exception. Upon further investigation, the line at

if pathlib.Path(subFp).suffix not in ['.musicxml', '.xml', '.mxl']:
fails to include .xml because .suffix returns an empty string for .xml.

Steps to reproduce

First, use Noteflight to produce an MXL file (because they consistently produce MXL files with this issue), then simply

import music21

music21.converter.parse("mxl.mxl")

will throw an exception.

More information

A quick fix would be to also match file extensions as is as extra testing conditions.

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