This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/master by this push:
     new 6647091  Use constant for repeated string
6647091 is described below

commit 664709109107656f51834c90b2ac77f65a7794d6
Author: Sebb <[email protected]>
AuthorDate: Sun May 9 14:50:44 2021 +0100

    Use constant for repeated string
---
 server/plugins/formdata.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/server/plugins/formdata.py b/server/plugins/formdata.py
index 6e6b943..71cb8fa 100644
--- a/server/plugins/formdata.py
+++ b/server/plugins/formdata.py
@@ -6,6 +6,7 @@ import aiohttp.web
 import multipart
 
 PYPONY_MAX_PAYLOAD = 256 * 1024
+ERRONEOUS_PAYLOAD = "Erroneous payload received"
 
 
 async def parse_formdata(body_type, request: aiohttp.web.BaseRequest) -> dict:
@@ -30,7 +31,7 @@ async def parse_formdata(body_type, request: 
aiohttp.web.BaseRequest) -> dict:
                         )  # json data MUST be an dictionary object, {...}
                         indata.update(js)
                     except ValueError:
-                        raise ValueError("Erroneous payload received")
+                        raise ValueError(ERRONEOUS_PAYLOAD)
                 elif body_type == "form":
                     if (
                         request.headers.get("content-type", "").lower()
@@ -40,7 +41,7 @@ async def parse_formdata(body_type, request: 
aiohttp.web.BaseRequest) -> dict:
                             for key, val in urllib.parse.parse_qsl(body):
                                 indata[key] = val
                         except ValueError:
-                            raise ValueError("Erroneous payload received")
+                            raise ValueError(ERRONEOUS_PAYLOAD)
                     # If multipart, turn our body into a BytesIO object and 
use multipart on it
                     elif (
                         "multipart/form-data"
@@ -59,7 +60,7 @@ async def parse_formdata(body_type, request: 
aiohttp.web.BaseRequest) -> dict:
                                     ):
                                         indata[part.name] = part.value
                                 except ValueError:
-                                    raise ValueError("Erroneous payload 
received")
+                                    raise ValueError(ERRONEOUS_PAYLOAD)
             finally:
                 pass
     return indata

Reply via email to