summaryrefslogtreecommitdiffstats
path: root/Modules/_csv.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-116738: Make `_csv` module thread-safe (#118344)AN Long2024-10-111-9/+11
|
* gh-124956: Use `#undef` for temp macros in `_csv.c` (#124957)sobolevn2024-10-071-0/+8
|
* gh-123446: Fix empty function names in `TypeError`s in `_csv` module (#123462)sobolevn2024-08-291-3/+3
|
* gh-123446: Fix empty function names in `TypeError`s in `_csv` module (#123461)sobolevn2024-08-291-3/+3
|
* gh-113785: csv: fields starting with escapechar are not quoted (GH-122110)Mikołaj Kuranowski2024-07-251-1/+0
|
* gh-121040: Use __attribute__((fallthrough)) (#121044)Victor Stinner2024-06-271-2/+2
| | | | | | | | | | | | | Fix warnings when using -Wimplicit-fallthrough compiler flag. Annotate explicitly "fall through" switch cases with a new _Py_FALLTHROUGH macro which uses __attribute__((fallthrough)) if available. Replace "fall through" comments with _Py_FALLTHROUGH. Add _Py__has_attribute() macro. No longer define __has_attribute() macro if it's not defined. Move also _Py__has_builtin() at the top of pyport.h. Co-Authored-By: Nikita Sobolev <mail@sobolevn.me>
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-031-0/+1
| | | | | | | | | | | | | | This PR adds the ability to enable the GIL if it was disabled at interpreter startup, and modifies the multi-phase module initialization path to enable the GIL when loading a module, unless that module's spec includes a slot indicating it can run safely without the GIL. PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148. A warning will be issued up to once per interpreter for the first GIL-using module that is loaded. If `-v` is given, a shorter message will be printed to stderr every time a GIL-using module is loaded (including the first one that issues a warning).
* gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438)Serhiy Storchaka2024-03-071-4/+6
|
* gh-67044: Always quote or escape \r and \n in csv.writer() (GH-115741)Serhiy Storchaka2024-02-231-0/+2
|
* gh-115712: Support CSV dialects with delimiter=' ' and skipinitialspace=True ↵Serhiy Storchaka2024-02-201-7/+29
| | | | | | | | (GH-115721) Restore support of such combination, disabled in gh-113796. csv.writer() now quotes empty fields if delimiter is a space and skipinitialspace is true and raises exception if quoting is not possible.
* gh-113732: Fix support of QUOTE_NOTNULL and QUOTE_STRINGS in csv.reader ↵Serhiy Storchaka2024-01-301-17/+29
| | | | (GH-113738)
* gh-113796: Add more validation checks in the csv.Dialect constructor (GH-113797)Serhiy Storchaka2024-01-221-0/+39
| | | ValueError is now raised if the same character is used in different roles.
* gh-114123: Migrate docstring from _csv to csv (#114124)Skip Montanaro2024-01-181-70/+1
| | | | Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Éric <merwok@netwok.org>
* gh-70835: Clarify error message for CSV file opened with wrong newline ↵Serhiy Storchaka2024-01-101-1/+2
| | | | | (GH-113786) Based on patch by SilentGhost.
* gh-111789: Use PyDict_GetItemRef() in Modules/_csv.c (gh-112073)Serhiy Storchaka2023-11-271-8/+2
|
* gh-110964: Remove private _PyArg functions (#110966)Victor Stinner2023-10-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the following private functions and structures to pycore_modsupport.h internal C API: * _PyArg_BadArgument() * _PyArg_CheckPositional() * _PyArg_NoKeywords() * _PyArg_NoPositional() * _PyArg_ParseStack() * _PyArg_ParseStackAndKeywords() * _PyArg_Parser structure * _PyArg_UnpackKeywords() * _PyArg_UnpackKeywordsWithVararg() * _PyArg_UnpackStack() * _Py_ANY_VARARGS() Changes: * Python/getargs.h now includes pycore_modsupport.h to export functions. * clinic.py now adds pycore_modsupport.h when one of these functions is used. * Add pycore_modsupport.h includes when a C extension uses one of these functions. * Define Py_BUILD_CORE_MODULE in C extensions which now include directly or indirectly (via code generated by Argument Clinic) pycore_modsupport.h: * _csv * _curses_panel * _dbm * _gdbm * _multiprocessing.posixshmem * _sqlite.row * _statistics * grp * resource * syslog * _testcapi: bad_get() no longer uses METH_FASTCALL calling convention but METH_VARARGS. Replace _PyArg_UnpackStack() with PyArg_ParseTuple(). * _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined by _testcapi sub-modules which need the internal C API (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c, watchers.c. * Remove Include/cpython/modsupport.h header file. Include/modsupport.h no longer includes the removed header file. * Fix mypy clinic.py
* gh-108444: Replace _PyLong_AsInt() with PyLong_AsInt() (#108459)Victor Stinner2023-08-241-1/+1
| | | | | | Change generated by the command: sed -i -e 's!_PyLong_AsInt!PyLong_AsInt!g' \ $(find -name "*.c" -o -name "*.h")
* gh-106869: Use new PyMemberDef constant names (#106871)Victor Stinner2023-07-251-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove '#include "structmember.h"'. * If needed, add <stddef.h> to get offsetof() function. * Update Parser/asdl_c.py to regenerate Python/Python-ast.c. * Replace: * T_SHORT => Py_T_SHORT * T_INT => Py_T_INT * T_LONG => Py_T_LONG * T_FLOAT => Py_T_FLOAT * T_DOUBLE => Py_T_DOUBLE * T_STRING => Py_T_STRING * T_OBJECT => _Py_T_OBJECT * T_CHAR => Py_T_CHAR * T_BYTE => Py_T_BYTE * T_UBYTE => Py_T_UBYTE * T_USHORT => Py_T_USHORT * T_UINT => Py_T_UINT * T_ULONG => Py_T_ULONG * T_STRING_INPLACE => Py_T_STRING_INPLACE * T_BOOL => Py_T_BOOL * T_OBJECT_EX => Py_T_OBJECT_EX * T_LONGLONG => Py_T_LONGLONG * T_ULONGLONG => Py_T_ULONGLONG * T_PYSSIZET => Py_T_PYSSIZET * T_NONE => _Py_T_NONE * READONLY => Py_READONLY * PY_AUDIT_READ => Py_AUDIT_READ * READ_RESTRICTED => Py_AUDIT_READ * PY_WRITE_RESTRICTED => _Py_WRITE_RESTRICTED * RESTRICTED => (READ_RESTRICTED | _Py_WRITE_RESTRICTED)
* gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)Serhiy Storchaka2023-07-121-1/+1
|
* gh-92536: Remove PyUnicode_READY() calls (#105210)Victor Stinner2023-06-011-12/+0
| | | | Since Python 3.12, PyUnicode_READY() does nothing and always returns 0.
* gh-104265 Disallow instantiation of `_csv.Reader` and `_csv.Writer` (#104266)chgnrdv2023-05-071-2/+2
|
* gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)Eric Snow2023-05-051-0/+1
| | | Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
* gh-67230: add quoting rules to csv module (GH-29469)Skip Montanaro2023-04-121-1/+15
| | | | | | Add two quoting styles for csv dialects. They will help to work with certain databases in particular. Automerge-Triggered-By: GH:merwok
* gh-99300: Use Py_NewRef() in Modules/ directory (#99466)Victor Stinner2022-11-141-6/+3
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in test C files of the Modules/ directory.
* gh-65496: Correct wording on csv's skipinitialspace argument (#96170)Stanley2022-10-071-4/+4
|
* gh-89653: Use int type for Unicode kind (#92704)Victor Stinner2022-05-131-4/+4
| | | | Use the same type that PyUnicode_FromKindAndData() kind parameter type (public C API): int.
* gh-91320: Use _PyCFunction_CAST() (#92251)Victor Stinner2022-05-031-3/+3
| | | | | | | | | | Replace "(PyCFunction)(void(*)(void))func" cast with _PyCFunction_CAST(func). Change generated by the command: sed -i -e \ 's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \ $(find -name "*.c")
* bpo-40676: Use Argument Clinic for csv (where possible) (GH-20200)Shantanu2022-04-161-37/+63
|
* bpo-46541: Remove unnecessary Py_VISIT (GH-31608)Dong-hee Na2022-02-281-1/+0
|
* bpo-46541: Remove usage of _Py_IDENTIFIER from csv module (GH-31372)Dong-hee Na2022-02-161-4/+10
|
* bpo-46613: Add PyType_GetModuleByDef to the public API (GH-31081)Petr Viktorin2022-02-111-1/+1
| | | | | * Make PyType_GetModuleByDef public (remove underscore) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code. It is still used in a number of non-builtin stdlib modules. The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime. A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings). https://bugs.python.org/issue46541#msg411799 explains the rationale for this change. The core of the change is in: * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings. That check is added to the PR CI config. The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()). This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *. The following are not changed (yet): * stop using _Py_IDENTIFIER() in the stdlib modules * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API * (maybe) intern the strings during runtime init https://bugs.python.org/issue46541
* bpo-20028: Empty escapechar/quotechar is not allowed for csv.Dialect (GH-28833)Dong-hee Na2021-10-111-9/+4
|
* bpo-27580: Add support of null characters in the csv module. (GH-28808)Serhiy Storchaka2021-10-091-33/+30
|
* bpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832)Dong-hee Na2021-10-091-0/+6
|
* bpo-20028: Improve error message of csv.Dialect when initializing (GH-28705)Dong-hee Na2021-10-091-8/+38
|
* Fix typos in the Modules directory (GH-28761)Christian Clauss2021-10-071-1/+1
|
* bpo-44630: Fix assertion errors in csv module (GH-27127)T. Wouters2021-07-131-4/+8
| | | | | | | | | | | | | Fix incorrect handling of exceptions when interpreting dialect objects in the csv module. Not clearing exceptions between calls to PyObject_GetAttrString() causes assertion failures in pydebug mode (or with assertions enabled). Add a minimal test that would've caught this (passing None as dialect, or any object that isn't a csv.Dialect subclass, which the csv module allows and caters to, even though it is not documented.) In pydebug mode, the test triggers the assertion failure in the old code. Contributed-By: T. Wouters [Google]
* bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351)Erlend Egeberg Aasland2021-06-171-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Make functools types immutable * Multibyte codec types are now immutable * pyexpat.xmlparser is now immutable * array.arrayiterator is now immutable * _thread types are now immutable * _csv types are now immutable * _queue.SimpleQueue is now immutable * mmap.mmap is now immutable * unicodedata.UCD is now immutable * sqlite3 types are now immutable * _lsprof.Profiler is now immutable * _overlapped.Overlapped is now immutable * _operator types are now immutable * winapi__overlapped.Overlapped is now immutable * _lzma types are now immutable * _bz2 types are now immutable * _dbm.dbm and _gdbm.gdbm are now immutable
* bpo-44116: Add GC support to _csv heap types (GH-26074)Erlend Egeberg Aasland2021-05-121-30/+32
|
* bpo-44089: Allow subclassing of ``csv.Error`` (GH-26008)Ken Jin2021-05-121-1/+1
| | | | | * fix subclass error * Update 2021-05-09-22-52-34.bpo-44089.IoANsN.rst
* bpo-14935: Remove static state from the _csv module (GH-23224)Petr Viktorin2020-12-151-241/+303
| | | | | | | | Uses code from: https://github.com/python/cpython/pull/16078 Co-authored-by: Marcel Plch <gmarcel.plch@gmail.com> Co-authored-by: Eddie Elizondo <eduardo.elizondorueda@gmail.com> Co-authored-by: Hai Shi <shihai1992@gmail.com>
* bpo-12178: Fix escaping of escapechar in csv.writer() (GH-13710)Berker Peksag2020-09-201-0/+3
| | | Co-authored-by: Itay Elbirt <anotahacou@gmail.com>
* bpo-26407: Do not mask errors in csv. (GH-20536)Serhiy Storchaka2020-06-221-8/+8
| | | | | Unexpected errors in calling the __iter__ method are no longer masked by TypeError in csv.reader(), csv.writer.writerow() and csv.writer.writerows().
* Remove usesless function from csv module (GH-20762)Dong-hee Na2020-06-091-8/+2
|
* bpo-40876: Clarify error message in the csv module (GH-20653)Ram Rachum2020-06-051-1/+1
|
* Remove unused ReaderObject_Check macro (#20614)Dong-hee Na2020-06-031-2/+0
|
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-1/+1
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode ↵Serhiy Storchaka2020-04-111-4/+4
| | | | data. (GH-19345)
* bpo-40024: Update C extension modules to use PyModule_AddType() (GH-19119)Dong-hee Na2020-03-241-6/+2
| | | | | | Update _asyncio, _bz2, _csv, _curses, _datetime, _io, _operator, _pickle, _queue, blake2, multibytecodec and overlapped C extension modules to use PyModule_AddType().