Django

Code

Ticket #3381 (closed: fixed)

Opened 2 years ago

Last modified 10 months ago

[PATCH] make manage.py read PYTHONSTARTUP

Reported by: Baurzhan Ismagulov <ibr@radix50.net> Assigned to: deryck
Milestone: Component: Uncategorized
Version: SVN Keywords: sprintsept14
Cc: ibr@radix50.net, me@andy.durdin.net Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Hello Adrian et al.,

here is the first draft. Is it ok to throw any errors on the user, or should I catch any exceptions?

With kind regards, Baurzhan.

Attachments

trunk-ibr-pystartup-20070128-2331.diff (0.8 kB) - added by Baurzhan Ismagulov <ibr@radix50.net> on 01/28/07 16:36:30.
pythonstartup.diff (1.1 kB) - added by deryck on 09/14/07 17:10:42.
Here is a patch that applies against trunk as of r6230. The patch on #3386 looked better to me, with some modifications to honor both $PYTHONSTARTUP and .pythonrc.py

Change History

01/28/07 16:36:30 changed by Baurzhan Ismagulov <ibr@radix50.net>

  • attachment trunk-ibr-pystartup-20070128-2331.diff added.

01/28/07 17:10:11 changed by adrian

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

Looks pretty good so far! Regarding throwing errors to the user, we should do whatever the standard Python interpreter does.

01/28/07 17:10:20 changed by adrian

  • stage changed from Unreviewed to Accepted.

01/28/07 23:38:57 changed by Michael Radziej <mir@noris.de>

#3386 marked as duplicate

01/29/07 00:44:34 changed by Jeff Bauer <jbauer@rubic.com>

It appears I was posting ticket #3386 shortly after this patch appeared.

Two minor details about my patch.

  1. I think if the user specifies --plain, the PYTHONSTARTUP should be ignored. My rationale is that you could have a user with a difficult-to-debug problem resulting from unanticipated effects of startup code and it would be easy to advise him/her to try to run the shell with --plain. Indeed I found one of my ~/.pythonrc.py startup scripts broke the Django shell. It could be argued this makes the shell behavior more consistent wrt not invoking IPython.
  1. The second difference is to import user unless --plain is specified. This will automatically (and somewhat portably) invoke .pythonrc.py if it's available in the user's home directory.

I'm not lobbying hard for either of my extensions, just presenting my rationale. I'm happy that any patch is being accepted.

09/14/07 16:02:48 changed by adrian

  • keywords set to sprintsept14.

09/14/07 16:50:50 changed by deryck

  • owner changed from nobody to deryck.
  • status changed from new to assigned.

09/14/07 17:10:42 changed by deryck

  • attachment pythonstartup.diff added.

Here is a patch that applies against trunk as of r6230. The patch on #3386 looked better to me, with some modifications to honor both $PYTHONSTARTUP and .pythonrc.py

09/14/07 17:11:18 changed by deryck

  • stage changed from Accepted to Ready for checkin.

09/14/07 17:16:14 changed by jacob

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [6231]) Fixed #3381 - manage.py shell now respects PYTHONSTARTUP/.pythonrc.py.

01/23/08 11:48:17 changed by anonymous

  • cc changed from ibr@radix50.net to ibr@radix50.net, me@andy.durdin.net.

Add/Change #3381 ([PATCH] make manage.py read PYTHONSTARTUP)




Change Properties
Action