Migrate to Python 3.x #58
No reviewers
Labels
No labels
ANSIBLE
BUG
CODE
DEVELOPMENT
DOCUMENTATION
FEEDBACK
FIX
HOWTOs
IDEA
INFRA
ISSUE
MAILSERVER
RESEARCH
TESTS
To-Be-Reviewed
WEB
WEBSITE
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Disroot/gpg-lacre#58
Loading…
Reference in a new issue
No description provided.
Delete branch "py3-migration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
bytes
objects properly.Takes care of #54 (adding more tests) and #52 (automatic migration).
@ -102,3 +103,3 @@
# adds a key and ensures it has the given email address
def add_key( keyhome, content ):
p = subprocess.Popen( build_command(keyhome, '--import', '--batch'), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
p = subprocess.Popen( ['/usr/bin/gpg', '--homedir', keyhome, '--import', '--batch'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
Why only this occurence of
build_command
had to be replaced?Thanks, I've just pushed a fix.
@ -342,3 +342,3 @@
if gpg_to != list():
log("Encrypting email to: %s" % ' '.join( map(lambda x: x[0], gpg_to) ))
log("Encrypting email to: %s" % ' '.join( [x[0] for x in gpg_to] ))
Y: Outer brackets aren't necessary. They produce a list, while a generator returned by the expression inside the brackets would be enough.
@ -597,3 +597,3 @@
address = address.lower()
else:
splitted_address = address.split('@')
if isinstance(address, str):
Y: This fragment should be kept outside of this function. To make it more elegant, conversion should take place before calling
sanitize_case_sense
.@ -95,0 +101,4 @@
config.get("relay", "script"),
config.get("relay", "port")]
logging.debug("Spawning relay: '%s'" % (relay_cmd))
Y: Modern Python code uses f-strings and str.format to format strings. Old printf-like approach is considered obsolete.
@ -95,3 +95,3 @@
for to in recipients:
if to in keys.values() and not get_bool_from_cfg('default', 'dec_keymap_only', 'yes'):
if to in list(keys.values()) and not get_bool_from_cfg('default', 'dec_keymap_only', 'yes'):
Y: Converting
dict.values()
to a list isn't necessary.I've added several remarks prefixed with "Y:" -- I've got them from yakub, member of Hackerspace Pomorze.
I'm leaving the point about mixing
str
andbytes
in a single function open. I can't tell which functions call this one withbytes
and which withstr
parameters and finding it out would require a thorough analysis. I'll do that while polishing the code.