Fix keyword-parameter handling bug in formparams.
[wrw.git] / wrw / proto.py
index 4fd26a0..2438c7c 100644 (file)
@@ -1,4 +1,4 @@
-import time, calendar, collections, binascii, base64
+import time, calendar, collections.abc, binascii, base64
 
 statusinfo = {
     400: ("Bad Request", "Invalid HTTP request."),
@@ -6,6 +6,7 @@ statusinfo = {
     403: ("Forbidden", "You are not authorized to request the requested resource."),
     404: ("Not Found", "The requested resource was not found."),
     405: ("Method Not Allowed", "The request method is not recognized or permitted by the requested resource."),
+    429: ("Too Many Requests", "Your client is sending more frequent requests than are accepted."),
     500: ("Server Error", "An internal error occurred."),
     501: ("Not Implemented", "The requested functionality has not been implemented."),
     503: ("Service Unavailable", "Service is being denied at this time."),
@@ -106,7 +107,7 @@ def urlq(url):
     if isinstance(url, str):
         url = url.encode("utf-8")
     ret = ""
-    invalid = b"%;&=#?/\"'"
+    invalid = b"%;&=+#?/\"'"
     for c in url:
         if c in invalid or (c <= 32) or (c >= 128):
             ret += "%%%02X" % c
@@ -209,7 +210,7 @@ def parurl(url, pars={}, **augment):
 def enhex(bs):
     return base64.b16encode(bs).decode("us-ascii")
 def unhex(es):
-    if not isinstance(es, collections.ByteString):
+    if not isinstance(es, collections.abc.ByteString):
         try:
             es = es.encode("us-ascii")
         except UnicodeError:
@@ -218,7 +219,7 @@ def unhex(es):
 def enb32(bs):
     return base64.b32encode(bs).decode("us-ascii")
 def unb32(es):
-    if not isinstance(es, collections.ByteString):
+    if not isinstance(es, collections.abc.ByteString):
         try:
             es = es.encode("us-ascii")
         except UnicodeError:
@@ -230,7 +231,7 @@ def unb32(es):
 def enb64(bs):
     return base64.b64encode(bs).decode("us-ascii")
 def unb64(es):
-    if not isinstance(es, collections.ByteString):
+    if not isinstance(es, collections.abc.ByteString):
         try:
             es = es.encode("us-ascii")
         except UnicodeError: