classification
Title: Idle: problem confighandler getting userdir
Type: behavior Stage: resolved
Components: IDLE, Windows Versions: Python 3.5, Python 3.4, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Unable to run IDLE without write-access to home directory
View: 8231
Assigned To: Nosy List: serhiy.storchaka, terry.reedy, weizhao
Priority: normal Keywords:

Created on 2013-09-21 15:39 by weizhao, last changed 2014-09-28 00:06 by terry.reedy. This issue is now closed.

Messages (5)
msg198210 - (view) Author: patrick wai (weizhao) Date: 2013-09-21 15:39
#file
idlelib/configHandler.py

#code
userDir = os.path.expanduser('~') 

#os
windows 7 sp1

it doesnt get final userdir path. it doesnt work correctly for userdir . 
this cause python3.3 IDLE GUI can not be opened on my pc . 
as per the docment says as follows:

help(os.path.expanduser)
Help on function expanduser in module ntpath:

expanduser(path)
    Expand ~ and ~user constructs.
    
    If user or $HOME is unknown, do nothing.

help(os.path.expandvars)
Help on function expandvars in module ntpath:

expandvars(path)
    Expand shell variables of the forms $var, ${var} and %var%.
    
    Unknown variables are left unchanged.

the right code may be:

userDir = os.path.expandvars(os.path.expanduser('~'))
msg198211 - (view) Author: patrick wai (weizhao) Date: 2013-09-21 15:57
i am working under non-administrator account .
in fact os.path.expanduser('~') works well when as admin run .
but just got a %userprofile% when as standard account .

On Sat, Sep 21, 2013 at 11:39 PM, patrick wai <report@bugs.python.org>wrote:

>
> New submission from patrick wai:
>
> #file
> idlelib/configHandler.py
>
> #code
> userDir = os.path.expanduser('~')
>
> #os
> windows 7 sp1
>
> it doesnt get final userdir path. it doesnt work correctly for userdir .
> this cause python3.3 IDLE GUI can not be opened on my pc .
> as per the docment says as follows:
>
> help(os.path.expanduser)
> Help on function expanduser in module ntpath:
>
> expanduser(path)
>     Expand ~ and ~user constructs.
>
>     If user or $HOME is unknown, do nothing.
>
> help(os.path.expandvars)
> Help on function expandvars in module ntpath:
>
> expandvars(path)
>     Expand shell variables of the forms $var, ${var} and %var%.
>
>     Unknown variables are left unchanged.
>
> the right code may be:
>
> userDir = os.path.expandvars(os.path.expanduser('~'))
>
> ----------
> components: IDLE
> messages: 198210
> nosy: weizhao
> priority: normal
> severity: normal
> status: open
> title: problems with pyshell to get userdir
> type: behavior
> versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4,
> Python 3.5
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue19062>
> _______________________________________
>
msg226085 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-08-29 21:10
(When responding via email, please delete the quoted test (except possibly for a line or two) as it constitutes noise when viewing the web page.)

On my updated win7, I get with 3.4.1
>>> import os.path
>>> userDir = os.path.expanduser('~')
>>> userDir
'C:\\Users\\Terry'

Contrary to the doc, I do not have HOME, but do have HOMEDRIVE and HOMEPATH, so expanduser must be using those.

configHander now uses os.getcwd() as a backup, but a comment wonders if this is adequate. (On windows not at present, as cwd is the specific version Python directory.)

I do not understand your comment about %userprofile% or 
  userDir = os.path.expandvars(os.path.expanduser('~'))
If expanduser('~') returns '~', expandvars('~') does too.

Please explain with quoted code and the result of running it.
msg227704 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-09-27 18:10
I suppose that on patrick's computeron his account (but not on admin account) HOME is literal "%userprofile%". It looks as just misconfiguration.
msg227742 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-09-28 00:06
The fact that Idle quits when there is a problem getting (or writing to) the home directory is a design bug discussed in #8231.  I do not see any other bug with Idle.  So I am closing this as a duplicate.
History
Date User Action Args
2014-09-28 00:06:14terry.reedysetstatus: open -> closed
superseder: Unable to run IDLE without write-access to home directory
messages: + msg227742

resolution: duplicate
stage: test needed -> resolved
2014-09-27 18:10:30serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg227704
2014-08-29 21:10:15terry.reedysetnosy: + terry.reedy
title: problems with pyshell to get userdir -> Idle: problem confighandler getting userdir
messages: + msg226085

versions: - Python 3.1, Python 3.2, Python 3.3
2014-07-31 18:09:17serhiy.storchakasetcomponents: + Windows
stage: test needed
2013-09-21 15:57:47weizhaosetmessages: + msg198211
2013-09-21 15:39:03weizhaocreate