SF.net SVN: docutils:[9948 ] trunk/docutils
milde--- via Docutils-checkins <[email protected]>
| Newsgroups | gmane.text.docutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 9948
http://sourceforge.net/p/docutils/code/9948
Author: milde
Date: 2024-10-13 12:40:46 +0000 (Sun, 13 Oct 2024)
Log Message:
-----------
Downgrade "duplicate ID" message from "serious" to "error".
A duplicate ID is not a critical error where the output will
inevitably contain severe errors but rather "a major issue that should
adressed. If ignored, the output will contain unpredictable errors."
(cf. :PEP:`0258` Error Handling).
Re-use `nodes.document.set_id()` in the XML parser, but
only for registering an existing ID, do not generate IDs.
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/docutils_xml.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2024-10-13 12:36:14 UTC (rev 9947)
+++ trunk/docutils/HISTORY.rst 2024-10-13 12:40:46 UTC (rev 9948)
@@ -65,6 +65,7 @@
raise ValueError for invalid attribute names or values.
- New function `parse_measure()`.
- Removed `Element.set_class()`.
+ - Downgrade "duplicate ID" message level from SERIOUS to ERROR.
* docutils/parsers/docutils_xml.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2024-10-13 12:36:14 UTC (rev 9947)
+++ trunk/docutils/docutils/nodes.py 2024-10-13 12:40:46 UTC (rev 9948)
@@ -1869,7 +1869,10 @@
for id in node['ids']:
self.ids.setdefault(id, node)
if self.ids[id] is not node:
- msg = self.reporter.severe('Duplicate ID: "%s".' % id)
+ msg = self.reporter.error(f'Duplicate ID: "{id}" used by '
+ f'{self.ids[id].starttag()} '
+ f'and {node.starttag()}',
+ base_node=node)
if msgnode is not None:
msgnode += msg
return id
Modified: trunk/docutils/docutils/parsers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/parsers/docutils_xml.py 2024-10-13 12:36:14 UTC (rev 9947)
+++ trunk/docutils/docutils/parsers/docutils_xml.py 2024-10-13 12:40:46 UTC (rev 9948)
@@ -151,14 +151,8 @@
if key in node.list_attributes:
value = value.split()
node.attributes[key] = value # node becomes invalid!
- # register ids, check for duplicates
- for id in node['ids']:
- document.ids.setdefault(id, node)
- if document.ids[id] is not node:
- document.reporter.error(f'Duplicate ID: "{id}" used by '
- f'{document.ids[id].starttag()} '
- f'and {node.starttag()}',
- base_node=node)
+ if node['ids']: # register, check for duplicates
+ document.set_id(node)
# Append content:
# update "unindent" flag: change line indentation?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.