Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-12268][PYSPARK] Make pyspark shell pythonstartup work under python3 #10255

Closed
wants to merge 1 commit into from

Conversation

tyro89
Copy link

@tyro89 tyro89 commented Dec 10, 2015

This replaces the execfile used for running custom python shell scripts
with explicit open, compile and exec (as recommended by 2to3). The reason
for this change is to make the pythonstartup option compatible with python3.

This replaces the execfile used for running custom python shell scripts
with explicit open, compile and exec. The reason is to make the
pythonstartup option compatible with python3.
@JoshRosen
Copy link
Contributor

@tyro89
Copy link
Author

tyro89 commented Dec 10, 2015

@tyro89 tyro89 changed the title Make pyspark shell pythonstartup work under python3 [SPARK-12268][PYSPARK] Make pyspark shell pythonstartup work under python3 Dec 10, 2015
@JoshRosen
Copy link
Contributor

Jenkins, this is ok to test.

@SparkQA
Copy link

SparkQA commented Dec 10, 2015

Test build #47542 has finished for PR 10255 at commit 46975aa.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@evanvolgas
Copy link

@JoshRosen Is there anything else missing on this PR or can this get merged?

@JoshRosen
Copy link
Contributor

Jenkins, retest this please.

@JoshRosen
Copy link
Contributor

Sorry for letting this slip through the cracks. Let me manually test this out now and if it looks good I'll merge it into master and branch-1.6.

@@ -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.

@JoshRosen
Copy link
Contributor

I tested this manually on Python 2.6.9, 2.7.10, 3.4.2, and PyPy 2.4.0 and it worked as expected, so I'm going to merge this change into master and branch-1.6. Thanks for working on this!

@evanvolgas
Copy link

Thank you!

asfgit pushed a commit that referenced this pull request Jan 13, 2016
…thon3

This replaces the `execfile` used for running custom python shell scripts
with explicit open, compile and exec (as recommended by 2to3). The reason
for this change is to make the pythonstartup option compatible with python3.

Author: Erik Selin <[email protected]>

Closes #10255 from tyro89/pythonstartup-python3.

(cherry picked from commit e4e0b3f)
Signed-off-by: Josh Rosen <[email protected]>
@asfgit asfgit closed this in e4e0b3f Jan 13, 2016
@SparkQA
Copy link

SparkQA commented Jan 13, 2016

Test build #49328 has finished for PR 10255 at commit 46975aa.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants