Skip to content

Usage of uninitialized variable (assignment within a conditional block) #101

@pchengi

Description

@pchengi

UnboundLocalError: cannot access local variable 'drs_path' where it is not associated with a value :: SKIPPED :: /root/src-cordexcmip6files/flat/uas_EUR-12_ERA5_evaluation_r1i1p1f1_HCLIMcom-SMHI_HCLIM43-ALADIN_v1-r1_mon_200101-201012.nc Traceback (most recent call last): File "/root/esgf-prepare/esgprep/drs/make.py", line 126, in __call__ if len(drs_path.errors) != 0:

The assignment to drs_path happens inside of a condition, if self.project == 'cmip6', while drs_path.errors is being tested outside of the conditional block. If the project isn't cmip6, this would result in the above-noted exception.
A suggestion is to initialize drs_path to None, before the condition, and later, first check to ensure that drs_path is not None prior to checking for drs_path.errors.

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