View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000011 | Cinelerra-GG | [All Projects] Bug | public | 2018-12-04 05:52 | 2019-01-01 14:39 |
Reporter | ferdnyc | Assigned To | goodguy | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 2018-11 | ||||
Target Version | Fixed in Version | 2018-12 | |||
Summary | 0000011: [PATCH] guicast/bccmdl.py is not Python 3 compatible | ||||
Description | I sent this to [email protected] earlier today, before I'd seen the announcement about the new site. Since it still hasn't posted to the mailing list yet, and since it really more concerns Cinelerra-GG, I thought I'd duplicate it here as well. ========================= The rpmfusion third-party package repository for Fedora Linux is working on packaging the latest Cinelerra-GG for inclusion: https://bugzilla.rpmfusion.org/show_bug.cgi?id=5093 The package reviewer quite correctly flagged the dependency on Python 2 in `guicast/bccmdl.py` as a concern, since Fedora is in the process of deprecating Python 2 entirely and it's highly desirable that all remaining uses of Python throughout the distro have support for Python 3. In the case of `guicast/bccmdl.py`, the only Python 3 incompatibilities were the `print` statements which use deprecated Python 2 semantics. The attached patch updates those all to Python 3 `print()` function form, retaining compatibility with Python 2 via an added instruction at the start of the file: from __future__ import print_function It also updates the Makefile in the `guicast` directory, to invoke the script via `python3 < bccmdl.py` | ||||
Additional Information | The patched bccmdl.py, whether run in Python 2 or Python 3, produces a set of files completely identical to the files output by the unpatched version when executed as python2.7 < bccmdl.py. $ git checkout master Switched to branch 'master' Your branch is up to date with 'origin/master'. $ python2.7 < bccmdl.py; cp -Rp xfer xfer-old $ git checkout bccmdl-py3 $ python3 < bccmdl.py; cp -Rp xfer xfer-newpy3 $ python2.7 < bccmdl.py; cp -Rp xfer xfer-newpy2 $ diff -rq xfer-old xfer-newpy3; echo $? 0 $ diff -rq xfer-old xfer-newpy2; echo $? 0 | ||||
Tags | No tags attached. | ||||
Thank you for the patch! It has been tested here and both the bccmdl.py and Makefile changes have been checked into the GIT repository. We currently use Fedora 29 on our Cinelerra-GG build and test systems. Just upgraded to 29 and got XEN working which makes building for so many different distros a breeze. In checking all of these distros, all but CentOS are at Python 3 now, but it may be that our CentOS system needs an update. BTW: we still have our original CD of the Red Hat Linux 1994 Halloween Release! |
|
I think the problem with the bug tracker was due to our CDN provider Cloudflare, which unfortunately didn't exclude the bug tracker and caused very strange errors. Now it should work. | |
Thanks for pointing that out. I'll look into it. I'll let you know when we've fixed the bug of the bugtracker. ;-) Sorry for the inconvenience. |
|
Er, sorry — that last URL should have been https://www.cinelerra-gg.org/bugtracker/view.php?id=11&nbn=3#bugnotes ...But the first URL is working again now, so problem solved. Thanks again! |
|
Great, thanks. I was going to submit the URL to this report to rpmfusion, so they could track the upstreaming of the patch... but something weird is going on with MantisBT now. The links MantisBT provides to this bug all point to this URL: https://www.cinelerra-gg.org/bugtracker/view.php?id=11 Anytime I try to visit that URL, either by a link or directly, MantisBT seems to think extra-hard for a few seconds, then dumps me back at "My View": https://www.cinelerra-gg.org/bugtracker/my_view_page.php The only way I was able to reach the bug to write this note was by following the link to YOUR previous note, from the link in the "Speech bubble" column of the View Issues view. That link points to this URL, which — unlike the previous one — actually works: https://www.cinelerra-gg.org/bugtracker/view.php?id=8&nbn=2#bugnotes Sorry for the off-topic clutter, can this MantisBT instance also be used to file bugs ABOUT this MantisBT instance? If so and you'd like me to open a new Issue about this, let me know and I'll do that. |
|
I attached your patch to this post so the developers could check it out.
0001-guicast-bccmdl.py-Use-python3.patch (9,162 bytes)
From 068b64ca763f1729078f522916a04190ca5d6635 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" <[email protected]> Date: Mon, 3 Dec 2018 11:09:03 -0500 Subject: [PATCH] guicast/bccmdl.py: Use python3 This change updates the print statements in guicast/bccmdl.py to use Python 3 semantics (with Python 2 compatibility retained via an added __future__ import), and updates the Makefile to run the script using the python3 interpreter. `python3 < bccmdl.py` with this patch applied outputs a set of files identical to those produced by the previous invocation of `python2.7 < bccmdl.py` --- cinelerra-5.1/guicast/Makefile | 2 +- cinelerra-5.1/guicast/bccmdl.py | 108 ++++++++++++++++---------------- 2 files changed, 56 insertions(+), 54 deletions(-) diff --git a/cinelerra-5.1/guicast/Makefile b/cinelerra-5.1/guicast/Makefile index 1c3822f3..15442cfb 100644 --- a/cinelerra-5.1/guicast/Makefile +++ b/cinelerra-5.1/guicast/Makefile @@ -95,7 +95,7 @@ $(shell echo $(OBJS) > $(OBJDIR)/objs) all: $(OUTPUT) $(UTILS) $(BCXFER): bccmdl.py bcxfer.C bcxfer.h - python2.7 < ./bccmdl.py + python3 < ./bccmdl.py +$(MAKE) -C xfer $(OUTPUT): $(OBJS) $(BCXFER) diff --git a/cinelerra-5.1/guicast/bccmdl.py b/cinelerra-5.1/guicast/bccmdl.py index 6b5b9363..1ebb9ca0 100755 --- a/cinelerra-5.1/guicast/bccmdl.py +++ b/cinelerra-5.1/guicast/bccmdl.py @@ -1,5 +1,8 @@ #!/bin/python +# Retain python2 compatibility +from __future__ import print_function + base = { "rgb8": { "i8": { @@ -608,10 +611,10 @@ def is_float(nm): def gen_xfer_proto(fd, pfx, cls, fr_cmdl, to_cmdl): global dtype, ctype - print >>fd, "%svoid %sxfer_%s_to_%s" % (pfx, cls, fr_cmdl[3:], to_cmdl[3:]), + print("%svoid %sxfer_%s_to_%s" % (pfx, cls, fr_cmdl[3:], to_cmdl[3:]), end=' ', file=fd) ityp = dtype[fr_cmdl]; fr_typ = ctype[ityp]; otyp = dtype[to_cmdl]; to_typ = ctype[otyp]; - print >>fd, "(unsigned y0, unsigned y1)", + print("(unsigned y0, unsigned y1)", end=' ', file=fd) def gen_xfer_fn(fd, fr_cmdl, to_cmdl): global layout, dtype, adata @@ -620,7 +623,7 @@ def gen_xfer_fn(fd, fr_cmdl, to_cmdl): # xfr fn header gen_xfer_proto(fd, "", class_qual, fr_cmdl, to_cmdl); # xfr fn body - print >>fd, "{" + print("{", file=fd) # loops / pointer preload in_xfer = "flat" if not is_planar(fr_cmdl) else \ fr_cmdl[3:] if is_yuv(fr_cmdl) else \ @@ -628,52 +631,52 @@ def gen_xfer_fn(fd, fr_cmdl, to_cmdl): out_xfer = "flat" if not is_planar(to_cmdl) else \ to_cmdl[3:] if is_yuv(to_cmdl) else \ "rgbp" if not has_alpha(to_cmdl) else "rgbap" - print >>fd, " xfer_%s_row_out(%s) xfer_%s_row_in(%s)" % \ - (out_xfer, ctype[otyp], in_xfer, ctype[ityp],) + print(" xfer_%s_row_out(%s) xfer_%s_row_in(%s)" % (out_xfer, ctype[otyp], in_xfer, ctype[ityp]), file=fd) + # load inp if( is_float(to_cmdl) and is_yuv(fr_cmdl) ): - for ic in layout[fr_cmdl]: print >>fd, "%s" % (base[ic][ityp]['r']), + for ic in layout[fr_cmdl]: print("%s" % (base[ic][ityp]['r']), end=' ', file=fd) if( ityp == "i8" ): - print >>fd, "\n float r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);", + print("\n float r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);", end=' ', file=fd) elif( ityp == "i16" ): - print >>fd, "\n float r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);", + print("\n float r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);", end=' ', file=fd) if( has_alpha(fr_cmdl) or has_alpha(to_cmdl) ): if( not has_alpha(fr_cmdl) ): - print >>fd, " z_float fa = 1;", + print(" z_float fa = 1;", end=' ', file=fd) elif( ityp == "i8" ): - print >>fd, " float fa = fclp(a,256);", + print(" float fa = fclp(a,256);", end=' ', file=fd) elif( ityp == "i16" ): - print >>fd, " float fa = fclp(a,65536);", + print(" float fa = fclp(a,65536);", end=' ', file=fd) else: - for ic in layout[fr_cmdl]: print >>fd, "%s" % (base[ic][otyp]['r']), + for ic in layout[fr_cmdl]: print("%s" % (base[ic][otyp]['r']), end=' ', file=fd) if( has_alpha(to_cmdl) and not has_alpha(fr_cmdl) ): - print >>fd, "%s" % (adata[otyp]), - print >>fd, "" + print("%s" % (adata[otyp]), end=' ', file=fd) + print("", file=fd) # xfer if( is_rgb(fr_cmdl) and is_yuv(to_cmdl) ): if( otyp == "i8" ): - print >>fd, " int32_t y, u, v; YUV::yuv.rgb_to_yuv_8(r, g, b, y, u, v);" + print(" int32_t y, u, v; YUV::yuv.rgb_to_yuv_8(r, g, b, y, u, v);", file=fd) elif( otyp == "i16" ): - print >>fd, " int32_t y, u, v; YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v);" + print(" int32_t y, u, v; YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v);", file=fd) elif( is_yuv(fr_cmdl) and is_rgb(to_cmdl)): if( otyp == "i8" ): - print >>fd, " int32_t r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);" + print(" int32_t r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);", file=fd) elif( otyp == "i16" ): - print >>fd, " int32_t r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);" + print(" int32_t r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);", file=fd) # blend if( has_bgcolor(fr_cmdl,to_cmdl) ): - print >>fd, "%s" % (base["bbg"][otyp]) + print("%s" % (base["bbg"][otyp]), file=fd) elif( has_alpha(fr_cmdl) and not has_alpha(to_cmdl) ): if( is_rgb(to_cmdl) ): - print >>fd, "%s" % (base["brgb"][otyp]) + print("%s" % (base["brgb"][otyp]), file=fd) elif( is_yuv(to_cmdl) ): - print >>fd, "%s" % (base["byuv"][otyp]) + print("%s" % (base["byuv"][otyp]), file=fd) # store out for oc in layout[to_cmdl]: - print >>fd, "%s" % (base[oc][otyp]['w']), - print >>fd, "xfer_end" - print >>fd, "}" - print >>fd, "" + print("%s" % (base[oc][otyp]['w']), end=' ', file=fd) + print("xfer_end", file=fd) + print("}", file=fd) + print("", file=fd) # output code file class_qual = "BC_Xfer::" @@ -681,9 +684,9 @@ xfn = "xfer/xfer.h" fd = open(xfn, "w") xid = "".join([chr(x) if chr(x).isalnum() else '_' for x in range(256)]) xid = "__" + xfn.upper()[xfn.rfind("/")+1:].translate(xid) + "__" -print >>fd, "#ifndef %s" % xid -print >>fd, "#define %s" % xid -print >>fd, "" +print("#ifndef %s" % xid, file=fd) +print("#define %s" % xid, file=fd) +print("", file=fd) xfd = open("bcxfer.h") fd.write(xfd.read()) xfd.close() @@ -693,57 +696,56 @@ for fr_cmdl in cmodels: for to_cmdl in cmodels: otyp = dtype[to_cmdl] if( is_specialized(fr_cmdl, to_cmdl) ): - print >>fd, " void %s(unsigned y0, unsigned y1);" % (special[(fr_cmdl, to_cmdl)]) + print(" void %s(unsigned y0, unsigned y1);" % (special[(fr_cmdl, to_cmdl)]), file=fd) continue if( ityp is None or otyp is None ): continue gen_xfer_proto(fd, " ", "", fr_cmdl, to_cmdl); - print >>fd, ";" + print(";", file=fd) # end of class definition -print >>fd, "};" -print >>fd, "" -print >>fd, "#endif" +print("};", file=fd) +print("", file=fd) +print("#endif", file=fd) fd.close() xfn = xfn[:xfn.rfind(".h")] # xfer functions for fr_cmdl in cmodels: fd = open(xfn + "_" + fr_cmdl + ".C", "w") - print >>fd, "#include \"xfer.h\"" - print >>fd, "" + print("#include \"xfer.h\"", file=fd) + print("", file=fd) for to_cmdl in cmodels: gen_xfer_fn(fd, fr_cmdl, to_cmdl) fd.close() fd = open(xfn + ".C", "w") # transfer switch -print >>fd, "#include \"xfer.h\"" -print >>fd, "" -print >>fd, "void %sxfer()" % class_qual -print >>fd, "{" +print("#include \"xfer.h\"", file=fd) +print("", file=fd) +print("void %sxfer()" % class_qual, file=fd) +print("{", file=fd) mx_no = mx_bcmdl + 1 -print >>fd, " static xfer_fn xfns[%d][%d] = {" % (mx_no, mx_no) +print(" static xfer_fn xfns[%d][%d] = {" % (mx_no, mx_no), file=fd) for fr_no in range(mx_no): fr_cmdl = bcmodels.get(fr_no) ityp = dtype[fr_cmdl] - print >>fd, " { // %s" % (fr_cmdl.upper() if ityp else "None") + print(" { // %s" % (fr_cmdl.upper() if ityp else "None"), file=fd) n = 0 for to_no in range(mx_no): to_cmdl = bcmodels.get(to_no) otyp = dtype[to_cmdl] xfn = special[(fr_cmdl, to_cmdl)] if( is_specialized(fr_cmdl, to_cmdl) ) else \ "xfer_%s_to_%s" % (fr_cmdl[3:], to_cmdl[3:]) if ( ityp and otyp ) else None - if( n > 72 ): print >>fd, ""; n = 0 - if( n == 0 ): print >>fd, " ",; n += 4 + if( n > 72 ): print("", file=fd); n = 0 + if( n == 0 ): print(" ", end=' ', file=fd); n += 4 fn = "&%s%s" % (class_qual, xfn) if( xfn ) else "0" - print >>fd, "%s, " % (fn), + print("%s, " % (fn), end=' ', file=fd) n += len(fn) + 3 - print >>fd, "}, " -print >>fd, " }; " -print >>fd, " xfn = xfns[in_colormodel][out_colormodel];" -print >>fd, " xfer_slices(out_w*out_h/0x80000+1);" -print >>fd, "}" -print >>fd, "" -print >>fd, "#include \"bcxfer.C\"" -print >>fd, "" + print("}, ", file=fd) +print(" }; ", file=fd) +print(" xfn = xfns[in_colormodel][out_colormodel];", file=fd) +print(" xfer_slices(out_w*out_h/0x80000+1);", file=fd) +print("}", file=fd) +print("", file=fd) +print("#include \"bcxfer.C\"", file=fd) +print("", file=fd) fd.close() - -- 2.19.2 |
|
Sorry, I didn't realize this had created a dupe. My first submit attempt failed because I used an unsupported tag, and when I hit Back to attempt correction (as the error message suggested) I ended up looking at the main landing page again. So, I re-started the submission from scratch. Since the patch never uploaded here, please close as an unintentional duplicate of #12. |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2018-12-04 05:52 | ferdnyc | New Issue | |
2018-12-04 06:02 | ferdnyc | Note Added: 0000021 | |
2018-12-04 06:15 | administrator | File Added: 0001-guicast-bccmdl.py-Use-python3.patch | |
2018-12-04 06:15 | administrator | Note Added: 0000022 | |
2018-12-04 06:28 | ferdnyc | Note Added: 0000024 | |
2018-12-04 06:34 | ferdnyc | Note Added: 0000025 | |
2018-12-04 06:42 | administrator | Note Added: 0000026 | |
2018-12-04 06:44 | administrator | Note Added: 0000027 | |
2018-12-04 12:25 | PhyllisSmith | Assigned To | => goodguy |
2018-12-04 12:25 | PhyllisSmith | Status | new => assigned |
2018-12-04 15:29 | PhyllisSmith | Note Added: 0000032 | |
2018-12-04 15:40 | PhyllisSmith | Status | assigned => resolved |
2018-12-04 15:40 | PhyllisSmith | Resolution | open => fixed |
2018-12-06 20:26 | Sam | Fixed in Version | => 2018-11 |
2018-12-06 20:26 | Sam | Target Version | => 2018-12 |
2018-12-06 20:26 | Sam | Description Updated | View Revisions |
2018-12-06 20:26 | Sam | Additional Information Updated | View Revisions |
2018-12-06 20:28 | Sam | Fixed in Version | 2018-11 => 2018-12 |
2018-12-06 20:43 | Sam | Target Version | 2018-12 => |
2018-12-06 23:57 | Sam | Category | General => Bug-Issue |
2018-12-07 00:00 | Sam | Category | Bug-Issue => Bug |
2019-01-01 14:39 | Sam | Status | resolved => closed |