Modernize code to Python 3.6+ and some cleanup

This commit is contained in:
Miroslav Šedivý
2021-01-31 22:48:38 +01:00
parent 93bb4407fa
commit b69e0c2023
86 changed files with 153 additions and 189 deletions

View File

@@ -18,7 +18,7 @@ public class Expose {
System.out.println("message.secret = " + wasHidden);
}
catch (IllegalAccessException e) {
// this will not happen after setAcessible(true)
// this will not happen after setAccessible(true)
System.err.println(e);
}
}

View File

@@ -3,4 +3,4 @@ import Confidential
message = Confidential('top secret text')
secret_field = Confidential.getDeclaredField('secret')
secret_field.setAccessible(True) # break the lock!
print 'message.secret =', secret_field.get(message)
print('message.secret =', secret_field.get(message))

View File

@@ -7,5 +7,5 @@ for field in fields:
# list private fields only
if Modifier.isPrivate(field.getModifiers()):
field.setAccessible(True) # break the lock
print 'field:', field
print '\t', field.getName(), '=', field.get(message)
print('field:', field)
print('\t', field.getName(), '=', field.get(message))

View File

@@ -1,4 +1,3 @@
"""
In the Jython registry file there is this line:
@@ -14,4 +13,4 @@ message = Confidential('top secret text')
for name in dir(message):
attr = getattr(message, name)
if not callable(attr): # non-methods only
print name + '\t=', attr
print(name + '\t=', attr)