Re.compile() and

I am hoping someone can lead a newbie to Python down the righteous path!!

I have a receiver that reads a signal from a gas meter every couple of minutes.
I have code that I got from the supplier but I am unable to make it work. I think the problem is in the ‘re’ module.
I don’t get an error in the re.compile statement (m = re.compile(’.($.)’)) but I do get an error later on.
Here is the part of code I receive error.

while True:
    # Match "$UMBOM"
    line = ser_amr.readline().rstrip()   # read a '\n' terminated line
    now = datetime.datetime.utcnow()
    if ((unix_time(now) - unix_time(last_flush)) > 10.0) and is_open_file(f):
        f.flush() # make sure we flush to disk at least every 10 seconds
        last_flush = now
    if (line != b'') and verbose:
        print (line)
    g =

    g =

TypeError: cannot use a string pattern on a bytes-like object

I am hoping someone can lend a hand.
oh yeah. The code was written in Python 2.x but I am using 3.7
Joe V

It’s hard to pinpoint exactly what’s going on without knowing which line is throwing it, however, based on the TypeError you may need to decode the bytes object to a string object (using .decode()). Here’s a reading that may help.