Modify

Ticket #53 (closed enhancement: fixed)

Opened 7 years ago

Last modified 7 years ago

Allow for immutable subclasses of YAMLObject

Reported by: toidinamai Owned by: xi
Priority: normal Component: pyyaml
Severity: trivial Keywords:
Cc:

Description

YAMLObject are not directly instantiated so they don't need their own instance attribute (i.e. an own dict). Because of that they should define an empty slots and let subclasses decide whether they want arbitrary instance attributes or not:

--- lib/yaml/__init__.py        (revision 251)
+++ lib/yaml/__init__.py        (working copy)
@@ -272,6 +272,9 @@
     yaml_tag = None
     yaml_flow_style = None
 
+    # no direct instantiation, so allow for immutable subclasses
+    __slots__ = ()
+
     def from_yaml(cls, loader, node):
         """
         Convert a representation node to a Python object.

The same is basically also true for YAMLObjectMetaclass but I doubt there is much use for this in practice.

Attachments

Change History

comment:1 Changed 7 years ago by xi

  • Status changed from new to closed
  • Resolution set to fixed

Makes sense to me. Applied in [252]. Thanks for the patch.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.