Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

In the particular case of pyparsing there was a bug in the docstring.

     def sub(self, repl): 
         """ 
         Return Regex with an attached parse action to transform the parsed 
         result as if called using `re.sub(expr, repl, string) 
<https://docs.python.org/3/library/re.html#re.sub>`_. 
  
         Example:: 
  
             make_html = Regex(r"(\w+):(.*?):").sub(r"<\1>\2</\1>") 
             print(make_html.transformString("h1:main title:")) 
             # prints "<h1>main title</h1>" 
        """

\1 and \2 were interpreted as control characters U+0001 and U+0002, so the user 
could see 

        make_html = Regex(r"(\w+):(.*?):").sub(r"<^A>^B</^A>")

or

        make_html = Regex(r"(\w+):(.*?):").sub(r"<☺>☻</☺>")

or

        make_html = Regex(r"(\w+):(.*?):").sub(r"<></>")

depending on the output device.

So this examples proves the usefulness of the new warning.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32912>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to