Skip to content

Commit

Permalink
More unicode path fixes (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
Storyyeller committed Jul 17, 2016
1 parent 4a63a02 commit d3d4b42
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Krakatau/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _searchForFile(self, name):
pass

def _loadClass(self, name):
print "Loading", name.encode('utf8')[:70]
print "Loading", name[:70]
data = self._searchForFile(name)

if data is None:
Expand Down
2 changes: 1 addition & 1 deletion Krakatau/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def __init__(self, typen=None, data=""):
self.type = typen
self.data = data

message = u"\n{}: {}".format(typen, data) if typen else unicode(data)
message = "\n{}: {}".format(typen, data) if typen else data
super(ClassLoaderError, self).__init__(message)

class VerificationError(Exception):
Expand Down
2 changes: 1 addition & 1 deletion Krakatau/script_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def findFiles(target, recursive, prefix):
if target.endswith('.jar'):
with zipfile.ZipFile(target, 'r') as archive:
targets = [name for name in archive.namelist() if name.endswith(prefix)]
targets = [name.encode('utf8') for name in archive.namelist() if name.endswith(prefix)]
else:
if recursive:
assert os.path.isdir(target)
Expand Down
8 changes: 4 additions & 4 deletions decompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ def decompileClass(path=[], targets=None, outpath=None, skip_errors=False, add_t
with e, out:
printer = visitor.DefaultVisitor()
for i,target in enumerate(targets):
print 'processing target {}, {} remaining'.format(target.encode('utf8'), len(targets)-i)
print 'processing target {}, {} remaining'.format(target, len(targets)-i)

try:
c = e.getClass(target)
c = e.getClass(target.decode('utf8'))
makeGraphCB = functools.partial(makeGraph, magic_throw)
source = printer.visit(javaclass.generateAST(c, makeGraphCB, skip_errors, add_throws=add_throws))
except Exception as err:
if not skip_errors:
raise
if isinstance(err, ClassLoaderError):
print 'Failed to decompile {} due to missing or invalid class {}'.format(target.encode('utf8'), err.data.encode('utf8'))
print 'Failed to decompile {} due to missing or invalid class {}'.format(target, err.data)
else:
import traceback
print traceback.format_exc()
Expand All @@ -115,7 +115,7 @@ def decompileClass(path=[], targets=None, outpath=None, skip_errors=False, add_t
source = package + source

filename = out.write(c.name.encode('utf8'), source)
print 'Class written to', filename.encode('utf8')
print 'Class written to', filename
print time.time() - start_time, ' seconds elapsed'
deleteUnusued(c)
print len(e.classes) - len(targets), 'extra classes loaded'
Expand Down
6 changes: 3 additions & 3 deletions disassemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def disassembleClass(readTarget, targets=None, outpath=None, roundtrip=False):
start_time = time.time()
with out:
for i, target in enumerate(targets):
print 'processing target {}, {}/{} remaining'.format(target.encode('utf8'), len(targets)-i, len(targets))
print 'processing target {}, {}/{} remaining'.format(target, len(targets)-i, len(targets))

data = readTarget(target)
clsdata = ClassData(Reader(data))
Expand All @@ -29,7 +29,7 @@ def disassembleClass(readTarget, targets=None, outpath=None, roundtrip=False):
Disassembler(clsdata, output.write, roundtrip=roundtrip).disassemble()

filename = out.write(name, output.getvalue())
print 'Class written to', filename.encode('utf8')
print 'Class written to', filename
print time.time() - start_time, ' seconds elapsed'

if __name__== "__main__":
Expand All @@ -54,7 +54,7 @@ def disassembleClass(readTarget, targets=None, outpath=None, roundtrip=False):
if jar:
def readArchive(name):
with zipfile.ZipFile(jar, 'r') as archive:
with archive.open(name) as f:
with archive.open(name.decode('utf8')) as f:
return f.read()
readTarget = readArchive
else:
Expand Down

0 comments on commit d3d4b42

Please sign in to comment.