BKE_bpath_absolute_convert: basedir='', this is a bug I am getting this error in the terminal after running my script(2.79b). What am I supposed to do?

This is basically my script

import bpy
import os 
import glob 
import time
import tempfile

fname = bpy.path.basename(bpy.context.blend_data.filepath)

 fname = os.path.splitext(filename)[0]

 tempFolder=tempfile.gettempdir()

 finalpath=os.path.join(tempfolder,fname)

 bpy.ops.wm.save_as_mainfile(filepath=finalpath, copy=True)


thanks
You're assigning to fname but then you're using filename in the next line. Same for tempFolder and tempfolder. This runs without error:

import bpy
import os 
import tempfile

filename = bpy.path.basename(bpy.context.blend_data.filepath)
fname = os.path.splitext(filename)[0]
tempfolder = tempfile.gettempdir()
finalpath = os.path.join(tempfolder, fname)
bpy.ops.wm.save_as_mainfile(filepath=finalpath, copy=True)