8000 get up to date by sumagnadas · Pull Request #22429 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

get up to date #22429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ How do you remove duplicates from a list?

See the Python Cookbook for a long discussion of many ways to do this:

https://github.com/ActiveState/code/tree/master/recipes/Python/52560_Remove_duplicates/recipe-52560.py
https://code.activestate.com/recipes/52560/

If you don't mind reordering the list, sort it and then scan from the end of the
list, deleting duplicates as you go::
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/urllib2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -601,5 +601,5 @@ This document was reviewed and revised by John Lee.
scripts with a localhost server, I have to prevent urllib from using
the proxy.
.. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe
<https://github.com/ActiveState/code/tree/master/recipes/Python/456195_urrlib2_opener_SSL_proxy_CONNECT/recipe-456195.py>`_.
<https://code.activestate.com/recipes/456195/>`_.

2 changes: 1 addition & 1 deletion Doc/library/bisect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The following functions are provided:
.. seealso::

`SortedCollection recipe
<https://github.com/ActiveState/code/tree/master/recipes/Python/577197_SortedCollection/recipe-577197.py>`_ that uses
<https://code.activestate.com/recipes/577197-sortedcollection/>`_ that uses
bisect to build a full-featured collection class with straight-forward search
methods and support for a key-function. The keys are precomputed to save
unnecessary calls to the key function during searches.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/collections.abc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:

.. seealso::

* `OrderedSet recipe <https://github.com/ActiveState/code/tree/master/recipes/Python/576694_OrderedSet/recipe-576694.py>`_ for an
* `OrderedSet recipe <https://code.activestate.com/recipes/576694/>`_ for an
example built on :class:`MutableSet`.

* For more about ABCs, see the :mod:`abc` module and :pep:`3119`.
4 changes: 2 additions & 2 deletions Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ The class can be used to simulate nested scopes and is useful in templating.
:attr:`~collections.ChainMap.parents` property.

* The `Nested Contexts recipe
<https://github.com/ActiveState/code/tree/master/recipes/Python/577434_Nested_contexts__chamapping/recipe-577434.py>`_ has options to control
<https://code.activestate.com/recipes/577434/>`_ has options to control
whether writes and other mutations apply only to the first mapping or to
any mapping in the chain.

* A `greatly simplified read-only version of Chainmap
<https://github.com/ActiveState/code/tree/master/recipes/Python/305268_Chained_map_lookups/recipe-305268.py>`_.
<https://code.activestate.com/recipes/305268/>`_.


:class:`ChainMap` Examples and Recipes
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/difflib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ If you want to know how to change the first sequence into the second, use
work.

* `Simple version control recipe
<https://github.com/ActiveState/code/tree/master/recipes/Python/576729_Simple_Version_Control/recipe-576729.py>`_ for a small application
<https://code.activestate.com/recipes/576729/>`_ for a small application
built with :class:`SequenceMatcher`.


Expand Down
2 changes: 1 addition & 1 deletion Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Number-theoretic and representation functions

For further discussion and two alternative approaches, see the `ASPN cookbook
recipes for accurate floating point summation
<https://github.com/ActiveState/code/tree/master/recipes/Python/393090_Binary_floating_point_summatiaccurate_full/recipe-393090.py>`_\.
<https://code.activestate.com/recipes/393090/>`_\.


.. function:: gcd(*integers)
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/optparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ equivalent to the above example::
<yourscript> -q -foutfile
<yourscript> -qfoutfile

Additionally, users can run one of ::
Additionally, users can run one of the following ::

<yourscript> -h
<yourscript> --help
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ from sources provided by the operating system.


`Complementary-Multiply-with-Carry recipe
<https://github.com/ActiveState/code/tree/master/recipes/Python/576707_Long_period_random_number/recipe-576707.py>`_ for a compatible alternative
<https://code.activestate.com/recipes/576707/>`_ for a compatible alternative
random number generator with a long period and comparatively simple update
operations.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/shelve.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Two additional methods are supported:

.. seealso::

`Persistent dictionary recipe <https://github.com/ActiveState/code/tree/master/recipe 10000 s/Python/576642_Persistent_dict_multiple_standard_file/recipe-576642.py>`_
`Persistent dictionary recipe <https://code.activestate.com/recipes/576642/>`_
with widely supported storage formats and having the speed of native
dictionaries.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ objects that compare equal might have different :attr:`~range.start`,

.. seealso::

* The `linspace recipe <https://github.com/ActiveState/code/tree/master/recipes/Python/579000_Equallyspaced_numbers_linspace/recipe-579000.py>`_
* The `linspace recipe <http://code.activestate.com/recipes/579000/>`_
shows how to implement a lazy version of range suitable for floating
point applications.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ always available.
additional garbage collector overhead if the object is managed by the garbage
collector.

See `recursive sizeof recipe <https://github.com/ActiveState/code/tree/master/recipes/Python/577504_Compute_Memory_footprint_object_its/recipe-577504.py>`_
See `recursive sizeof recipe <https://code.activestate.com/recipes/577504>`_
for an example of using :func:`getsizeof` recursively to find the size of
containers and all their contents.

Expand Down
2 changes: 1 addition & 1 deletion Doc/tutorial/whatnow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ More Python resources:
for download. Once you begin releasing code, you can register it here so that
others can find it.

* https://github.com/ActiveState/code/tree/master/recipes/Python: The Python Cookbook is a
* https://code.activestate.com/recipes/langs/python/: The Python Cookbook is a
sizable collection of code examples, larger modules, and useful scripts.
Particularly notable contributions are collected in a book also titled Python
Cookbook (O'Reilly & Associates, ISBN 0-596-00797-3.)
Expand Down
4 changes: 2 additions & 2 deletions Doc/whatsnew/3.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,8 @@ functools

(Contributed by Raymond Hettinger and incorporating design ideas from Jim
Baker, Miki Tebeka, and Nick Coghlan; see `recipe 498245
<https://github.com/ActiveState/code/tree/master/recipes/Python/498245_LRU_and_LFU_cache_decorators/recipe-498245.py>`_\, `recipe 577479
<https://github.com/ActiveState/code/tree/master/recipes/Python/577479_Simple_caching_decorator/recipe-577479.py>`_\, :issue:`10586`, and
<https://code.activestate.com/recipes/498245>`_\, `recipe 577479
<https://code.activestate.com/recipes/577479>`_\, :issue:`10586`, and
:issue:`10593`.)

* The :func:`functools.wraps` decorator now adds a :attr:`__wrapped__` attribute
Expand Down
2 changes: 1 addition & 1 deletion Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ class Counter(dict):
# http://en.wikipedia.org/wiki/Multiset
# http://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html
# http://www.demo2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm
# https://github.com/ActiveState/code/tree/master/recipes/Python/259174_bag_collection_class/recipe-259174.py
# http://code.activestate.com/recipes/259174/
# Knuth, TAOCP Vol. II section 4.6.3

def __init__(self, iterable=None, /, **kwds):
Expand Down
2 changes: 1 addition & 1 deletion Lib/heapq.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def merge(*iterables, key=None, reverse=False):
# 2) Made multiple passes over the data.
# 3) Made more comparisons in common cases (small k, large n, semi-random input).
# See the more detailed comparison of approach at:
# https://github.com/ActiveState/code/tree/master/recipes/Python/577573_Compare_algorithms/recipe-577573.py
# http://code.activestate.com/recipes/577573-compare-algorithms-for-heapqsmallest

def nsmallest(n, iterable, key=None):
"""Find the n smallest elements in a dataset.
Expand Down
3 changes: 2 additions & 1 deletion Lib/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def _checkLevel(level):
raise ValueError("Unknown level: %r" % level)
rv = _nameToLevel[level]
else:
raise TypeError("Level not an integer or a valid string: %r" % level)
raise TypeError("Level not an integer or a valid string: %r"
% (level,))
return rv

#---------------------------------------------------------------------------
Expand Down
33 changes: 20 additions & 13 deletions Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3720,7 +3720,15 @@ def tzname(self, dt):

utc = UTC()

class FormatterTest(unittest.TestCase):
class AssertErrorMessage:

def assert_error_message(self, exception, message, *args, **kwargs):
try:
self.assertRaises((), *args, **kwargs)
except exception as e:
self.assertEqual(message, str(e))

class FormatterTest(unittest.TestCase, AssertErrorMessage):
def setUp(self):
self.common = {
'name': 'formatter.test',
Expand All @@ -3744,12 +3752,6 @@ def get_record(self, name=None):
result.update(self.variants[name])
return logging.makeLogRecord(result)

def assert_error_message(self, exception, message, *args, **kwargs):
try:
self.assertRaises(exception, *args, **kwargs)
except exception as e:
self.assertEqual(message, e.message)

def test_percent(self):
# Test %-formatting
r = self.get_record()
Expand Down Expand Up @@ -3868,7 +3870,7 @@ def test_format_validate(self):
# Testing failure for '-' in field name
self.assert_error_message(
ValueError,
"invalid field name/expression: 'name-thing'",
"invalid format: invalid field name/expression: 'name-thing'",
logging.Formatter, "{name-thing}", style="{"
)
# Testing failure for style mismatch
Expand All @@ -3891,7 +3893,7 @@ def test_format_validate(self):
# Testing failure for invalid spec
self.assert_error_message(
ValueError,
"bad specifier: '.2ff'",
"invalid format: bad specifier: '.2ff'",
logging.Formatter, '{process:.2ff}', style='{'
)
self.assertRaises(ValueError, logging.Formatter, '{process:.2Z}', style='{')
Expand All @@ -3901,12 +3903,12 @@ def test_format_validate(self):
# Testing failure for mismatch braces
self.assert_error_message(
ValueError,
"invalid format: unmatched '{' in format spec",
"invalid format: expected '}' before end of string",
logging.Formatter, '{process', style='{'
)
self.assert_error_message(
ValueError,
"invalid format: unmatched '{' in format spec",
"invalid format: Single '}' encountered in format string",
logging.Formatter, 'process}', style='{'
)
self.assertRaises(ValueError, logging.Formatter, '{{foo!r:4.2}', style='{')
Expand Down Expand Up @@ -4867,7 +4869,7 @@ def process(self, msg, kwargs):
self.assertIs(self.logger.manager, orig_manager)


class LoggerTest(BaseTest):
class LoggerTest(BaseTest, AssertErrorMessage):

def setUp(self):
super(LoggerTest, self).setUp()
Expand All @@ -4879,7 +4881,12 @@ def setUp(self):
self.addCleanup(logging.shutdown)

def test_set_invalid_level(self):
self.assertRaises(TypeError, self.logger.setLevel, object())
self.assert_error_message(
TypeError, 'Level not an integer or a valid string: None',
self.logger.setLevel, None)
self.assert_error_message(
TypeError, 'Level not an integer or a valid string: (0, 0)',
self.logger.setLevel, (0, 0))

def test_exception(self):
msg = 'testing exception: %r'
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def testFsum(self):
def msum(iterable):
"""Full precision summation. Compute sum(iterable) without any
intermediate accumulation of error. Based on the 'lsum' function
at https://github.com/ActiveState/code/tree/master/recipes/Python/393090_Binary_floating_point_summatiaccurate_full/recipe-393090.py
at http://code.activestate.com/recipes/393090/

"""
tmant, texp = 0, 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Port the :mod:`_bisect` module to the multi-phase initialization API (:pep:`489`).
14 changes: 5 additions & 9 deletions Modules/_bisectmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,14 @@ common approach.\n");

static struct PyModuleDef _bisectmodule = {
PyModuleDef_HEAD_INIT,
"_bisect",
module_doc,
-1,
bisect_methods,
NULL,
NULL,
NULL,
NULL
.m_name = "_bisect",
.m_doc = module_doc,
.m_methods = bisect_methods,
.m_size = 0
};

PyMODINIT_FUNC
PyInit__bisect(void)
{
return PyModule_Create(&_bisectmodule);
return PyModuleDef_Init(&_bisectmodule);
}
Loading
0