Dong-hee Na <donghee.n...@gmail.com> added the comment:

Thanks,

my easy patch is worked by pre-checking left paren index. but some edge case 
which I don't expect should be considered.

     if (left_paren_index != -1) {
-        /* Use default error message for any line with an opening paren */
-        return 0;
+       int found_white_space = 0;
+       int found_other_char = 0;
+       Py_ssize_t pos = 0;
+       while(pos != left_paren_index) {
+           int kind = PyUnicode_KIND(self->text);
+           void *data = PyUnicode_DATA(self->text);
+            Py_UCS4 ch = PyUnicode_READ(kind, data, pos);
+           if (Py_UNICODE_ISSPACE(ch)) {
+                found_white_space = 1;
+           }
+           if (!Py_UNICODE_ISSPACE(ch) && found_white_space == 1) {
+                found_other_char = 1;
+           }
+           pos++;
+       }
+
+       if (found_other_char == 0) {
+           return 0;
+       }
     }


Type "help", "copyright", "credits" or "license" for more information.
>>> print (foo.)
  File "<stdin>", line 1
    print (foo.)
               ^
SyntaxError: invalid syntax

>>> print "a".toupper().tolower()
  File "<stdin>", line 1
    print "a".toupper().tolower()
            ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean 
print("a".toupper().tolower())?

SyntaxError: Missing parentheses in call to 'print'. Did you mean 
print(Foo().header(a=foo(1)))?

----------

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

Reply via email to