aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'netlib/utils.py')
-rw-r--r--netlib/utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/netlib/utils.py b/netlib/utils.py
index 09be29d9..dda76808 100644
--- a/netlib/utils.py
+++ b/netlib/utils.py
@@ -414,8 +414,18 @@ def http2_read_raw_frame(rfile):
body = rfile.safe_read(length)
return [header, body]
+
def http2_read_frame(rfile):
header, body = http2_read_raw_frame(rfile)
frame, length = hyperframe.frame.Frame.parse_frame_header(header)
frame.parse_body(memoryview(body))
return frame
+
+
+def safe_subn(pattern, repl, target, *args, **kwargs):
+ """
+ There are Unicode conversion problems with re.subn. We try to smooth
+ that over by casting the pattern and replacement to strings. We really
+ need a better solution that is aware of the actual content ecoding.
+ """
+ return re.subn(str(pattern), str(repl), target, *args, **kwargs)