Skip to content

SWIG signature mismatch at RecordWriter #358

Closed

Description

@raingo

I tried to run the example "tensorflow/g3doc/how_tos/reading_data/convert_to_records.py", but there is an error saying function signature mismatch on the bool WriteRecord(::tensorflow::StringPiece record); call.

My swig version is SWIG Version 1.3.40

A simple fix is to change bool WriteRecord(::tensorflow::StringPiece record); to bool WriteRecord(const string &record); for these two files,

tensorflow/tensorflow/python/lib/io/py_record_writer.h
tensorflow/tensorflow/python/lib/io/py_record_writer.cc

Activity

  1. girving commented on Nov 30, 2015

    @girving
    Contributor

    StringPiece is faster than string in some cases, so we don't want to change the signature in that way. Can you add the full error message? Also, what happens if you change ::tensorflow::StringPiece to just tensorflow::StringPiece (i.e., remove the ::)?

  2. raingo commented on Nov 30, 2015

    @raingo
    ContributorAuthor

    Removing the "::" solves the problem. Thanks!

    As a reference, following is the TypeError with "::".

      File "tensorflow/python/pywrap_tensorflow.py", line 132, in WriteRecord
        def WriteRecord(self, *args): return _pywrap_tensorflow.PyRecordWriter_WriteRecord(self, *args)
    TypeError: in method 'PyRecordWriter_WriteRecord', argument 2 of type '::tensorflow::StringPiece'
    
  3. girving commented on Dec 1, 2015

    @girving
    Contributor

    Thanks, I'll fix this in the code.

  4. added a commit that references this issue on Dec 1, 2015
  5. added and removed on Feb 9, 2017
  6. added a commit that references this issue on Jan 23, 2020
  7. added a commit that references this issue on Oct 4, 2023
  8. added a commit that references this issue on May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions