Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python/pyspark/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@
# which allows us to execute the user's PYTHONSTARTUP file:
_pythonstartup = os.environ.get('OLD_PYTHONSTARTUP')
if _pythonstartup and os.path.isfile(_pythonstartup):
execfile(_pythonstartup)
with open(_pythonstartup) as f:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor consequence of this change is that the variable f is now defined in in the REPL, e.g. f will now point to a closed file. We could try to add some fancy logic to prevent this, but it would be equally brittle in the opposite direction. Therefore I'm fine with this change; it's extremely unlikely that user code in the REPL will take conditional actions based on whether f is defined.

code = compile(f.read(), _pythonstartup, 'exec')
exec(code)