-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Open
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The following csvtest.py
script works for Python 3.10 and earlier but fails for 3.11 and later:
import csv
import io
b = io.StringIO()
csv.writer(b, quoting=csv.QUOTE_NONE, lineterminator='\n').writerow(["\r"])
print(repr(b.getvalue()))
For example, running the shell script …
for v in 9 10 11 12 13; do
pyenv shell 3.$v
python --version
python csvtest.py
done
… yields:
Python 3.9.21
'\r\n'
Python 3.10.16
'\r\n'
Python 3.11.11
Traceback (most recent call last):
File "/tmp/csvtest.py", line 4, in <module>
csv.writer(b, quoting=csv.QUOTE_NONE, lineterminator='\n').writerow(["\r"])
_csv.Error: need to escape, but no escapechar set
Python 3.12.8
Traceback (most recent call last):
File "/tmp/csvtest.py", line 4, in <module>
csv.writer(b, quoting=csv.QUOTE_NONE, lineterminator='\n').writerow(["\r"])
_csv.Error: need to escape, but no escapechar set
Python 3.13.1
Traceback (most recent call last):
File "/tmp/csvtest.py", line 4, in <module>
csv.writer(b, quoting=csv.QUOTE_NONE, lineterminator='\n').writerow(["\r"])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
_csv.Error: need to escape, but no escapechar set
As in Python 3.10 and earlier, escaping the carriage return character (\r
) should not be necessary (due to the custom lineterminator
), but Python 3.11+ still expects it.
CPython versions tested on:
3.9, 3.10, 3.11, 3.12, 3.13
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
No status