Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning from docstrings #170

Open
josch opened this issue Jul 1, 2019 · 0 comments
Open

DeprecationWarning from docstrings #170

josch opened this issue Jul 1, 2019 · 0 comments

Comments

@josch
Copy link

josch commented Jul 1, 2019

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])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant