Skip to content

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Aug 20, 2025

The csv.register_dialect() docstring no longer imply that it returns a dialect.
All functions have now signatures.

The csv.register_dialect() docstring no longer imply that it returns a
dialect.
All functions have now signatures.
@serhiy-storchaka serhiy-storchaka added skip news needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 20, 2025
@serhiy-storchaka serhiy-storchaka changed the title gh-137949: Fix and improve the csv functions docstrings gh-137986: Fix and improve the csv functions docstrings Aug 20, 2025
@serhiy-storchaka
Copy link
Member Author

The diff of the pydoc output:

@@ -149,58 +149,45 @@
     field_size_limit(new_limit=<unrepresentable>)
         Sets an upper limit on parsed fields.
 
-            csv.field_size_limit([limit])
-
         Returns old limit. If limit is not given, no new limit is set and
         the old limit is returned
 
     get_dialect(name)
         Return the dialect instance associated with name.
 
-        dialect = csv.get_dialect(name)
-
     list_dialects()
         Return a list of all known dialect names.
 
-        names = csv.list_dialects()
-
-    reader(...)
-        csv_reader = reader(iterable [, dialect='excel']
-                                [optional keyword args])
-            for row in csv_reader:
-                process(row)
+    reader(iterable, /, dialect='excel', **fmtparams)
+        Return a reader object that will process lines from the given iterable.
 
         The "iterable" argument can be any object that returns a line
         of input for each iteration, such as a file object or a list.  The
-        optional "dialect" parameter is discussed below.  The function
+        optional "dialect" argument defines a CSV dialect.  The function
         also accepts optional keyword arguments which override settings
         provided by the dialect.
 
         The returned object is an iterator.  Each iteration returns a row
         of the CSV file (which can span multiple input lines).
 
-    register_dialect(...)
-        Create a mapping from a string name to a dialect class.
-        dialect = csv.register_dialect(name[, dialect[, **fmtparams]])
+    register_dialect(name, /, dialect='excel', **fmtparams)
+        Create a mapping from a string name to a CVS dialect.
+
+        The optional "dialect" argument specifies the base dialect instance
+        or the name of the registered dialect.  The function also accepts
+        optional keyword arguments which override settings provided by the
+        dialect.
 
     unregister_dialect(name)
         Delete the name/dialect mapping associated with a string name.
 
-        csv.unregister_dialect(name)
-
-    writer(...)
-        csv_writer = csv.writer(fileobj [, dialect='excel']
-                                    [optional keyword args])
-            for row in sequence:
-                csv_writer.writerow(row)
-
-            [or]
-
-            csv_writer = csv.writer(fileobj [, dialect='excel']
-                                    [optional keyword args])
-            csv_writer.writerows(rows)
+    writer(fileobj, /, dialect='excel', **fmtparams)
+        Return a writer object that will write user data on the given file object.
 
         The "fileobj" argument can be any object that supports the file API.
+        The optional "dialect" argument defines a CSV dialect.  The function
+        also accepts optional keyword arguments which override settings
+        provided by the dialect.
 

@picnixz
Copy link
Member

picnixz commented Aug 20, 2025

Oh so the other change is part of this PR. Good.

@serhiy-storchaka
Copy link
Member Author

Other changes for writerow() and writerows() methods:

@@ -128,17 +128,15 @@
      |
      |  Methods defined here:
      |
-     |  writerow(self, object, /)
-     |      writerow(iterable)
+     |  writerow(self, row, /)
+     |      Construct and write a CSV record from an iterable of fields.
      |
-     |      Construct and write a CSV record from an iterable of fields.  Non-string
-     |      elements will be converted to string.
+     |      Non-string elements will be converted to string.
      |
-     |  writerows(self, object, /)
-     |      writerows(iterable of iterables)
+     |  writerows(self, rows, /)
+     |      Construct and write a series of iterables to a csv file.
      |
-     |      Construct and write a series of iterables to a csv file.  Non-string
-     |      elements will be converted to string.
+     |      Non-string elements will be converted to string.
      |
      |  ----------------------------------------------------------------------
      |  Data descriptors defined here:

@serhiy-storchaka serhiy-storchaka merged commit aa1dbd4 into python:main Aug 24, 2025
44 checks passed
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@serhiy-storchaka serhiy-storchaka deleted the csv-docstrings branch August 24, 2025 08:13
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 24, 2025
…GH-137987)

The csv.register_dialect() docstring no longer imply that it returns a
dialect.
All functions have now signatures.
(cherry picked from commit aa1dbd4dde32951de2e7438b56d6761001604ee2)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: maurycy <[email protected]>
@miss-islington-app
Copy link

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker aa1dbd4dde32951de2e7438b56d6761001604ee2 3.13

@bedevere-app
Copy link

bedevere-app bot commented Aug 24, 2025

GH-138107 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Aug 24, 2025
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Aug 24, 2025
…ythonGH-137987)

The csv.register_dialect() docstring no longer imply that it returns a
dialect.
All functions have now signatures.
(cherry picked from commit aa1dbd4)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: maurycy <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Aug 24, 2025

GH-138108 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Aug 24, 2025
serhiy-storchaka added a commit that referenced this pull request Aug 24, 2025
…7987) (GH-138108)

The csv.register_dialect() docstring no longer imply that it returns a
dialect.
All functions have now signatures.
(cherry picked from commit aa1dbd4)

Co-authored-by: maurycy <[email protected]>
krisztian-gajdar added a commit to krisztian-gajdar/cpython that referenced this pull request Aug 24, 2025
…tuations

docs: add news entry for TracebackException punctuation fix

style: remove trailing whitespace in traceback.py

Update 2025-08-24-11-42-38.gh-issue-137716.7-Mtj-.rst

Update 2025-08-24-11-42-38.gh-issue-137716.7-Mtj-.rst

refactor: improve suggestion message computation and punctuation handling

style: remove trailing whitespace in traceback.py

pythongh-137986: Fix and improve the csv functions docstrings (pythonGH-137987)

The csv.register_dialect() docstring no longer imply that it returns a
dialect.
All functions have now signatures.

Co-authored-by: maurycy <[email protected]>

pythongh-135261: bring back CI job for testing OpenSSL 1.1.1w (python#135262)

This partially reverts commit d83e30c
by bringing back the CI job for testing OpenSSL 1.1.1w. Despite this
version being upstream EOL, the rationale for keeping it as follows:

- It most resembles other 1.1.1-work-a-like ssl APIs supported by important vendors.
- Python officially requires OpenSSL 1.1.1 or later, although OpenSSL 3.0 or later
  is recommended for cryptographic modules. Since changing the build requirements
  requires a transition period, we need to keep testing the allowed versions.
- The code base still contains calls to OpenSSL functions that are deprecated since
  OpenSSL 3.0 as well as `ifdef` blocks constrained to OpenSSL 1.1.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants