Author corona10
Recipients corona10, piyushhajare, xtreak
Date 2018-07-01.13:55:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1530453345.03.0.56676864532.issue34013@psf.upfronthosting.co.za>
In-reply-to
Content
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)))?
History
Date User Action Args
2018-07-01 13:55:45corona10setrecipients: + corona10, xtreak, piyushhajare
2018-07-01 13:55:45corona10setmessageid: <1530453345.03.0.56676864532.issue34013@psf.upfronthosting.co.za>
2018-07-01 13:55:45corona10linkissue34013 messages
2018-07-01 13:55:44corona10create