From: Justin Timmons <justinmtimmons@gmail.com>
To: Syohei YOSHIDA <syohex@gmail.com>
Cc: 24954@debbugs.gnu.org
Subject: bug#24954: [PATCH] Support Python 3
Date: Sat, 10 Dec 2016 17:00:57 -0500 [thread overview]
Message-ID: <87pokzla06.fsf@gmail.com> (raw)
In-Reply-To: <20161116141615.19036-1-syohex@gmail.com> (Syohei YOSHIDA's message of "Wed, 16 Nov 2016 23:16:15 +0900")
[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]
DISCLAIMER: This is my first response to an emacs bug, so apologies in
advance for any mistakes =)
----------------------------------------------------------------------
I applied your patch and found another interoperability issue with
python3 - fixed in the attached patch file. argparse's subparsers have
had an issue from 3.3-3.5+ which doesn't cause a failure when a
subparser is omitted from the program's arguments. See the stackoverflow post here: http://stackoverflow.com/questions/18282403/argparse-with-required-subcommands#answer-18283730.
Running a quick `find` in the directory shows three total python files;
while modhelp was fairly trivial to be made python2/3 compatible, the
other two will require a little more work and some ugly boilerplate
without the use of something like the `six` library (eg. HTTPServer
being moved from BaseHTTPServer to http.server would split the imports
based on python version, among others).
.../emacs/modules/modhelp.py
.../emacs/test/manual/etags/pyt-src/server.py
.../emacs/test/lisp/emacs-lisp/package-resources/package-test-server.py
This raises the question of whether or not these should be converted to be
python2/3 compatible, stay python2, or move to python3 altogether. I
wouldn't be able to answer that, but maybe one of the maintainers could
weigh in on it (I'm not sure who exactly, since there's not much in the maintainer list about python).
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch file to convert modhelp.py to python3 --]
[-- Type: text/x-patch, Size: 2785 bytes --]
diff --git a/modules/modhelp.py b/modules/modhelp.py
index 445cb3b..64b90dd 100755
--- a/modules/modhelp.py
+++ b/modules/modhelp.py
@@ -45,31 +45,31 @@ def cmd_test(args):
failed = []
for m in mods:
- print '[*] %s: ------- start -------' % m
- print '[*] %s: running make' % m
+ print('[*] %s: ------- start -------' % m)
+ print('[*] %s: running make' % m)
r = sp.call(make_cmd, cwd=m)
if r != 0:
- print '[E] %s: make failed' % m
+ print('[E] %s: make failed' % m)
failed += [m]
continue
- print '[*] %s: running test' % m
+ print('[*] %s: running test' % m)
testpath = os.path.join(m, 'test.el')
if os.path.isfile(testpath):
emacs_cmd = [EMACS, '-batch', '-L', '.', '-l', 'ert',
'-l', testpath, '-f', 'ert-run-tests-batch-and-exit']
- print ' '.join(emacs_cmd)
+ print(' '.join(emacs_cmd))
r = sp.call(emacs_cmd)
if r != 0:
- print '[E] %s: test failed' % m
+ print('[E] %s: test failed' % m)
failed += [m]
continue
else:
- print '[W] %s: no test to run' % m
+ print('[W] %s: no test to run' % m)
- print '\n[*] %d/%d MODULES OK' % (len(mods)-len(failed), len(mods))
+ print('\n[*] %d/%d MODULES OK' % (len(mods)-len(failed), len(mods)))
for m in failed:
- print '\tfailed: %s' % m
+ print('\tfailed: %s' % m)
def to_lisp_sym(sym):
sym = re.sub('[_ ]', '-', sym)
@@ -81,7 +81,7 @@ def to_c_sym(sym):
def cmd_init(args):
if os.path.exists(args.module):
- print "%s: file/dir '%s' already exists" % (__file__, args.module)
+ print("%s: file/dir '%s' already exists" % (__file__, args.module))
return
os.mkdir(args.module)
@@ -98,10 +98,10 @@ def cmd_init(args):
if isinstance(path, string.Template):
path = path.substitute(template_vars)
path = os.path.join(args.module, path)
- print "writing %s..." % path
+ print("writing %s..." % path)
with open(path, "w+") as f:
f.write(t.substitute(template_vars))
- print "done! you can run %s test %s" % (__file__, args.module)
+ print("done! you can run %s test %s" % (__file__, args.module))
def main():
@@ -109,7 +109,8 @@ def main():
os.chdir(os.path.dirname(os.path.realpath(__file__)))
mainp = argparse.ArgumentParser()
- subp = mainp.add_subparsers()
+ subp = mainp.add_subparsers(dest='command')
+ subp.required = True
testp = subp.add_parser('test', help='run tests')
testp.add_argument('-f', '--force', action='store_true',
next prev parent reply other threads:[~2016-12-10 22:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 14:16 bug#24954: [PATCH] Support Python 3 Syohei YOSHIDA
2016-12-10 22:00 ` Justin Timmons [this message]
2017-04-04 1:42 ` npostavs
2017-12-03 15:50 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pokzla06.fsf@gmail.com \
--to=justinmtimmons@gmail.com \
--cc=24954@debbugs.gnu.org \
--cc=syohex@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.