diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyStringConcatenationToFormatIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyStringConcatenationToFormatIntention.java index 3a646fc1d7ce..c2624aa941fd 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyStringConcatenationToFormatIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyStringConcatenationToFormatIntention.java @@ -140,10 +140,11 @@ public class PyStringConcatenationToFormatIntention extends BaseIntentionAction int paramCount = 0; boolean isUnicode = false; final PyClassTypeImpl unicodeType = PyBuiltinCache.getInstance(element).getObjectType("unicode"); + for (PyExpression expression : getSimpleExpressions((PyBinaryExpression) element)) { if (expression instanceof PyStringLiteralExpression) { final PyType type = context.getType(expression); - if (PyTypeChecker.match(unicodeType, type, context)) { + if (type != null && type.equals(unicodeType)) { isUnicode = true; } if (!quotesDetected) { diff --git a/python/testData/intentions/PyStringConcatenationToFormatIntentionTest/py3Unicode.py b/python/testData/intentions/PyStringConcatenationToFormatIntentionTest/py3Unicode.py new file mode 100644 index 000000000000..e038bae9dc85 --- /dev/null +++ b/python/testData/intentions/PyStringConcatenationToFormatIntentionTest/py3Unicode.py @@ -0,0 +1,2 @@ + +string = "qwer" + "asdf" \ No newline at end of file diff --git a/python/testData/intentions/PyStringConcatenationToFormatIntentionTest/py3Unicode_after.py b/python/testData/intentions/PyStringConcatenationToFormatIntentionTest/py3Unicode_after.py new file mode 100644 index 000000000000..aa3a037f8384 --- /dev/null +++ b/python/testData/intentions/PyStringConcatenationToFormatIntentionTest/py3Unicode_after.py @@ -0,0 +1,2 @@ + +string = "qwerasdf" \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/intentions/PyStringConcatenationToFormatIntentionTest.java b/python/testSrc/com/jetbrains/python/intentions/PyStringConcatenationToFormatIntentionTest.java index a16d15650c3e..39c678e24d06 100644 --- a/python/testSrc/com/jetbrains/python/intentions/PyStringConcatenationToFormatIntentionTest.java +++ b/python/testSrc/com/jetbrains/python/intentions/PyStringConcatenationToFormatIntentionTest.java @@ -73,4 +73,8 @@ public class PyStringConcatenationToFormatIntentionTest extends PyIntentionTestC public void testPy3() { //PY-4706 doTest(PyBundle.message("INTN.replace.plus.with.str.format"), LanguageLevel.PYTHON33); } + + public void testPy3Unicode() { + doTest(PyBundle.message("INTN.replace.plus.with.str.format"), LanguageLevel.PYTHON33); + } } \ No newline at end of file