Skip to content

UserWarning: NTSerializer does not use custom encoding when serializing to N-Triples #1376

@tcmitchell

Description

@tcmitchell

When I serialize a graph to N-Triples using rdflib 6.0.0, I get the following warning:

.../plugins/serializers/nt.py:28: UserWarning: NTSerializer does not use custom encoding.
warnings.warn("NTSerializer does not use custom encoding.")

I did not get this warning in rdflib 5.0.0, and I am not specifying a custom encoding.

In rdflib 5.0.0:

Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rdflib
RDFLib Version: 5.0.0
>>> g = rdflib.Graph()
>>> g.parse('example3.nt', format='nt')
<Graph identifier=Ned04151a53fa4b9da44a1a3c1880071a (<class 'rdflib.graph.Graph'>)>
>>> out = g.serialize(format='nt')
>>> 

In rdflib 6.0.0:

Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rdflib
RDFLib Version: 6.0.0
>>> g = rdflib.Graph()
>>> g.parse('example3.nt', format='nt')
<Graph identifier=N48d61e6c8ba447a085e7a693015d6a4e (<class 'rdflib.graph.Graph'>)>
>>> out = g.serialize(format='nt')
.../plugins/serializers/nt.py:28: UserWarning: NTSerializer does not use custom encoding.
  warnings.warn("NTSerializer does not use custom encoding.")
>>> 

Source diving tells me that Graph.serialize() now passes 'utf-8' for the encoding when destination and encoding are both set to None (the default).

I did not expect a warning about a custom encoding because I did not specify an encoding, custom or otherwise. This code closely follows the RDF/XML example in the Saving RDF documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions