Skip to content

Commit 8642de0

Browse files
authored
Update OSS licensing (#1973)
Added license information for: - _queue from Python Software Foundation - _functools from Python Software Foundation - Two small functions from Werkzeug Reformatted license for - Profiler from Nylas.
1 parent 665ab60 commit 8642de0

File tree

5 files changed

+239
-60
lines changed

5 files changed

+239
-60
lines changed

sentry_sdk/_functools.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,61 @@
11
"""
22
A backport of Python 3 functools to Python 2/3. The only important change
33
we rely upon is that `update_wrapper` handles AttributeError gracefully.
4+
5+
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
6+
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
7+
8+
All Rights Reserved
9+
10+
11+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
12+
--------------------------------------------
13+
14+
1. This LICENSE AGREEMENT is between the Python Software Foundation
15+
("PSF"), and the Individual or Organization ("Licensee") accessing and
16+
otherwise using this software ("Python") in source or binary form and
17+
its associated documentation.
18+
19+
2. Subject to the terms and conditions of this License Agreement, PSF hereby
20+
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
21+
analyze, test, perform and/or display publicly, prepare derivative works,
22+
distribute, and otherwise use Python alone or in any derivative version,
23+
provided, however, that PSF's License Agreement and PSF's notice of copyright,
24+
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
25+
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
26+
All Rights Reserved" are retained in Python alone or in any derivative version
27+
prepared by Licensee.
28+
29+
3. In the event Licensee prepares a derivative work that is based on
30+
or incorporates Python or any part thereof, and wants to make
31+
the derivative work available to others as provided herein, then
32+
Licensee hereby agrees to include in any such work a brief summary of
33+
the changes made to Python.
34+
35+
4. PSF is making Python available to Licensee on an "AS IS"
36+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
37+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
38+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
39+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
40+
INFRINGE ANY THIRD PARTY RIGHTS.
41+
42+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
43+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
44+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
45+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
46+
47+
6. This License Agreement will automatically terminate upon a material
48+
breach of its terms and conditions.
49+
50+
7. Nothing in this License Agreement shall be deemed to create any
51+
relationship of agency, partnership, or joint venture between PSF and
52+
Licensee. This License Agreement does not grant permission to use PSF
53+
trademarks or trade name in a trademark sense to endorse or promote
54+
products or services of Licensee, or any third party.
55+
56+
8. By copying, installing or otherwise using Python, Licensee
57+
agrees to be bound by the terms and conditions of this License
58+
Agreement.
459
"""
560

661
from functools import partial

sentry_sdk/_queue.py

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,74 @@
11
"""
2-
A fork of Python 3.6's stdlib queue with Lock swapped out for RLock to avoid a
3-
deadlock while garbage collecting.
2+
A fork of Python 3.6's stdlib queue (found in Pythons 'cpython/Lib/queue.py')
3+
with Lock swapped out for RLock to avoid a deadlock while garbage collecting.
44
5-
See
5+
https://github.com/python/cpython/blob/v3.6.12/Lib/queue.py
6+
7+
8+
See also
69
https://codewithoutrules.com/2017/08/16/concurrency-python/
710
https://bugs.python.org/issue14976
811
https://github.com/sqlalchemy/sqlalchemy/blob/4eb747b61f0c1b1c25bdee3856d7195d10a0c227/lib/sqlalchemy/queue.py#L1
912
1013
We also vendor the code to evade eventlet's broken monkeypatching, see
1114
https://github.com/getsentry/sentry-python/pull/484
15+
16+
17+
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
18+
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
19+
20+
All Rights Reserved
21+
22+
23+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
24+
--------------------------------------------
25+
26+
1. This LICENSE AGREEMENT is between the Python Software Foundation
27+
("PSF"), and the Individual or Organization ("Licensee") accessing and
28+
otherwise using this software ("Python") in source or binary form and
29+
its associated documentation.
30+
31+
2. Subject to the terms and conditions of this License Agreement, PSF hereby
32+
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
33+
analyze, test, perform and/or display publicly, prepare derivative works,
34+
distribute, and otherwise use Python alone or in any derivative version,
35+
provided, however, that PSF's License Agreement and PSF's notice of copyright,
36+
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
37+
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
38+
All Rights Reserved" are retained in Python alone or in any derivative version
39+
prepared by Licensee.
40+
41+
3. In the event Licensee prepares a derivative work that is based on
42+
or incorporates Python or any part thereof, and wants to make
43+
the derivative work available to others as provided herein, then
44+
Licensee hereby agrees to include in any such work a brief summary of
45+
the changes made to Python.
46+
47+
4. PSF is making Python available to Licensee on an "AS IS"
48+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
49+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
50+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
51+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
52+
INFRINGE ANY THIRD PARTY RIGHTS.
53+
54+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
55+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
56+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
57+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
58+
59+
6. This License Agreement will automatically terminate upon a material
60+
breach of its terms and conditions.
61+
62+
7. Nothing in this License Agreement shall be deemed to create any
63+
relationship of agency, partnership, or joint venture between PSF and
64+
Licensee. This License Agreement does not grant permission to use PSF
65+
trademarks or trade name in a trademark sense to endorse or promote
66+
products or services of Licensee, or any third party.
67+
68+
8. By copying, installing or otherwise using Python, Licensee
69+
agrees to be bound by the terms and conditions of this License
70+
Agreement.
71+
1272
"""
1373

1474
import threading

sentry_sdk/_werkzeug.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
"""
2+
Copyright (c) 2007 by the Pallets team.
3+
4+
Some rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are
8+
met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
13+
* Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in the
15+
documentation and/or other materials provided with the distribution.
16+
17+
* Neither the name of the copyright holder nor the names of its
18+
contributors may be used to endorse or promote products derived from
19+
this software without specific prior written permission.
20+
21+
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22+
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
23+
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
24+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28+
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31+
THIS SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF
32+
SUCH DAMAGE.
33+
"""
34+
35+
from sentry_sdk._compat import iteritems
36+
37+
from sentry_sdk._types import TYPE_CHECKING
38+
39+
if TYPE_CHECKING:
40+
from typing import Dict
41+
from typing import Iterator
42+
from typing import Tuple
43+
44+
45+
#
46+
# `get_headers` comes from `werkzeug.datastructures.EnvironHeaders`
47+
# https://github.com/pallets/werkzeug/blob/0.14.1/werkzeug/datastructures.py#L1361
48+
#
49+
# We need this function because Django does not give us a "pure" http header
50+
# dict. So we might as well use it for all WSGI integrations.
51+
#
52+
def _get_headers(environ):
53+
# type: (Dict[str, str]) -> Iterator[Tuple[str, str]]
54+
"""
55+
Returns only proper HTTP headers.
56+
"""
57+
for key, value in iteritems(environ):
58+
key = str(key)
59+
if key.startswith("HTTP_") and key not in (
60+
"HTTP_CONTENT_TYPE",
61+
"HTTP_CONTENT_LENGTH",
62+
):
63+
yield key[5:].replace("_", "-").title(), value
64+
elif key in ("CONTENT_TYPE", "CONTENT_LENGTH"):
65+
yield key.replace("_", "-").title(), value
66+
67+
68+
#
69+
# `get_host` comes from `werkzeug.wsgi.get_host`
70+
# https://github.com/pallets/werkzeug/blob/1.0.1/src/werkzeug/wsgi.py#L145
71+
#
72+
def get_host(environ, use_x_forwarded_for=False):
73+
# type: (Dict[str, str], bool) -> str
74+
"""
75+
Return the host for the given WSGI environment.
76+
"""
77+
if use_x_forwarded_for and "HTTP_X_FORWARDED_HOST" in environ:
78+
rv = environ["HTTP_X_FORWARDED_HOST"]
79+
if environ["wsgi.url_scheme"] == "http" and rv.endswith(":80"):
80+
rv = rv[:-3]
81+
elif environ["wsgi.url_scheme"] == "https" and rv.endswith(":443"):
82+
rv = rv[:-4]
83+
elif environ.get("HTTP_HOST"):
84+
rv = environ["HTTP_HOST"]
85+
if environ["wsgi.url_scheme"] == "http" and rv.endswith(":80"):
86+
rv = rv[:-3]
87+
elif environ["wsgi.url_scheme"] == "https" and rv.endswith(":443"):
88+
rv = rv[:-4]
89+
elif environ.get("SERVER_NAME"):
90+
rv = environ["SERVER_NAME"]
91+
if (environ["wsgi.url_scheme"], environ["SERVER_PORT"]) not in (
92+
("https", "443"),
93+
("http", "80"),
94+
):
95+
rv += ":" + environ["SERVER_PORT"]
96+
else:
97+
# In spite of the WSGI spec, SERVER_NAME might not be present.
98+
rv = "unknown"
99+
100+
return rv

sentry_sdk/integrations/wsgi.py

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import sys
22

33
from sentry_sdk._functools import partial
4+
from sentry_sdk._werkzeug import get_host, _get_headers
45
from sentry_sdk.consts import OP
56
from sentry_sdk.hub import Hub, _should_send_default_pii
67
from sentry_sdk.utils import (
78
ContextVar,
89
capture_internal_exceptions,
910
event_from_exception,
1011
)
11-
from sentry_sdk._compat import PY2, reraise, iteritems
12+
from sentry_sdk._compat import PY2, reraise
1213
from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_ROUTE
1314
from sentry_sdk.sessions import auto_session_tracking
1415
from sentry_sdk.integrations._wsgi_common import _filter_headers
@@ -54,35 +55,6 @@ def wsgi_decoding_dance(s, charset="utf-8", errors="replace"):
5455
return s.encode("latin1").decode(charset, errors)
5556

5657

57-
def get_host(environ, use_x_forwarded_for=False):
58-
# type: (Dict[str, str], bool) -> str
59-
"""Return the host for the given WSGI environment. Yanked from Werkzeug."""
60-
if use_x_forwarded_for and "HTTP_X_FORWARDED_HOST" in environ:
61-
rv = environ["HTTP_X_FORWARDED_HOST"]
62-
if environ["wsgi.url_scheme"] == "http" and rv.endswith(":80"):
63-
rv = rv[:-3]
64-
elif environ["wsgi.url_scheme"] == "https" and rv.endswith(":443"):
65-
rv = rv[:-4]
66-
elif environ.get("HTTP_HOST"):
67-
rv = environ["HTTP_HOST"]
68-
if environ["wsgi.url_scheme"] == "http" and rv.endswith(":80"):
69-
rv = rv[:-3]
70-
elif environ["wsgi.url_scheme"] == "https" and rv.endswith(":443"):
71-
rv = rv[:-4]
72-
elif environ.get("SERVER_NAME"):
73-
rv = environ["SERVER_NAME"]
74-
if (environ["wsgi.url_scheme"], environ["SERVER_PORT"]) not in (
75-
("https", "443"),
76-
("http", "80"),
77-
):
78-
rv += ":" + environ["SERVER_PORT"]
79-
else:
80-
# In spite of the WSGI spec, SERVER_NAME might not be present.
81-
rv = "unknown"
82-
83-
return rv
84-
85-
8658
def get_request_url(environ, use_x_forwarded_for=False):
8759
# type: (Dict[str, str], bool) -> str
8860
"""Return the absolute URL without query string for the given WSGI
@@ -185,27 +157,6 @@ def _get_environ(environ):
185157
yield key, environ[key]
186158

187159

188-
# `get_headers` comes from `werkzeug.datastructures.EnvironHeaders`
189-
#
190-
# We need this function because Django does not give us a "pure" http header
191-
# dict. So we might as well use it for all WSGI integrations.
192-
def _get_headers(environ):
193-
# type: (Dict[str, str]) -> Iterator[Tuple[str, str]]
194-
"""
195-
Returns only proper HTTP headers.
196-
197-
"""
198-
for key, value in iteritems(environ):
199-
key = str(key)
200-
if key.startswith("HTTP_") and key not in (
201-
"HTTP_CONTENT_TYPE",
202-
"HTTP_CONTENT_LENGTH",
203-
):
204-
yield key[5:].replace("_", "-").title(), value
205-
elif key in ("CONTENT_TYPE", "CONTENT_LENGTH"):
206-
yield key.replace("_", "-").title(), value
207-
208-
209160
def get_client_ip(environ):
210161
# type: (Dict[str, str]) -> Optional[Any]
211162
"""

sentry_sdk/profiler.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
"""
2-
This file is originally based on code from https://github.com/nylas/nylas-perftools, which is published under the following license:
2+
This file is originally based on code from https://github.com/nylas/nylas-perftools,
3+
which is published under the following license:
34
45
The MIT License (MIT)
56
67
Copyright (c) 2014 Nylas
78
8-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9-
10-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11-
12-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.
1326
"""
1427

1528
import atexit

0 commit comments

Comments
 (0)