pdfrw
pdfrw copied to clipboard
DeprecationWarning from docstrings
With Python 3.7 I'm getting warnings like:
/usr/lib/python3/dist-packages/pdfrw/objects/pdfstring.py:265: DeprecationWarning: invalid escape sequence \(
The following patch fixes the problem:
--- /usr/lib/python3/dist-packages/pdfrw/objects/pdfstring.py.bak 2019-07-01 10:45:42.857128581 +0200
+++ /usr/lib/python3/dist-packages/pdfrw/objects/pdfstring.py 2019-07-01 10:46:35.325658317 +0200
@@ -117,7 +117,7 @@
in literal strings is to not escape parentheses. This only works, and is
only allowed, when the parentheses are properly balanced. For example,
"((Hello))" is a valid encoding for a literal string, but "((Hello)" is not;
-the latter case should be encoded "(\(Hello)"
+the latter case should be encoded "(\\(Hello)"
Encoding text into strings
==========================
@@ -372,12 +372,12 @@
Possible string escapes from the spec:
(PDF 1.7 Reference, section 3.2.3, page 53)
- 1. \[nrtbf\()]: simple escapes
+ 1. \\[nrtbf\\()]: simple escapes
2. \\d{1,3}: octal. Must be zero-padded to 3 digits
if followed by digit
- 3. \<end of line>: line continuation. We don't know the EOL
+ 3. \\<end of line>: line continuation. We don't know the EOL
marker used in the PDF, so accept \r, \n, and \r\n.
- 4. Any other character following \ escape -- the backslash
+ 4. Any other character following \\ escape -- the backslash
is swallowed.
"""
result = (self.unescape_func or self.init_unescapes())(self[1:-1])