[0.6a] fileservice.py exception when HOME environment variable does not exist (windows)

Bug #430243 reported by Karel Kolman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
wxBanker
Fix Released
Medium
Michael Rooney

Bug Description

Here's the traceback from a windows system:

Traceback (most recent call last):
  File "C:\Projects\wxbanker\wxbanker\wxbanker.py", line 271, in <module>
    main()
  File "C:\Projects\wxbanker\wxbanker\wxbanker.py", line 259, in main
    app = init()
  File "C:\Projects\wxbanker\wxbanker\wxbanker.py", line 234, in init
    bankController = Controller(path)
  File "C:\Projects\wxbanker\wxbanker\controller.py", line 185, in __init__
    self.InitConfig()
  File "C:\Projects\wxbanker\wxbanker\controller.py", line 209, in InitConfig
    configPath = fileservice.getConfigFilePath(self.CONFIG_NAME)
  File "C:\Projects\wxbanker\wxbanker\fileservice.py", line 51, in getConfigFilePath
    return __getFilePath(filename, xdgListName="xdg_config_dirs")
  File "C:\Projects\wxbanker\wxbanker\fileservice.py", line 41, in __getFilePath
    if not os.path.exists(pathdir):
UnboundLocalError: local variable 'pathdir' referenced before assignment

The pathdir var needs a default value.
Consider using the USERPROFILE environment variable (or the HOMEDRIVE + HOMEPATH pair) on the win32 platform.

Revision history for this message
Michael Rooney (mrooney) wrote :

Thanks for the report! I have a continuous integration server set up at http://wxbanker.ath.cx:8080 which runs the tests on Linux in python 2.5 and 2.6 every night, which should in theory catch things like this, except I don't have a Windows/OSX box. Thanks for reminding me to set up a Windows and OSX VM to start making sure things work there too :)

That traceback confuses me though, how is pathdir unassigned there? I can see where it would crash on finding 'HOME' or something but I don't see a code path that leads to pathdir not having been assigned.

Changed in wxbanker:
assignee: nobody → Michael Rooney (mrooney)
importance: Undecided → Medium
milestone: none → 0.6
status: New → In Progress
Revision history for this message
Karel Kolman (kolmis) wrote :

Well the code says

if xdg:
   pathdir=...
elif "HOME" in os.environ:
   pathdir=...

and if neither of the two if-conditions is satisfied, pathdir will not be assigned
at line 41.

Revision history for this message
Michael Rooney (mrooney) wrote :

Okay, I got the Windows build slave up at http://wxbanker.ath.cx:8080/job/wxbanker-trunk-winxp-py26/ . I fixed this by using APPDATA+"wxbanker" which I think is the optimal place, and fixed 72 tests in the process (it broke almost every test :), but there are still about 30 failures left. Looks like an IO issue with the test db, and a few currency formatting problems. Feel free to check it out and let me know if you have any ideas. Also with the new dateutil dependency which is non-trivial to satisfy on Windows, I think I am going to start supplying a wxbanker.zip which includes dateutil in the folder, so it will just work, for Windows users.

I also am a little mixed on whether, for the paths, I should default to the source directory if it can't find a better option, or raise an exception like it currently does, which should point out situations where I need to find a proper path.

Any opinions on any of those questions? :)

Changed in wxbanker:
status: In Progress → Fix Committed
Michael Rooney (mrooney)
summary: - fileservice.py exception when HOME environment variable does not exist
- (windows)
+ [0.6a] fileservice.py exception when HOME environment variable does not
+ exist (windows)
Revision history for this message
Karel Kolman (kolmis) wrote :

The currency tests are failing because locale definitions can differ on Linux and Windows, i.e. the thousand separator can be an ordinary space ' ' vs u'\xa0' characters or in other words linux Russian locale does not have to be the same as Russian locale on windows.

My opinion on the currency formatting is that number formatting should not be part of the currency definition, the definitions should contain
'currency_symbol'
'int_curr_symbol'
(and maybe 'n_cs_precedes', 'p_cs_precedes')
symbols only and keep the number formatting to the current locale.

The BaseCurrency's constructor would contain one simple statement:
self.LOCALECONV = locale.localeconv()

I'm not sure you'll agree with me, but i think this would simplify things.

Michael Rooney (mrooney)
Changed in wxbanker:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.