Ticket #13681: 13681_sagelib.patch

File 13681_sagelib.patch, 22.5 KB (added by jdemeyer, 9 years ago)
  • sage/calculus/calculus.py

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1351972010 -3600
    # Node ID 12f48e5fe23d178a11d305e33a70917bcceaf93d
    # Parent  ac04c0a5230b1925f81c980d54b69319ba1100b3
    Use os.path.join() to construct temporary filenames
    
    diff --git a/sage/calculus/calculus.py b/sage/calculus/calculus.py
    a b  
    13011301        629/8*e^(-4*t) + 91/8*e^(4*t)
    13021302        sage: p1 = plot(xt,0,1/2,rgbcolor=(1,0,0))
    13031303        sage: p2 = plot(yt,0,1/2,rgbcolor=(0,1,0))
    1304         sage: (p1+p2).save(SAGE_TMP + "de_plot.png")
     1304        sage: (p1+p2).save(os.path.join(SAGE_TMP, "de_plot.png"))
    13051305
    13061306    Another example::
    13071307
  • sage/combinat/words/morphism.py

    diff --git a/sage/combinat/words/morphism.py b/sage/combinat/words/morphism.py
    a b  
    563563            <class 'sage.combinat.words.word.FiniteWord_iter_with_caching'>
    564564            sage: w == loads(dumps(w))
    565565            True
    566             sage: save(w, filename=SAGE_TMP + 'test.sobj')
     566            sage: save(w, filename=os.path.join(SAGE_TMP, 'test.sobj'))
    567567
    568568        One may impose the datatype of the resulting word::
    569569
  • sage/geometry/polytope.py

    diff --git a/sage/geometry/polytope.py b/sage/geometry/polytope.py
    a b  
    5050if os.path.exists(path):
    5151    os.environ['PATH'] = '%s:'%path + os.environ['PATH']
    5252
    53 tmp_file = '%s/tmp.poly'%SAGE_TMP
     53tmp_file = os.path.join(SAGE_TMP, 'tmp.poly')
    5454
    5555class Polytope(SageObject):
    5656    """
  • sage/graphs/bipartite_graph.py

    diff --git a/sage/graphs/bipartite_graph.py b/sage/graphs/bipartite_graph.py
    a b  
    202202
    203203    5. From an alist file::
    204204
    205          sage: file_name = SAGE_TMP + 'deleteme.alist.txt'
     205         sage: file_name = os.path.join(SAGE_TMP, 'deleteme.alist.txt')
    206206         sage: fi = open(file_name, 'w')
    207207         sage: fi.write("7 4 \n 3 4 \n 3 3 1 3 1 1 1 \n 3 3 3 4 \n\
    208208                         1 2 4 \n 1 3 4 \n 1 0 0 \n 2 3 4 \n\
     
    903903
    904904        EXAMPLE::
    905905
    906             sage: file_name = SAGE_TMP + 'deleteme.alist.txt'
     906            sage: file_name = os.path.join(SAGE_TMP, 'deleteme.alist.txt')
    907907            sage: fi = open(file_name, 'w')
    908908            sage: fi.write("7 4 \n 3 4 \n 3 3 1 3 1 1 1 \n 3 3 3 4 \n\
    909909                            1 2 4 \n 1 3 4 \n 1 0 0 \n 2 3 4 \n\
     
    999999            [0 1 0 1 0 1 0]
    10001000            [1 1 0 1 0 0 1]
    10011001            sage: b = BipartiteGraph(M)
    1002             sage: file_name = SAGE_TMP + 'deleteme.alist.txt'
     1002            sage: file_name = os.path.join(SAGE_TMP, 'deleteme.alist.txt')
    10031003            sage: b.save_afile(file_name)
    10041004            sage: b2 = BipartiteGraph(file_name)
    10051005            sage: b == b2
     
    10071007
    10081008        TESTS::
    10091009
    1010             sage: file_name = SAGE_TMP + 'deleteme.alist.txt'
     1010            sage: file_name = os.path.join(SAGE_TMP, 'deleteme.alist.txt')
    10111011            sage: for order in range(3, 13, 3):
    10121012            ...       num_chks = int(order / 3)
    10131013            ...       num_vars = order - num_chks
  • sage/gsl/ode.pyx

    diff --git a/sage/gsl/ode.pyx b/sage/gsl/ode.pyx
    a b  
    226226        sage: T.function=f_1
    227227        sage: T.jacobian=j_1
    228228        sage: T.ode_solve(y_0=[1,0],t_span=[0,100],params=[10.0],num_points=1000)
    229         sage: outfile = SAGE_TMP + 'sage.png'
     229        sage: outfile = os.path.join(SAGE_TMP, 'sage.png')
    230230        sage: T.plot_solution(filename=outfile)
    231231       
    232232    The solver line is equivalent to::
     
    316316        sage: vander = van_der_pol()               # not tested
    317317        sage: T.function=vander                    # not tested
    318318        sage: T.ode_solve(y_0 = [1,0], t_span=[0,2000], num_points=1000)   # not tested
    319         sage: T.plot_solution(i=0, filename=SAGE_TMP + '/test.png')        # not tested
     319        sage: T.plot_solution(i=0, filename=os.path.join(SAGE_TMP, 'test.png'))        # not tested
    320320
    321321
    322322    """
  • sage/interfaces/cleaner.py

    diff --git a/sage/interfaces/cleaner.py b/sage/interfaces/cleaner.py
    a b  
    1515import os
    1616
    1717import sage.misc.misc as misc
    18 F = '%s/spawned_processes'%misc.SAGE_TMP
    1918
    2019def cleaner(pid, cmd=''):
    2120    if cmd != '':
    2221        cmd = cmd.strip().split()[0]
    2322    # This is safe, since only this process writes to this file.
     23    F = os.path.join(misc.SAGE_TMP, 'spawned_processes')
    2424    if os.path.exists(F):
    2525        o = open(F,'a')
    2626    else:
    27         if not os.path.exists(misc.SAGE_TMP):
     27        if not os.path.exists(str(misc.SAGE_TMP)):
    2828            return
    2929        o = open(F,'w')
    3030    o.write('%s %s\n'%(pid, cmd))
  • sage/interfaces/expect.py

    diff --git a/sage/interfaces/expect.py b/sage/interfaces/expect.py
    a b  
    7272
    7373failed_to_start = []
    7474
    75 #tmp_expect_interface_local='%s/tmp'%SAGE_TMP_INTERFACE
    76 
    77 #def tmp_expect_interface_local():
    78 #    return '%s/tmp'%SAGE_TMP_INTERFACE + str(os.getpid())
    79 
    80 ## On some platforms, e.g., windows, this can easily take 10 seconds!?!  Terrible.  And
    81 ## it should not be necessary or used anyways.
    82 ## def _absolute(cmd):
    83 ##     c = cmd.split()
    84 ##     s  = c[0]
    85 ##     t = os.popen('which %s'%s).read().strip()
    86 ##     if len(t) == 0:
    87 ##         raise RuntimeError
    88 ##     return ' '.join([t] + c[1:])
    89 
    9075# The subprocess is a shared resource.  In a multi-threaded
    9176# environment, there would have to be a lock to control access to the
    9277# subprocess.  Fortunately, Sage does not use Python threads.
     
    613598        - Simon King (2010-09): Making the tmp-file unique for the interface instance
    614599
    615600        """
    616         #return '%s/tmp'%SAGE_TMP_INTERFACE + str(self.pid())
    617601        try:
    618602            return self.__local_tmpfile
    619603        except AttributeError:
    620             self.__local_tmpfile = '%s/tmp'%SAGE_TMP_INTERFACE + str(self.pid())
     604            self.__local_tmpfile = os.path.join(SAGE_TMP_INTERFACE, 'tmp' + str(self.pid()))
    621605            return self.__local_tmpfile
    622606
    623607    def _remote_tmpdir(self):
  • sage/interfaces/gap.py

    diff --git a/sage/interfaces/gap.py b/sage/interfaces/gap.py
    a b  
    10261026        workspace file contains more than 82 characters) is fixed::
    10271027
    10281028            sage: ORIGINAL_WORKSPACE = sage.interfaces.gap.WORKSPACE
    1029             sage: sage.interfaces.gap.WORKSPACE = SAGE_TMP + "gap" + "0"*(80-len(SAGE_TMP))
     1029            sage: sage.interfaces.gap.WORKSPACE = os.path.join(SAGE_TMP, "gap" + "0"*(80-len(SAGE_TMP)))
    10301030            sage: gap = Gap()
    10311031            sage: gap('3+2')
    10321032            5
  • sage/interfaces/gnuplot.py

    diff --git a/sage/interfaces/gnuplot.py b/sage/interfaces/gnuplot.py
    a b  
    176176
    177177    def interact(self, cmd):
    178178        from sage.misc.all import SAGE_TMP
    179         file= '%s/gnuplot'%SAGE_TMP
     179        file = os.path.join(SAGE_TMP, 'gnuplot')
    180180        open(file, 'w').write(cmd + '\n pause -1 "Press return to continue (no further rotation possible)"')
    181181        os.system('sage-native-execute gnuplot -persist %s'%file)
    182182
  • sage/interfaces/magma.py

    diff --git a/sage/interfaces/magma.py b/sage/interfaces/magma.py
    a b  
    10011001       
    10021002        EXAMPLES::
    10031003       
    1004             sage: open(SAGE_TMP + 'a.m','w').write('function f(n) return n^2; end function;\nprint "hi";')
    1005             sage: print magma.load(SAGE_TMP + 'a.m')      # optional - magma
    1006             Loading ".../.sage//temp/.../a.m"
     1004            sage: filename = os.path.join(SAGE_TMP, 'a.m')
     1005            sage: open(filename, 'w').write('function f(n) return n^2; end function;\nprint "hi";')
     1006            sage: print magma.load(filename)      # optional - magma
     1007            Loading ".../tmp/.../a.m"
    10071008            hi
    10081009            sage: magma('f(12)')       # optional - magma
    10091010            144
  • sage/libs/mwrank/mwrank.pyx

    diff --git a/sage/libs/mwrank/mwrank.pyx b/sage/libs/mwrank/mwrank.pyx
    a b  
    117117
    118118        sage: from sage.libs.mwrank.mwrank import get_precision
    119119        sage: get_precision()
    120         50
    121 
     120        50
    122121    """
    123122    return mwrank_get_precision()
    124123
     
    154153
    155154    EXAMPLES::
    156155
    157         sage: file= SAGE_TMP + '/PRIMES'
     156        sage: file = os.path.join(SAGE_TMP, 'PRIMES')
    158157        sage: open(file,'w').write(' '.join([str(p) for p in prime_range(10^7,10^7+20)]))
    159158        sage: mwrank_initprimes(file, verb=True)
    160159
  • sage/matrix/matrix2.pyx

    diff --git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx
    a b  
    73337333        EXAMPLE::
    73347334       
    73357335            sage: M = random_matrix(CC, 4)
    7336             sage: M.visualize_structure(SAGE_TMP + "matrix.png")
     7336            sage: M.visualize_structure(os.path.join(SAGE_TMP, "matrix.png"))
    73377337        """
    73387338        import gd
    73397339        import os
  • sage/misc/cython.py

    diff --git a/sage/misc/cython.py b/sage/misc/cython.py
    a b  
    373373    # This is the *temporary* directory where we build the pyx file.
    374374    # This is deleted when sage exits, which means pyx files must be
    375375    # rebuilt every time Sage is restarted at present.
    376     build_dir = '%s/%s'%(SPYX_TMP, base)
     376    build_dir = os.path.join(SPYX_TMP, base)
    377377
    378378    if os.path.exists(build_dir):
    379379        # There is already a module here. Maybe we do not have to rebuild?
  • sage/misc/dist.py

    diff --git a/sage/misc/dist.py b/sage/misc/dist.py
    a b  
    7070
    7171    EXAMPLES::
    7272
    73         sage: install_scripts(SAGE_TMP, ignore_existing=True)
     73        sage: install_scripts(str(SAGE_TMP), ignore_existing=True)
    7474        Checking that Sage has the command 'gap' installed
    7575        ...
    7676    """
  • sage/misc/latex.py

    diff --git a/sage/misc/latex.py b/sage/misc/latex.py
    a b  
    21122112    EXAMPLES::
    21132113
    21142114        sage: from sage.misc.latex import png
    2115         sage: png(ZZ[x], SAGE_TMP + "zz.png") # random - error if no latex
     2115        sage: png(ZZ[x], os.path.join(SAGE_TMP, "zz.png")) # random - error if no latex
    21162116    """
    21172117    if not pdflatex:
    21182118        engine = "latex"
  • sage/misc/misc.py

    diff --git a/sage/misc/misc.py b/sage/misc/misc.py
    a b  
    135135
    136136#################################################
    137137# Next we create the Sage temporary directory.
    138 # It is called temp instead of tmp mainly for
    139 # "historical reasons"...
     138#################################################
    140139
    141140SAGE_TMP = os.path.join(DOT_SAGE, 'tmp', HOSTNAME, str(os.getpid()))
    142141sage_makedirs(SAGE_TMP)
    143142
    144 SPYX_TMP = os.path.join(SAGE_TMP, 'spyx/')
     143SPYX_TMP = os.path.join(SAGE_TMP, 'spyx')
    145144
    146 SAGE_TMP_INTERFACE = os.path.join(SAGE_TMP, 'interface/')
     145SAGE_TMP_INTERFACE = os.path.join(SAGE_TMP, 'interface')
    147146sage_makedirs(SAGE_TMP_INTERFACE)
    148147
    149148SAGE_DB = os.path.join(DOT_SAGE, 'db')
  • sage/misc/sageinspect.py

    diff --git a/sage/misc/sageinspect.py b/sage/misc/sageinspect.py
    a b  
    14301430        source_lines = open(filename).readlines()
    14311431    except IOError:
    14321432        try:
    1433             from sage.all import SAGE_TMP
     1433            from sage.misc.misc import SPYX_TMP
    14341434            raw_name = filename.split('/')[-1]
    1435             newname = SAGE_TMP+'/spyx/'+'_'.join(raw_name.split('_')[:-1])+'/'+raw_name
     1435            newname = os.path.join(SPYX_TMP, '_'.join(raw_name.split('_')[:-1]), raw_name)
    14361436            source_lines = open(newname).readlines()
    14371437        except IOError:
    14381438            return None
  • sage/misc/session.pyx

    diff --git a/sage/misc/session.pyx b/sage/misc/session.pyx
    a b  
    1717save your session permanently, since SAGE_TMP will be removed when
    1818leaving Sage!::
    1919
    20     sage: save_session(SAGE_TMP+'session')
     20    sage: save_session(os.path.join(SAGE_TMP, 'session'))
    2121
    2222This saves a dictionary with $w$ as one of the keys::
    2323
    24     sage: z = load(SAGE_TMP+'session')
     24    sage: z = load(os.path.join(SAGE_TMP, 'session'))
    2525    sage: z.keys()
    2626    ['w']
    2727    sage: z['w']
     
    3232    sage: reset()
    3333    sage: show_identifiers()
    3434    []
    35     sage: load_session(SAGE_TMP+'session')
     35    sage: load_session(os.path.join(SAGE_TMP, 'session'))
    3636
    3737Indeed $w$ is now defined again.::
    3838
  • sage/numerical/backends/coin_backend.pyx

    diff --git a/sage/numerical/backends/coin_backend.pyx b/sage/numerical/backends/coin_backend.pyx
    a b  
    10351035            1
    10361036            sage: p.add_linear_constraint([(0, 1), (1, 2)], None, 3)          # optional - Coin
    10371037            sage: p.set_objective([2, 5])                          # optional - Coin
    1038             sage: p.write_mps(SAGE_TMP+"/lp_problem.mps", 0)       # optional - Coin
     1038            sage: p.write_mps(os.path.join(SAGE_TMP, "lp_problem.mps"), 0)       # optional - Coin
    10391039        """
    10401040
    10411041        cdef char * mps = "mps"
     
    10571057            1
    10581058            sage: p.add_linear_constraint([(0, 1), (1, 2)], None, 3)          # optional - Coin
    10591059            sage: p.set_objective([2, 5])                          # optional - Coin
    1060             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp")       # optional - Coin
     1060            sage: p.write_lp(os.path.join(SAGE_TMP, "lp_problem.lp"))       # optional - Coin
    10611061        """
    10621062
    10631063        cdef char * lp = "lp"
  • sage/numerical/backends/cplex_backend.pyx

    diff --git a/sage/numerical/backends/cplex_backend.pyx b/sage/numerical/backends/cplex_backend.pyx
    a b  
    12741274            1
    12751275            sage: p.add_linear_constraint([(0, 1), (1, 2)], None, 3)          # optional - CPLEX
    12761276            sage: p.set_objective([2, 5])                          # optional - CPLEX
    1277             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp")            # optional - CPLEX
     1277            sage: p.write_lp(os.path.join(SAGE_TMP, "lp_problem.lp"))            # optional - CPLEX
    12781278        """
    12791279
    12801280        cdef int status
     
    12981298            1
    12991299            sage: p.add_linear_constraint([(0, 1), (1, 2)], None, 3)          # optional - CPLEX
    13001300            sage: p.set_objective([2, 5])                          # optional - CPLEX
    1301             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp")            # optional - CPLEX
     1301            sage: p.write_lp(os.path.join(SAGE_TMP, "lp_problem.lp"))            # optional - CPLEX
    13021302        """
    13031303
    13041304        cdef int status
  • sage/numerical/backends/generic_backend.pyx

    diff --git a/sage/numerical/backends/generic_backend.pyx b/sage/numerical/backends/generic_backend.pyx
    a b  
    554554            2
    555555            sage: p.add_linear_constraint([(0, 1], (1, 2)], None, 3) # optional - Nonexistent_LP_solver
    556556            sage: p.set_objective([2, 5])                          # optional - Nonexistent_LP_solver
    557             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp")            # optional - Nonexistent_LP_solver
     557            sage: p.write_lp(os.path.join(SAGE_TMP, "lp_problem.lp"))            # optional - Nonexistent_LP_solver
    558558        """
    559559        raise NotImplementedError()
    560560
     
    574574            2
    575575            sage: p.add_linear_constraint([(0, 1), (1, 2)], None, 3) # optional - Nonexistent_LP_solver
    576576            sage: p.set_objective([2, 5])                          # optional - Nonexistent_LP_solver
    577             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp")            # optional - Nonexistent_LP_solver
     577            sage: p.write_lp(os.path.join(SAGE_TMP, "lp_problem.lp"))            # optional - Nonexistent_LP_solver
    578578        """
    579579        raise NotImplementedError()
    580580
  • sage/numerical/backends/glpk_backend.pyx

    diff --git a/sage/numerical/backends/glpk_backend.pyx b/sage/numerical/backends/glpk_backend.pyx
    a b  
    12111211            1
    12121212            sage: p.add_linear_constraint([[0, 1], [1, 2]], None, 3)
    12131213            sage: p.set_objective([2, 5])
    1214             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp")
     1214            sage: p.write_lp(os.path.join(SAGE_TMP, "lp_problem.lp"))
    12151215        """
    12161216        glp_write_lp(self.lp, NULL, filename)
    12171217
     
    12311231            1
    12321232            sage: p.add_linear_constraint([[0, 1], [1, 2]], None, 3)
    12331233            sage: p.set_objective([2, 5])
    1234             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp")
     1234            sage: p.write_lp(os.path.join(SAGE_TMP, "lp_problem.lp"))
    12351235        """
    12361236        glp_write_mps(self.lp, modern, NULL,  filename)
    12371237
  • sage/numerical/backends/gurobi_backend.pyx

    diff --git a/sage/numerical/backends/gurobi_backend.pyx b/sage/numerical/backends/gurobi_backend.pyx
    a b  
    11011101            1
    11021102            sage: p.add_linear_constraint([[0, 1], [1, 2]], None, 3)                # optional - Gurobi
    11031103            sage: p.set_objective([2, 5])                                           # optional - Gurobi
    1104             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp")                             # optional - Gurobi
     1104            sage: p.write_lp(os.path.join(SAGE_TMP, "lp_problem.lp"))               # optional - Gurobi
    11051105        """
    11061106        check(self.env, GRBwrite(self.model[0], filename))
    11071107
     
    11211121            1
    11221122            sage: p.add_linear_constraint([[0, 1], [1, 2]], None, 3)                # optional - Gurobi
    11231123            sage: p.set_objective([2, 5])                                           # optional - Gurobi
    1124             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp")                             # optional - Gurobi
     1124            sage: p.write_lp(os.path.join(SAGE_TMP, "lp_problem.lp"))               # optional - Gurobi
    11251125        """
    11261126        check(self.env, GRBwrite(self.model[0], filename))
    11271127
  • sage/numerical/mip.pyx

    diff --git a/sage/numerical/mip.pyx b/sage/numerical/mip.pyx
    a b  
    724724            sage: x = p.new_variable()
    725725            sage: p.set_objective(x[1] + x[2])
    726726            sage: p.add_constraint(-3*x[1] + 2*x[2], max=2,name="OneConstraint")
    727             sage: p.write_mps(SAGE_TMP+"/lp_problem.mps")
     727            sage: p.write_mps(os.path.join(SAGE_TMP, "lp_problem.mps"))
    728728
    729729        For information about the MPS file format :
    730730        http://en.wikipedia.org/wiki/MPS_%28format%29
     
    749749            sage: x = p.new_variable()
    750750            sage: p.set_objective(x[1] + x[2])
    751751            sage: p.add_constraint(-3*x[1] + 2*x[2], max=2)
    752             sage: p.write_lp(SAGE_TMP+"/lp_problem.lp")
     752            sage: p.write_lp(os.path.join(SAGE_TMP, "lp_problem.lp"))
    753753
    754754        For more information about the LP file format :
    755755        http://lpsolve.sourceforge.net/5.5/lp-format.htm
  • sage/plot/plot3d/base.pyx

    diff --git a/sage/plot/plot3d/base.pyx b/sage/plot/plot3d/base.pyx
    a b  
    10821082        # Tachyon resolution options
    10831083        if DOCTEST_MODE:
    10841084            opts = '-res 10 10'
    1085             filename = sage.misc.misc.SAGE_TMP + "/tmp"
     1085            filename = os.path.join(sage.misc.misc.SAGE_TMP, "tmp")
    10861086        elif EMBEDDED_MODE:
    10871087            opts = '-res %s %s'%(figsize[0]*100, figsize[1]*100)
    10881088            filename = sage.misc.temporary_file.graphics_filename()[:-4]
  • sage/plot/plot3d/tachyon.py

    diff --git a/sage/plot/plot3d/tachyon.py b/sage/plot/plot3d/tachyon.py
    a b  
    314314        import sage.plot.plot
    315315        if sage.plot.plot.DOCTEST_MODE:
    316316            filename = graphics_filename()
    317             self.save(SAGE_TMP + '/test.png', verbose=verbose, extra_opts=extra_opts)
     317            self.save(os.path.join(SAGE_TMP, 'test.png'), verbose=verbose, extra_opts=extra_opts)
    318318            return
    319319        if sage.plot.plot.EMBEDDED_MODE:
    320320            filename = graphics_filename()
  • sage/plot/text.py

    diff --git a/sage/plot/text.py b/sage/plot/text.py
    a b  
    232232
    233233    You can save text as part of PDF output::
    234234
    235         sage: text("sage", (0,0), rgbcolor=(0,0,0)).save(SAGE_TMP + 'a.pdf')
     235        sage: text("sage", (0,0), rgbcolor=(0,0,0)).save(os.path.join(SAGE_TMP, 'a.pdf'))
    236236
    237237    Text must be 2D (use the text3d command for 3D text)::
    238238
  • sage/server/notebook/notebook.py

    diff --git a/sage/server/notebook/notebook.py b/sage/server/notebook/notebook.py
    a b  
    11801180       
    11811181        ::
    11821182
    1183             sage: savefile = SAGE_TMP + 'tmp.sws'
     1183            sage: savefile = os.path.join(SAGE_TMP, 'tmp.sws')
    11841184       
    11851185            sage: nb.export_worksheet(W.filename(),  savefile, verbose=False)
    11861186       
  • sage/structure/sage_object.pyx

    diff --git a/sage/structure/sage_object.pyx b/sage/structure/sage_object.pyx
    a b  
    185185        EXAMPLES::
    186186       
    187187            sage: f = x^3 + 5
    188             sage: f.save(SAGE_TMP + '/file')
    189             sage: load(SAGE_TMP + '/file.sobj')
     188            sage: f.save(os.path.join(SAGE_TMP, 'file'))
     189            sage: load(os.path.join(SAGE_TMP, 'file.sobj'))
    190190            x^3 + 5
    191191        """
    192192        if filename is None:
     
    814814    EXAMPLES::
    815815   
    816816        sage: a = matrix(2, [1,2,3,-5/2])
    817         sage: objfile = SAGE_TMP + 'test.sobj'
    818         sage: objfile_short = SAGE_TMP + 'test'
     817        sage: objfile = os.path.join(SAGE_TMP, 'test.sobj')
     818        sage: objfile_short = os.path.join(SAGE_TMP, 'test')
    819819        sage: save(a, objfile)
    820820        sage: load(objfile_short)
    821821        [   1    2]
     
    823823        sage: E = EllipticCurve([-1,0])
    824824        sage: P = plot(E)
    825825        sage: save(P, objfile_short)   # saves the plot to "test.sobj"
    826         sage: save(P, filename=SAGE_TMP + "sage.png", xmin=-2)
    827         sage: save(P, SAGE_TMP + "filename.with.some.wrong.ext")
     826        sage: save(P, filename=os.path.join(SAGE_TMP, "sage.png"), xmin=-2)
     827        sage: save(P, os.path.join(SAGE_TMP, "filename.with.some.wrong.ext"))
    828828        Traceback (most recent call last):
    829829        ...
    830830        ValueError: allowed file extensions for images are '.eps', '.pdf', '.png', '.ps', '.sobj', '.svg'!
    831831        sage: print load(objfile)
    832832        Graphics object consisting of 2 graphics primitives
    833         sage: save("A python string", SAGE_TMP + 'test')
     833        sage: save("A python string", os.path.join(SAGE_TMP, 'test'))
    834834        sage: load(objfile)
    835835        'A python string'
    836836        sage: load(objfile_short)
     
    840840
    841841    Check that #11577 is fixed::
    842842
    843         sage: filename = SAGE_TMP + "foo.bar" # filename containing a dot
     843        sage: filename = os.path.join(SAGE_TMP, "foo.bar") # filename containing a dot
    844844        sage: save((1,1),filename)            # saves tuple to "foo.bar.sobj"
    845845        sage: load(filename)
    846846        (1, 1)