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

sage.env: _add_variable_or_fallback depends on the order of a dict #23758

Closed
jhpalmieri opened this issue Aug 30, 2017 · 23 comments
Closed

sage.env: _add_variable_or_fallback depends on the order of a dict #23758

jhpalmieri opened this issue Aug 30, 2017 · 23 comments

Comments

@jhpalmieri
Copy link
Member

In sage/env.py, the function _add_variable_or_fallback does some variable substitution: if a string contains $VAR, it substitutes the value of VAR in the dictionary SAGE_ENV. It does this by iterating through the items of SAGE_ENV, which means that if both VAR and VAR_OTHER are in SAGE_ENV, it's sort of a coin toss as to what happens when it comes across $VAR_OTHER.

(This arose when I was working on #21469: the string $SAGE_SRC_ROOT was being replaced by the value of SAGE_SRC, followed by the string _ROOT.)

CC: @mkoeppe

Component: build

Author: John Palmieri

Branch: 343d685

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/23758

@jhpalmieri jhpalmieri added this to the sage-8.1 milestone Aug 30, 2017
@jhpalmieri
Copy link
Member Author

Branch: u/jhpalmieri/variable_replacement

@jhpalmieri
Copy link
Member Author

New commits:

60927e5trac 23758: in env.py, _add_variable_or_fallback should depend less

@jhpalmieri
Copy link
Member Author

Commit: 60927e5

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2017

Changed commit from 60927e5 to c23cc1c

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

c23cc1ctrac 23758: restore "import os"

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 30, 2017

comment:4

I don't know, maybe we can just get rid of this whole variable substitution business, by using the Python variable SAGE_ROOT instead of "$SAGE_ROOT"?

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 30, 2017

comment:5

(Could be a follow-up ticket.)

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 30, 2017

comment:6

Perhaps add a doctest?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 31, 2017

Changed commit from c23cc1c to 343d685

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 31, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

343d685trac 23758: add a doctest

@jhpalmieri
Copy link
Member Author

comment:8

Here is a doctest. The same test fails for me in the develop branch, but I suppose that failure may not be repeatable on all platforms, since dictionaries are not ordered.

@jhpalmieri
Copy link
Member Author

comment:9

Replying to @mkoeppe:

I don't know, maybe we can just get rid of this whole variable substitution business, by using the Python variable SAGE_ROOT instead of "$SAGE_ROOT"?

I agree, a followup ticket if we want to address this. I'm not sure what the point of the substitution is, compared to using shell variables or some shortcut for accessing SAGE_ENV['foo'].

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 31, 2017

Author: John H. Palmieri

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 31, 2017

Reviewer: Matthias Koeppe

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 31, 2017

comment:11

Follow up ticket is #23762.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 31, 2017

Changed commit from 343d685 to c7cff80

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 31, 2017

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

eb4137btrac 23762: in sage/env.py, get rid of the variable substitution
c7cff80Merge branch 't/23758/variable_replacement' into env

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 31, 2017

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 31, 2017

Changed commit from c7cff80 to 343d685

@jhpalmieri
Copy link
Member Author

comment:14

Sorry, I accidentally pushed a branch here instead of to the appropriate ticket. The positively reviewed branch has been restored.

@vbraun
Copy link
Member

vbraun commented Sep 4, 2017

Changed branch from u/jhpalmieri/variable_replacement to 343d685

@jdemeyer
Copy link

jdemeyer commented Dec 8, 2017

Changed commit from 343d685 to none

@jdemeyer
Copy link

jdemeyer commented Dec 8, 2017

Changed author from John H. Palmieri to John Palmieri

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

No branches or pull requests

4 participants