You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: _csv.Reader and _csv.Writer are named Reader and Writer instead of reader and writer #1259
The types of csv.reader() and csv.writer() objects report themselves as _csv.Reader and _csv.Writer. In CPython they are named _csv.reader and _csv.writer and are only exported under the attributes Reader and Writer.
Operating system
macOS
CPU architecture
ARM64
GraalPy version
master a3009f9 (Python 3.13.14); also reproduced on 25.1.3 (Python 3.12.8)
JDK version
No response
Context configuration
No response
Steps to reproduce
importcsvprint(type(csv.reader([])))
GraalPy master:
<class '_csv.Reader'>
Expected behavior
CPython 3.13.14 (same on 3.12.13):
<class '_csv.reader'>
Stack trace
Additional context
__name__, __qualname__ and repr() of the objects differ the same way, and type(csv.writer(f)) is <class '_csv.Writer'> instead of <class '_csv.writer'>. type(csv.reader([])) is _csv.Reader holds on both.
Root Cause
PythonBuiltinClassType declares CSVReader("Reader", ...) and CSVWriter("Writer", ...) with publishInModule("_csv") (PythonBuiltinClassType.java#L1317-L1318), so one string is both the module attribute and the type name. CPython names the types _csv.reader and _csv.writer (_csv.c#L1055, #L1508) and adds them to the module as Reader and Writer (#L1752-L1762).
Fix Suggestion
Name the types reader and writer with moduleName("_csv") instead of publishInModule("_csv"), which would shadow the reader() and writer() functions, and add the Reader and Writer aliases in CSVModuleBuiltins.initialize (CSVModuleBuiltins.java#L114-L125), as SocketModuleBuiltins does for SocketType.
Activity