classification
Title: 2to3 can't find fixes_dir
Type: Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: collinwinter Nosy List: HWJ, barry, benjamin.peterson, bhy, collinwinter, giampaolo.rodola, haypo, loewis, orivej
Priority: release blocker Keywords: patch

Created on 2008-06-17 12:56 by bhy, last changed 2008-08-19 16:09 by benjamin.peterson. This issue is now closed.

Files
File name Uploaded Description Edit
2to3.patch orivej, 2008-06-20 20:07
2to3.patch orivej, 2008-06-20 20:17
Messages (15)
msg68319 - (view) Author: Haoyu Bai (bhy) Date: 2008-06-17 12:55
After install Python 3.0 r64319 on my Linux system, running 2to3 given
the below error:

$ 2to3 hello23.py
Traceback (most recent call last):
  File "/usr/bin/2to3", line 5, in <module>
sys.exit(refactor.main("lib2to3/fixes"))
  File "/usr/lib/python3.0/lib2to3/refactor.py", line 81, in main
rt = RefactoringTool(fixer_dir, options)
  File "/usr/lib/python3.0/lib2to3/refactor.py", line 160, in __init__
self.pre_order, self.post_order = self.get_fixers()
  File "/usr/lib/python3.0/lib2to3/refactor.py", line 180, in get_fixers
fix_names = get_all_fix_names(self.fixer_dir)
  File "/usr/lib/python3.0/lib2to3/refactor.py", line 95, in
get_all_fix_names
names = os.listdir(fixer_dir)
OSError: [Errno 2] No such file or directory: 'lib2to3/fixes'
msg68459 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-06-20 13:24
Collin, how does this look?

#!/usr/bin/env python
from lib2to3 import refactor
import sys
import os

fixers = os.path.join(os.path.dirname(refactor.__file__), "fixes")
sys.exit(refactor.main(fixers))
msg68464 - (view) Author: Helmut Jarausch (HWJ) Date: 2008-06-20 15:31
The suggested fix succeeds but then the next problem occurs

Traceback (most recent call last):
  File "/usr/local/bin/2to3", line 6, in <module>
sys.exit(refactor.main(fixers))
  File "/usr/local/lib/python3.0/lib2to3/refactor.py", line 81, in main
rt = RefactoringTool(fixer_dir, options)
  File "/usr/local/lib/python3.0/lib2to3/refactor.py", line 160, in 
__init__
self.pre_order, self.post_order = self.get_fixers()
  File "/usr/local/lib/python3.0/lib2to3/refactor.py", line 185, in 
get_fixers
mod = __import__(fixer_pkg + ".fix_" + fix_name, {}, {}, ["*"])
ValueError: Empty module name
msg68468 - (view) Author: Georgij Kondratjev (orivej) Date: 2008-06-20 19:53
Do what Benjamin Peterson suggested and also edit get_fixers(self) in
refactor.py so fixer_pkg is initialized like this:

fixer_pkg = os.path.relpath(self.fixer_dir,
os.path.join(os.path.dirname(__file__), '..'))
fixer_pkg = fixer_pkg.replace(os.path.sep, ".")

This works for me.
msg68469 - (view) Author: Georgij Kondratjev (orivej) Date: 2008-06-20 20:07
Here is the patch (against both current svn and beta 1).
msg68471 - (view) Author: Georgij Kondratjev (orivej) Date: 2008-06-20 20:17
After uploading the patch I noticed

-#!/usr/bin/env python
+#!/usr/bin/python3.0

in it.
They just should be dropped.
msg68472 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-06-20 20:28
The patch looks good, but I'm going to let Collin deal with it because
I'm not sure if he wants to maintain backwards compatibility with older
version. (os.path.relpath was introduced in 2.6)
msg68492 - (view) Author: Helmut Jarausch (HWJ) Date: 2008-06-21 09:19
This patch seems to work, but

when invoked it tries to write to /usr/local/lib/python3.0/lib2to3
( I get 
root: Writing failed:[Errno 13] Permission denied: '/usr/local/lib/
python3.0/lib2to3/PatternGrammar3.0.0.beta.1.pickle'
)

I hope this will be handled during install in future.

Furthermore, as a test, I copied refactor.py to xxx.py
and ran 2to3 on xxx.py

Here I get
RefactoringTool: Can't parse xxx.py: ParseError: bad input: type=22, 
value='=', context=('', (67, 71))

This error message is a bit terse for someone not knowing the details
of 2to3

Thanks for the patch,
Helmut.
msg68494 - (view) Author: Georgij Kondratjev (orivej) Date: 2008-06-21 10:40
> when invoked it tries to write to /usr/local/lib/python3.0/lib2to3

2to3 always worked like this. I always had to run it as root. Seems
weird for me too.

> Furthermore, as a test, I copied refactor.py to xxx.py
and ran 2to3 on xxx.py

It seems to be a bug with 2to3 processing refactor.py.
msg69732 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2008-07-16 00:01
I think we'll defer this as a blocker.  It would be good to get 2to3
working right for the betas, but I don't think it should hold up beta2.
msg70553 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-08-01 14:16
Installation of PatternGrammar pickle is now fixed in r65368 and r65369.

HWJ, please don't report multiple problems in a single tracker issue;
instead, create separate tracker issues for independent problems.
msg71011 - (view) Author: Haoyu Bai (bhy) Date: 2008-08-11 10:53
I tried the patch and it works well. Thanks Georgij! So, why the patch
havn't merged into SVN?
msg71191 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-15 23:59
I don't like the patch because it constricts possible fixer dirs. IMO,
refactor.py needs some refactoring its self in order to separate command
line logic from application logic.
msg71220 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2008-08-16 15:36
I reported the same bug with another patch: #3553. I used __import__ 
and module.__file__ attribute (and not realpath).
msg71438 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-19 16:09
Fixed in r65853. Hopefully we can do the real refactoring fix after the
betas.
History
Date User Action Args
2008-08-19 16:09:46benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg71438
2008-08-16 15:36:16hayposetnosy: + haypo
messages: + msg71220
2008-08-15 23:59:08benjamin.petersonsetmessages: + msg71191
2008-08-11 10:53:34bhysetmessages: + msg71011
2008-08-01 14:16:52loewissetnosy: + loewis
messages: + msg70553
2008-07-18 03:46:10barrysetpriority: deferred blocker -> release blocker
2008-07-16 00:01:56barrysetpriority: release blocker -> deferred blocker
nosy: + barry
messages: + msg69732
2008-06-21 12:23:34giampaolo.rodolasetnosy: + giampaolo.rodola
2008-06-21 10:40:20orivejsetmessages: + msg68494
2008-06-21 09:19:24HWJsetmessages: + msg68492
2008-06-20 20:28:56benjamin.petersonsetpriority: release blocker
messages: + msg68472
2008-06-20 20:17:49orivejsetfiles: + 2to3.patch
messages: + msg68471
2008-06-20 20:07:33orivejsetfiles: + 2to3.patch
keywords: + patch
messages: + msg68469
2008-06-20 19:53:21orivejsetnosy: + orivej
messages: + msg68468
2008-06-20 15:31:41HWJsetnosy: + HWJ
messages: + msg68464
2008-06-20 13:24:09benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg68459
2008-06-17 12:56:28bhycreate