Ticket #10012 (closed: fixed)

Opened 6 years ago

Last modified 5 years ago

System variables in Mantid script interperter become not set.

Reported by: Alex Buts Owned by: Martyn Gigg
Priority: major Milestone: Release 3.2.1
Component: Framework Keywords:
Cc: Blocked By:
Blocking: Tester: Alex Buts

Description

script below

import os
print "file is: ", __file__
print "path is: ", os.path.dirname(os.path.realpath(__file__))

does not work if run from Mantid script interpreter complaining that file is an unknown variable.

It does run though if the script is loaded in the script interpreter and only the row

print "file is: ", __file__ 

or a selection or rows including the one above is executed.

Change History

comment:1 Changed 6 years ago by Martyn Gigg

  • Status changed from new to assigned
  • Keywords PatchCandidate added

comment:2 Changed 6 years ago by Martyn Gigg

  • Status changed from assigned to inprogress

Keep special file variable when clearing Python locals...

in MantidPlot. Refs #10012

Changeset: eb4b296f8b9aef9388106591153b2b09c8d8bb72

comment:3 Changed 6 years ago by Martyn Gigg

  • Status changed from inprogress to verify
  • Resolution set to fixed

Branch: bugfix/10012_maintain_file_var_in_script_window

Tester: Start MantidPlot, open the Python script window and paste in the following code

x = 1
y = 2
print x
print y
print __file__

Execute the code and there should be an error that no __file__ variable is defined. Now save the script to a file somewhere and execute the script. It should now print the location of the file on the last line.

Now comment out the y = 2 line and execute the script, it should stop at the print y line as it should no longer know what y is.

comment:4 Changed 6 years ago by Alex Buts

  • Status changed from verify to verifying
  • Tester set to Alex Buts

comment:5 Changed 6 years ago by Alex Buts

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/bugfix/10012_maintain_file_var_in_script_window'

Full changeset: c43cd8f24563c6196424e52283a93cca9790f3d8

comment:6 Changed 6 years ago by Peter Peterson

  • Keywords PatchCandidate removed
  • Milestone changed from Release 3.3 to Release 3.2.1

comment:7 Changed 6 years ago by Martyn Gigg

Cherry-pick fixes from bugfix/10012_maintain_file_var_in_script_window

into next

Changes:

Keep special file variable when clearing Python locals...

in MantidPlot. Refs #10012 (cherry picked from commit eb4b296f8b9aef9388106591153b2b09c8d8bb72)

Changeset: 0019275fb477a270009e08020fac08e4fdcb806b

comment:8 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 10854

Note: See TracTickets for help on using tickets.