Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 56dd604

Browse filesBrowse files
committed
Merge pull request #6282 from tacaswell/fix_ps_string_escaping
FIX: use b'' when escaping array as strings in ps
2 parents 44e7356 + 97953f3 commit 56dd604
Copy full SHA for 56dd604

File tree

Expand file treeCollapse file tree

1 file changed

+8
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-7
lines changed

‎lib/matplotlib/backends/backend_ps.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_ps.py
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,16 @@ def _num_to_str(val):
165165
def _nums_to_str(*args):
166166
return ' '.join(map(_num_to_str,args))
167167

168+
168169
def quote_ps_string(s):
169170
"Quote dangerous characters of S for use in a PostScript string constant."
170-
s=s.replace("\\", "\\\\")
171-
s=s.replace("(", "\\(")
172-
s=s.replace(")", "\\)")
173-
s=s.replace("'", "\\251")
174-
s=s.replace("`", "\\301")
175-
s=re.sub(r"[^ -~\n]", lambda x: r"\%03o"%ord(x.group()), s)
176-
return s
171+
s = s.replace(b"\\", b"\\\\")
172+
s = s.replace(b"(", b"\\(")
173+
s = s.replace(b")", b"\\)")
174+
s = s.replace(b"'", b"\\251")
175+
s = s.replace(b"`", b"\\301")
176+
s = re.sub(br"[^ -~\n]", lambda x: br"\%03o" % ord(x.group()), s)
177+
return s.decode('ascii')
177178

178179

179180
def seq_allequal(seq1, seq2):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.