"unable to coerce endpoint":my problem about build a graph transmitting datas on the USRP

Hi:
Everyone!I’m a beginner.Thank you very much for giving me any
solution to my problem.
I meant to build a graph like this to transmit the binary datas in
my file to the usrp_sink :
gr.file_source–>modulator–>amp–>usrp_sink

The following  is my program:

from gnuradio import gr
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
from optparse import OptionParser

From gr-digital

from gnuradio import digital

from current dir

from uhd_interface import uhd_transmitter

import time, struct, sys

class my_top_block(gr.top_block):
def init(self, modulator, options):
gr.top_block.init(self)

    if(options.tx_freq is not None):
         args = modulator.extract_kwargs_from_options(options)
        symbol_rate = options.bitrate /

modulator(**args).bits_per_symbol()

        self.sink = uhd_transmitter(options.args, symbol_rate,
                                    options.samples_per_symbol,
                                    options.tx_freq,

options.tx_gain,
options.spec, options.antenna,
options.verbose)
options.samples_per_symbol = self.sink._sps

    elif(options.to_file is not None):
        sys.stderr.write(("Saving samples to '%s'.\n\n" %

(options.to_file)))
self.sink = gr.file_sink(gr.sizeof_gr_complex,
options.to_file)
else:
sys.stderr.write(“No sink defined, dumping samples to null
sink.\n\n”)
self.sink = gr.null_sink(gr.sizeof_gr_complex)

    # do this after for any adjustments to the options that may
    # occur in the sinks (specifically the UHD sink)
    self._modulator = modulator
    self.amp = gr.multiply_const_cc(1
    self._pkt_input

=gr.file_source(gr.sizeof_comlpex,“payload.dat”,False
self.connect(self._pkt_input, self._modulator,self.amp,self.sink

/////////////////////////////////////////////////////////////////////////////

main

/////////////////////////////////////////////////////////////////////////////

def main():

mods = digital.modulation_utils.type_1_mods()#选择调制方式# Type 1

modulators accept a stream of bytes on their input and produce complex
baseband output

parser = OptionParser(option_class=eng_option,

conflict_handler=“resolve”)
expert_grp = parser.add_option_group(“Expert”)

parser.add_option("-m", "--modulation", type="choice",

choices=mods.keys(),
default=‘psk’,
help=“Select modulation from: %s
[default=%%default]”
% (’, '.join(mods.keys()),))

parser.add_option("-s", "--size", type="eng_float", default=1500,
                  help="set packet size [default=%default]")
parser.add_option("-M", "--megabytes", type="eng_float",

default=1.0,
help=“set megabytes to transmit
[default=%default]”)
parser.add_option("","–discontinuous", action=“store_true”,
default=False,
help=“enable discontinous transmission (bursts of
5 packets)”)
parser.add_option("","–to-file", default=None,
help=“Output file for modulated samples”)

#transmit_path.add_options(parser, expert_grp)
uhd_transmitter.add_options(parser)

for mod in mods.values():
    mod.add_options(expert_grp)

(options, args) = parser.parse_args ()

if len(args) != 0:
    parser.print_help()
    sys.exit(1)

tb = my_top_block(mods[options.modulation], options)

r = gr.enable_realtime_scheduling()
if r != gr.RT_OK:
    print "Warning: failed to enable realtime scheduling"

tb.start()                       # start flow graph

tb.wait()                       # wait for it to finish

if name == ‘main’:
try:
main()
except KeyboardInterrupt:
pass

It is modified from the gnuradio 3.5.0 version,benchmark_tx.py.
and the error report is:unable to coerce endpoint.

Does anybody can help explain the reason to me or help me solve
it?Thanks again!