[issue43692] Raise SyntaxError on implicit string concatentation in list

Carsten Docktor report at bugs.python.org
Thu Apr 1 06:28:05 EDT 2021


New submission from Carsten Docktor <carsten.docktor at gmail.com>:

I recently found several bugs, which came from the "feature" shown below.
Is python supposed to use string concatenation in a list environment like this? Why would this be appreciated?

## Expected Behavior

The example below should raise a SyntaxErorr for a missing comma.
String concatenation in a list should require brackets.

## Current Behavior

Missing commas in a string list lead to unnoticed concatenated strings.


## Steps to Reproduce

```python
my_list = [
  "a",
  "b"
  "c",
  "d"
]
interpreted_list = [
  "a",
  "bc",
  "d",
]
assert my_list == interpreted_list  # unwanted behavior
```

----------
components: Interpreter Core
messages: 389970
nosy: carsten.docktor
priority: normal
severity: normal
status: open
title: Raise SyntaxError on implicit string concatentation in list
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43692>
_______________________________________


More information about the Python-bugs-list mailing list