Bug 232792

Summary: Namespace pollution in all python ports
Product: Ports & Packages Reporter: sgk
Component: Individual Port(s)Assignee: Tobias C. Berner <tcberner>
Status: Closed FIXED    
Severity: Affects Some People CC: dimpase+freebsd, imp, jrm, koobs, linimon, lwhsu, python, tcberner, w.schwarzenfeld
Priority: --- Keywords: needs-qa
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://github.com/python/cpython/pull/12027
https://github.com/python/cpython/pull/12050
Attachments:
Description Flags
patch none

Description sgk 2018-10-29 19:15:51 UTC
Created attachment 198747 [details]
patch

The python languages contain a file named mathmodules.c, which defines a function named sinpi.  sinpi is part of The Floating-point extensions for C - Part 4: Supplementary functions, ISO/IEC TS 18661-4:2015.  For a libm that contains functions for TS-18661-4:2015, there is a conflict between math.h and the locally defined sinpi in mathmodules.c.  The attached patch removes the conflict.
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2018-10-30 03:23:12 UTC
Thank you for your report.

Could you please submit this as an upstream bug (at https://bugs.python.org/) and add the resulting issue URL to this bugs URL field please.
Comment 2 sgk 2018-10-30 17:24:40 UTC
(In reply to Kubilay Kocak from comment #1)
I went to https://bugs.python.org/, but could not find a "Submit Bug Report"
link nor a FAQ on how to submit a bug report.  I've previously sent emails
(with patches) to freebsd-ports@ about this conflict

https://lists.freebsd.org/pipermail/freebsd-ports/2017-June/109093.html
https://lists.freebsd.org/pipermail/freebsd-ports/2017-September/110229.html

Finally, gave up on those emails having any hope.  Having once again
recreated the patch for lang/python36, I decided to submit a (useless?)
bug report.

I will be returning to the code I submitted as bug #218514 to address
a few issues raised by Bruce Evans (bde).  Once I address those issues,
I will seek to have the code committed to libm.  The python ports will
be broken at that time.  I've tried to get patches committed to no 
avail.
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2018-10-30 18:52:06 UTC
(In reply to sgk from comment #2)

> Once I address those issues, I will seek to have the code committed to libm.
> The python ports will be broken at that time.

That's not how things work in a collaborative environment.

I respect the work you do on FreeBSD, but you (or anyone else) don't get to unilaterally break Python.  Remember POLA.
Comment 4 sgk 2018-10-30 19:26:41 UTC
(In reply to Mark Linimon from comment #3)

I have submitted patches multiple times to deal
with python's use of sinpi in mathmodules.c.
See

https://lists.freebsd.org/pipermail/freebsd-ports/2017-June/109093.html
https://lists.freebsd.org/pipermail/freebsd-ports/2017-September/110229.html

and the patch attached to this bug report.  It's been over a
year since I sent the original patch.  How much more collaboration
do you want.  If freebsd-ports@ and freebsd-python@ refuse to
committed my patches and a patch to libm breaks python, then
that's not my problem.
Comment 5 Warner Losh freebsd_committer freebsd_triage 2018-10-30 20:59:37 UTC
Have you tried emailing python@freebsd.org directly? They seem to be in charge of this port. Maybe that would be a better place to start than freebsd-ports@? Certainly wouldn't hurt to reach out to them first before you intentionally break something which will cause a chain reaction of people with hurt feelings which likely won't end well.
Comment 6 Joseph Mingrone freebsd_committer freebsd_triage 2018-10-30 21:30:45 UTC
Once you log in at https://bugs.python.org/ there is a 'Create New' link under 'Issues' in the menu on the left side of the main page.  On the surface, I think I am repeating what Kubilay alluded to: this sounds like a Python issue and not a FreeBSD Python ports issue.
Comment 7 sgk 2018-10-30 21:49:29 UTC
Sigh. Closing.
Comment 8 Joseph Mingrone freebsd_committer freebsd_triage 2018-10-30 21:57:16 UTC
That's not to say that this patch is or isn't appropriate in the short term.  I will re-open until someone from python@ or portmgr@ weighs in, OK?  We don't want to see your contributions wasted, but we just have to be cautious with a big change like this.
Comment 9 bye 2018-10-30 23:07:51 UTC
(In reply to Warner Losh from comment #5)
Coming from the dirty mouth imp man. That is rich. Power trip to the max.
Comment 10 Dima Pasechnik 2019-02-26 11:13:04 UTC
and https://github.com/python/cpython/pull/12050 is the backport to python2.7
Comment 11 Kubilay Kocak freebsd_committer freebsd_triage 2019-02-26 11:25:04 UTC
(In reply to Dima Pasechnik from comment #10)

Thank you!
Comment 12 Antoine Brodin freebsd_committer freebsd_triage 2019-04-12 17:09:44 UTC
It needs to be backported to 3.5 and 3.6 branches too.
Comment 13 Dima Pasechnik 2019-04-12 21:01:12 UTC
Hopefully upstream will do the backport to 3.6, see
https://bugs.python.org/issue36106#msg340110

No word about 3.5 yet.

Anyhow, what exactly is needed here? Patches for Python 2.7, 3.5, 3.6?
Comment 14 commit-hook freebsd_committer freebsd_triage 2019-12-07 19:12:04 UTC
A commit references this bug:

Author: tcberner
Date: Sat Dec  7 19:11:48 UTC 2019
New revision: 519233
URL: https://svnweb.freebsd.org/changeset/ports/519233

Log:
  Fix namespace pollution in python3.5 and python3.6 (upstreamed fix)

  The standard math library (libm) may follow IEEE-754 recommendation to
  include an implementation of sinPi(), i.e. sinPi(x):=sin(pi*x).
  And this triggers a name clash, found by FreeBSD developer
  Steve Kargl, who worked on putting sinpi into libm used on FreeBSD
  (it has to be named "sinpi", not "sinPi", cf. e.g.
  https://en.cppreference.com/w/c/experimental/fpext4).

  - python2.7 and > 3.6 are already fixed

  PR:		232792
  Submitted by:	Steve Kargl <sgk@troutmask.apl.washington.edu>, Dima Pasechnik <dimpase+freebsd@gmail.com>
  Approved by:	python (maintainer timeout)
  Obtained from:	https://github.com/python/cpython/commit/b545ba0a508a5980ab147ed2641a42be3b31a2db

Changes:
  head/lang/python35/Makefile
  head/lang/python35/distinfo
  head/lang/python36/Makefile
  head/lang/python36/distinfo
Comment 15 Tobias C. Berner freebsd_committer freebsd_triage 2019-12-07 19:12:50 UTC
Thanks, committed. 

The other versions (2.7 and >3.6 already ship with the renamed function).
Comment 16 commit-hook freebsd_committer freebsd_triage 2019-12-09 09:24:57 UTC
A commit references this bug:

Author: lwhsu
Date: Mon Dec  9 09:24:15 UTC 2019
New revision: 519597
URL: https://svnweb.freebsd.org/changeset/ports/519597

Log:
  MFH: r519233 r519241 r519244

  Fix namespace pollution in python3.5 and python3.6 (upstreamed fix)

  The standard math library (libm) may follow IEEE-754 recommendation to
  include an implementation of sinPi(), i.e. sinPi(x):=sin(pi*x).
  And this triggers a name clash, found by FreeBSD developer
  Steve Kargl, who worked on putting sinpi into libm used on FreeBSD
  (it has to be named "sinpi", not "sinPi", cf. e.g.
  https://en.cppreference.com/w/c/experimental/fpext4).

  - python2.7 and > 3.6 are already fixed

  PR:		232792
  Submitted by:	Steve Kargl <sgk@troutmask.apl.washington.edu>, Dima Pasechnik <dimpase+freebsd@gmail.com>
  Approved by:	python (maintainer timeout)
  Obtained from:	https://github.com/python/cpython/commit/b545ba0a508a5980ab147ed2641a42be3b31a2db

  Backport fix of https://bugs.python.org/issue32849

  This is needed for starting sysutils/azure-agent at boot:
  https://github.com/Azure/WALinuxAgent/issues/1687

  Obtained from:	https://github.com/python/cpython/pull/12852/commits/f9c01a16dae8aa15d264a1937fb589e8598d1c88
  Sponsored by:	The FreeBSD Foundation

  Fix makefile ordering.

  Reported by:	mat

  Approved by:	ports-secteam (miwi)
  Sponsored by:	The FreeBSD Foundation

Changes:
  branches/2019Q4/lang/python35/Makefile
  branches/2019Q4/lang/python35/distinfo
  branches/2019Q4/lang/python36/Makefile
  branches/2019Q4/lang/python36/distinfo