Skip to content

Commit 20dc99f

Browse files
Fix a number of places where literal backslashes in Python strings should have been escaped (#105)
1 parent 5b58e3a commit 20dc99f

File tree

6 files changed

+59
-54
lines changed

6 files changed

+59
-54
lines changed

changelog.rst

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ Features:
1111

1212
* Fix for broken `MANIFEST.in` that prevented source installation (#101. Thanks: `Dave Hirschfeld`_).
1313

14+
Bug fixes:
15+
----------
16+
17+
* Fix deprecation warnings with stricter backslash escaping in strings. (Thanks: `Benjamin Beasley`_)
18+
1419
1.12.0
1520
======
1621

pgspecial/dbcommands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,7 @@ def describe_one_table_details(cur, schema_name, relation_name, oid, verbose):
18051805
# /* print the number of child tables, if any */
18061806
if cur.rowcount > 0:
18071807
status.append(
1808-
"Number of child tables: %d (Use \d+ to list"
1808+
"Number of child tables: %d (Use \\d+ to list"
18091809
" them.)\n" % cur.rowcount
18101810
)
18111811
else:

pgspecial/iocommands.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@export
2121
def editor_command(command):
2222
"""
23-
Is this an external editor command? (\e or \ev)
23+
Is this an external editor command? (\\e or \\ev)
2424
2525
:param command: string
2626
@@ -47,7 +47,7 @@ def get_filename(sql):
4747

4848
@export
4949
def get_watch_command(command):
50-
match = re.match("(.*?)[\s]*\\\\watch (\d+);?$", command)
50+
match = re.match("(.*?)[\\s]*\\\\watch (\\d+);?$", command)
5151
if match:
5252
groups = match.groups()
5353
return groups[0], int(groups[1])
@@ -188,7 +188,7 @@ def subst_favorite_query_args(query, args):
188188

189189
query = query.replace(subst_var, val)
190190

191-
match = re.search("\\$\d+", query)
191+
match = re.search("\\$\\d+", query)
192192
if match:
193193
return [
194194
None,

pgspecial/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(self):
6666
self.call_pset,
6767
"\\pset",
6868
"\\pset [key] [value]",
69-
"A limited version of traditional \pset",
69+
"A limited version of traditional \\pset",
7070
arg_type=PARSED_QUERY,
7171
)
7272

@@ -151,7 +151,7 @@ def show_command_help(self, pattern, **_):
151151
message += helpcommand["synopsis"]
152152
else:
153153
message = 'No help available for "%s"' % pattern
154-
message += "\nTry \h with no arguments to see available help."
154+
message += "\nTry \\h with no arguments to see available help."
155155

156156
return [(None, None, None, message)]
157157

scripts/docparser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def parse(file_name):
3333
print("Parse postgres SGML reference files into JSON")
3434
print("Usage:")
3535
print(
36-
'echo -n "commands = " > command_help.py; python parser.py ref/ | python -mjson.tool | sed \'s/"\: null/": None/g\' >> command_help.py'
36+
'echo -n "commands = " > command_help.py; python parser.py ref/ | python -mjson.tool | sed \'s/"\\: null/": None/g\' >> command_help.py'
3737
)
3838
print("")
3939
sys.exit(0)

0 commit comments

Comments
 (0)