Repository: django/django
File: django/http/request.py (Python)

Code before:
        if not self._upload_handlers:
            # If there are no upload handlers defined, initialize them from
            # settings.
            self._initialize_handlers()
        return self._upload_handlers

    @upload_handlers.setter
    def upload_handlers(self, upload_handlers):
        if hasattr(self, "_files"):
            raise AttributeError(
                "You cannot set the upload handlers after the upload has been "
                "processed."
            )
        self._upload_handlers = upload_handlers

    @property
    def multipart_parser_class(self):
        return self._multipart_parser_class

    @multipart_parser_class.setter
    def multipart_parser_class(self, multipart_parser_class):
        if hasattr(self, "_files"):
            raise AttributeError(
                "You cannot set the multipart parser class after the upload has been "
                "processed."
            )
        self._multipart_parser_class = multipart_parser_class

    def parse_file_upload(self, META, post_data):
        """Return a tuple of (POST QueryDict, FILES MultiValueDict)."""
        self.upload_handlers = ImmutableList(
            self.upload_handlers,
            warning=(
                "You cannot alter upload handlers after the upload has been "
                "processed."
            ),
        )
        parser = self.multipart_parser_class(
            META, post_data, self.upload_handlers, self.encoding
        )
        return parser.parse()

    @property
    def body(self):
        if not hasattr(self, "_body"):
            if self._read_started:
                raise RawPostDataException(
                    "You cannot access body after reading from request's data stream"
                )

            # Limit the maximum request data size that will be handled

Review comment (suggestion):
I'd raise `RuntimeError` since I'm used to `AttributeError` emitted on getting missing attrs, not on setting.

Code after:
        if not self._upload_handlers:
            # If there are no upload handlers defined, initialize them from
            # settings.
            self._initialize_handlers()
        return self._upload_handlers

    @upload_handlers.setter
    def upload_handlers(self, upload_handlers):
        if hasattr(self, "_files"):
            raise AttributeError(
                "You cannot set the upload handlers after the upload has been "
                "processed."
            )
        self._upload_handlers = upload_handlers

    @property
    def multipart_parser_class(self):
        return self._multipart_parser_class

    @multipart_parser_class.setter
    def multipart_parser_class(self, multipart_parser_class):
        if hasattr(self, "_files"):
            raise RuntimeError(
                "You cannot set the multipart parser class after the upload has been "
                "processed."
            )
        self._multipart_parser_class = multipart_parser_class

    def parse_file_upload(self, META, post_data):
        """Return a tuple of (POST QueryDict, FILES MultiValueDict)."""
        self.upload_handlers = ImmutableList(
            self.upload_handlers,
            warning=(
                "You cannot alter upload handlers after the upload has been "
                "processed."
            ),
        )
        parser = self.multipart_parser_class(
            META, post_data, self.upload_handlers, self.encoding
        )
        return parser.parse()

    @property
    def body(self):
        if not hasattr(self, "_body"):
            if self._read_started:
                raise RawPostDataException(
                    "You cannot access body after reading from request's data stream"
                )

            # Limit the maximum request data size that will be handled