# Buggy code
def _read(self, files, envs, silent=True, key=None):
    for source_file in files:
        if source_file.endswith(self.extensions):  # pragma: no cover
            try:
                source_data = self.file_reader(
                    io.open(
                        find_file(
                            source_file,
                            project_root=self.obj.get("PROJECT_ROOT_FOR_DYNACONF"),
                        ),
                        encoding=self.obj.get("ENCODING_FOR_DYNACONF", "utf-8"),
                    )
                )
                self.obj.logger.debug(
                    "{}_loader: {}".format(self.identifier, source_file)
                )
            except IOError:
                self.obj.logger.debug(
                    "{}_loader: {} (Ignored, file not Found)".format(
                        self.identifier, source_file
                    )
                )
                source_data = None
        else:
            # for tests it is possible to pass string
            source_data = self.string_reader(source_file)

        if not source_data:
            continue

        source_data = {k.lower(): value for k, value in source_data.items()}

        for env in envs:
            data = {}
            try:
                data = source_data[env.lower()]
            except KeyError:
                if env not in (self.obj.get("GLOBAL_ENV_FOR_DYNACONF"), "GLOBAL"):
                    message = "%s_loader: %s env not defined in %s" % (
                        self.identifier,
                        env,
                        source_file,
                    )
                    if silent:
                        self.obj.logger.warning(message)
                    else:
                        raise KeyError(message)
                continue

            if env != self.obj.get("DEFAULT_ENV_FOR_DYNACONF"):
                identifier = "{0}_{1}".format(self.identifier, env.lower())
            else:
                identifier = self.identifier

            if not key:
                self.obj.update(data, loader_identifier=identifier)
            elif key in data:
                self.obj.set(key, data.get(key), loader_identifier=identifier)

            self.obj.logger.debug(
                "{}_loader: {}: {}".format(
                    self.identifier,
                    env.lower(),
                    list(data.keys()) if "secret" in source_file else data,
                )
            )


# Traceback (AttributeError)
In [1]: from dynaconf import settings

In [2]: settings.POTATO
Out[2]: 'test'

In [3]: settings.get_fresh('POTATO')

In [4]: settings.POTATO
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-22d467a777a4> in <module>
----> 1 settings.POTATO

~/miniconda3/lib/python3.7/site-packages/dynaconf/base.py in __getattr__(self, name)
95             raise AttributeError(
96                 "Attribute %s was deleted, "
---> 97                 "or belongs to different env" % name
98             )
99         if (

AttributeError: Attribute POTATO was deleted, or belongs to different env

# Fixed code
def _read(self, files, envs, silent=True, key=None):
    for source_file in files:
        if source_file.endswith(self.extensions):  # pragma: no cover
            try:
                source_data = self.file_reader(
                    io.open(
                        find_file(
                            source_file,
                            project_root=self.obj.get("PROJECT_ROOT_FOR_DYNACONF"),
                        ),
                        encoding=self.obj.get("ENCODING_FOR_DYNACONF", "utf-8"),
                    )
                )
                self.obj.logger.debug(
                    "{}_loader: {}".format(self.identifier, source_file)
                )
            except IOError:
                self.obj.logger.debug(
                    "{}_loader: {} (Ignored, file not Found)".format(
                        self.identifier, source_file
                    )
                )
                source_data = None
        else:
            # for tests it is possible to pass string
            source_data = self.string_reader(source_file)

        if not source_data:
            continue

        # env name is checked in lower
        source_data = {k.lower(): value for k, value in source_data.items()}

        for env in envs:
            data = {}
            try:
                data = source_data[env.lower()]
            except KeyError:
                if env not in (self.obj.get("GLOBAL_ENV_FOR_DYNACONF"), "GLOBAL"):
                    message = "%s_loader: %s env not defined in %s" % (
                        self.identifier,
                        env,
                        source_file,
                    )
                    if silent:
                        self.obj.logger.warning(message)
                    else:
                        raise KeyError(message)
                continue

            if env != self.obj.get("DEFAULT_ENV_FOR_DYNACONF"):
                identifier = "{0}_{1}".format(self.identifier, env.lower())
            else:
                identifier = self.identifier

            # data 1st level keys should be transformed to upper case.
            data = {k.upper(): v for k, v in data.items()}
            if key:
                key = key.upper()

            if not key:
                self.obj.update(data, loader_identifier=identifier)
            elif key in data:
                self.obj.set(key, data.get(key), loader_identifier=identifier)

            self.obj.logger.debug(
                "{}_loader: {}: {}".format(
                    self.identifier,
                    env.lower(),
                    list(data.keys()) if "secret" in source_file else data,
                )
            )