Commit Graph

156 Commits

Author SHA1 Message Date
Hai Shi 4660597b51
bpo-40275: Use new test.support helper submodules in tests (GH-21448) 2020-08-03 18:49:18 +02:00
Niklas Fiekas 8bd216dfed
bpo-29882: Add an efficient popcount method for integers (#771)
* bpo-29882: Add an efficient popcount method for integers

* Update 'sign bit' and versionadded in docs

* Add entry to whatsnew document

* Doc: use positive example, mention population count

* Minor cleanups of the core code

* Move popcount_digit closer to where it's used

* Use z instead of self after conversion

* Add 'absolute value' and 'population count' to docstring

* Fix clinic error about missing summary line

* Ensure popcount_digit is portable with 64-bit ints

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2020-05-29 17:28:02 +01:00
Gregory P. Smith 6a5d3ff676
bpo-40636: Clarify the zip built-in docstring. (GH-20118)
Clarify the zip built-in docstring.

This puts much simpler text up front along with an example.

As it was, the zip built-in docstring was technically correct.  But too
technical for the reader who shouldn't _need_ to know about `__next__` and
`StopIteration` as most people do not need to understand the internal
implementation details of the iterator protocol in their daily life.

This is a documentation only change, intended to be backported to 3.8; it is
only tangentially related to PEP-618 which might offer new behavior options
in the future.

Wording based a bit more on enumerate per Brandt's suggestion.

This gets rid of the legacy wording paragraph which seems too tied to
implementation details of the iterator protocol which isn't relevant here.

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2020-05-15 14:26:00 -07:00
sweeneyde a81849b031
bpo-39939: Add str.removeprefix and str.removesuffix (GH-18939)
Added str.removeprefix and str.removesuffix methods and corresponding
bytes, bytearray, and collections.UserString methods to remove affixes
from a string if present. See PEP 616 for a full description.
2020-04-22 23:05:48 +02:00
Guido van Rossum 48b069a003
bpo-39481: Implementation for PEP 585 (#18239)
This implements things like `list[int]`,
which returns an object of type `types.GenericAlias`.
This object mostly acts as a proxy for `list`,
but has attributes `__origin__` and `__args__`
that allow recovering the parts (with values `list` and `(int,)`.

There is also an approximate notion of type variables;
e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`.
Type variables are objects of type `typing.TypeVar`.
2020-04-07 09:50:06 -07:00
Peter Donis e0b8101492
bpo-1812: Fix newline conversion when doctest.testfile loads from a package whose loader has a get_data method (GH-17385)
This pull request fixes the newline conversion bug originally reported in bpo-1812. When that issue was originally submitted, the open builtin did not default to universal newline mode; now it does, which makes the issue fix simpler, since the only code path that needs to be changed is the one in doctest._load_testfile where the file is loaded from a package whose loader has a get_data method.
2020-03-26 10:53:16 -05:00
Xtreak 8289e27393 bpo-36406: Handle namespace packages in doctest (GH-12520) 2019-12-13 10:06:53 -08:00
Min ho Kim c4cacc8c5e Fix typos in comments, docs and test names (#15018)
* Fix typos in comments, docs and test names

* Update test_pyparse.py

account for change in string length

* Apply suggestion: splitable -> splittable

Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu>

* Apply suggestion: splitable -> splittable

Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu>

* Apply suggestion: Dealloccte -> Deallocate

Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu>

* Update posixmodule checksum.

* Reverse idlelib changes.
2019-07-30 18:16:13 -04:00
Gregory P. Smith 0c2f930564
bpo-22385: Support output separators in hex methods. (#13578)
* bpo-22385: Support output separators in hex methods.

Also in binascii.hexlify aka b2a_hex.

The underlying implementation behind all hex generation in CPython uses the
same pystrhex.c implementation.  This adds support to bytes, bytearray,
and memoryview objects.

The binascii module functions exist rather than being slated for deprecation
because they return bytes rather than requiring an intermediate step through a
str object.

This change was inspired by MicroPython which supports sep in its binascii
implementation (and does not yet support the .hex methods).

https://bugs.python.org/issue22385
2019-05-29 11:46:58 -07:00
Pablo Galindo c5dc60ea85 bpo-24746: Fix doctest failures when running the testsuite with -R (#11501) 2019-01-10 06:29:40 -08:00
Sanyam Khurana cbb1645993 bpo-24746: Avoid stripping trailing whitespace in doctest fancy diff (#10639) 2019-01-09 05:38:38 -08:00
Serhiy Storchaka da8d72c953
bpo-12458: Fix line numbers for multiline expressions. (GH-8774) 2018-09-17 15:17:29 +03:00
Lisa Roach 5ac704306f bpo-33073: Adding as_integer_ratio to ints. (GH-8750) 2018-09-13 23:56:23 -07:00
Nick Coghlan d5d9e02dd3
bpo-33053: -m now adds *starting* directory to sys.path (GH-6231)
Historically, -m added the empty string as sys.path
zero, meaning it resolved imports against the current
working directory, the same way -c and the interactive
prompt do.

This changes the sys.path initialisation to add the
*starting* working directory as sys.path[0] instead,
such that changes to the working directory while the
program is running will have no effect on imports
when using the -m switch.
2018-03-25 23:03:10 +10:00
Jason R. Coombs b9650a04a8
bpo-32991: Restore expectation that inspect.getfile raises TypeError on namespace package (GH-5980)
* bpo-32991: Add test capturing expectation.

DocTestFinder.find should return an empty list for doctests in a namespace package.

* bpo-32991: Restore expectation that inspect.getfile on a namespace package raises TypeError.
2018-03-05 18:29:08 -05:00
INADA Naoki a49ac99029
bpo-32677: Add .isascii() to str, bytes and bytearray (GH-5342) 2018-01-27 14:06:21 +09:00
R David Murray 44b548dda8 #27364: fix "incorrect" uses of escape character in the stdlib.
And most of the tools.

Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and
Martin Panter.
2016-09-08 13:59:53 -04:00
Benjamin Peterson ab078e9ed1 Backed out changeset af29d89083b3 (closes #25548) (closes #27498) 2016-07-13 21:13:29 -07:00
Berker Peksag a67d78e50c Issue #18300: Merge from 3.5 2016-06-24 09:29:21 +03:00
Berker Peksag e495646a97 Issue #18300: Set TERM='' by default in assert_python_* 2016-06-24 09:28:50 +03:00
Kushal Das 5801ecb440 Issue #25548: Showing memory address of class objects in repl 2016-06-04 16:21:13 -07:00
Martin Panter 3e04d5b306 Issue #27076: Merge spelling from 3.5 2016-05-26 06:03:19 +00:00
Martin Panter 46f50726a0 Issue #27076: Doc, comment and tests spelling fixes
Most fixes to Doc/ and Lib/ directories by Ville Skyttä.
2016-05-26 05:35:26 +00:00
Serhiy Storchaka e437a10d15 Issue #23277: Remove unused imports in tests. 2016-04-24 21:41:02 +03:00
Victor Stinner 931602a1ac test_doctest: remove unused imports 2016-03-25 12:48:17 +01:00
Martin Panter c04fb56e36 Issue #26304: Change "allows to <verb>" to "allows <verb>ing" or similar
The original form is incorrect grammar and feels awkward, even though the
meaning is clear.
2016-02-10 05:44:01 +00:00
Victor Stinner 09a08de363 Fix test_doctest in verbose mode 2015-12-02 14:37:17 +01:00
Berker Peksag ce643913a9 Issue #9517: Move script_helper to the support package.
Patch by Christie Wilson.
2015-05-06 06:33:17 +03:00
Gregory P. Smith 8cb6569fe1 Implements issue #9951: Adds a hex() method to bytes, bytearray, & memoryview.
Also updates a few internal implementations of the same thing to use the
new built-in code.

Contributed by Arnon Yaari.
2015-04-25 23:22:26 +00:00
Berker Peksag dfa4e045a3 Issue #23943: Fix typos. Patch by Piotr Kasprzyk. 2015-04-14 09:35:51 +03:00
Berker Peksag 4882cacab6 Issue #23943: Fix typos. Patch by Piotr Kasprzyk. 2015-04-14 09:30:01 +03:00
Serhiy Storchaka ae2d667ae8 Open files in binary mode to avoid newlines transformation. 2015-04-04 10:36:50 +03:00
Serhiy Storchaka c9ba38c21c Open files in binary mode to avoid newlines transformation. 2015-04-04 10:36:25 +03:00
Yury Selivanov b532df62b9 Issue #21740: Support wrapped callables in pydoc. Patch by Claudiu Popa. 2014-12-08 15:00:05 -05:00
R David Murray f355943002 Merge: #8473: Add tests that doctest uses universal newlines in testfile. 2014-10-02 22:43:51 -04:00
R David Murray b48cb29ac4 #8473: Add tests that doctest uses universal newlines in testfile.
Python3 does not have the bug covered by the issue.
2014-10-02 22:42:42 -04:00
Ethan Furman 7b9ff0e6da Issue8297: module attribute lookup failures now include module name in error message. 2014-04-24 14:47:47 -07:00
R David Murray 1976d9bf6d #15916: if there are no docstrings, make empty suite, not an error.
This makes doctest work like unittest: if the test case is empty, that
just means there are zero tests run, it's not an error.  The existing
behavior was broken, since it only gave an error if there were *no*
docstrings, and zero tests run if there were docstrings but none of them
contained tests.  So this makes it self-consistent as well.

Patch by Glenn Jones.
2014-04-14 20:28:36 -04:00
Giampaolo Rodola' e09fb7198a fix #21076: turn signal module constants into enums 2014-04-04 15:34:17 +02:00
Tim Peters f9a07f2e11 Issue #19138: doctest's IGNORE_EXCEPTION_DETAIL now allows no detail at all. 2013-12-03 21:02:05 -06:00
Zachary Ware 7119b454fd Issue #3158: Relax new doctests a bit.
Apparently, the number of objects with docstrings in builtins varies
with --with-pydebug (non-debug has one fewer).

Also, skip the new tests entirely if built --without-doc-strings.
2013-11-24 02:21:57 -06:00
Zachary Ware a4b7a7548c Issue #3158: doctest can now find doctests in functions and methods
written in C.

As a part of this, a few doctests have been added to the builtins module
(on hex(), oct(), and bin()), a doctest has been fixed (hopefully on all
platforms) on float, and test_builtins now runs doctests in builtins.
2013-11-24 01:19:09 -06:00
R David Murray 4af6898dbd #11390: fix test failures due to readline and windows lineneds. 2013-06-25 08:11:22 -04:00
R David Murray 5707d508e1 #11390: convert doctest CLI to argparse and add -o and -f options.
This provides a way to specify arbitrary doctest options when using
the CLI interface to process test files, just as one can when calling
testmod or testfile programmatically.
2013-06-23 14:24:13 -04:00
R David Murray 5a9d706123 #16522: Add FAIL_FAST flag to doctest.
Patch by me, most of the work (doc and tests) by Daniel Urban.
2012-11-21 15:09:21 -05:00
R David Murray c3bfb01a95 Merge #14649: clarify DocTestSuite error when there are no docstrings.
Also adds tests to verify the documented behavior (which is probably a bug, as
indicated in the added comments).

Patch by Chris Jerdonek.
2012-09-10 10:16:46 -04:00
R David Murray 5abd76a75d #14649: clarify DocTestSuite error when there are no docstrings.
Also adds tests to verify the documented behavior (which is probably a bug, as
indicated in the added comments).

Patch by Chris Jerdonek.
2012-09-10 10:15:58 -04:00
Vinay Sajip 7ded1f0f69 Implemented PEP 405 (Python virtual environments). 2012-05-26 03:45:29 +01:00
Antoine Pitrou 165b1283ff Followup to #7502: add __hash__ method and tests. 2011-12-18 20:20:17 +01:00
Antoine Pitrou 2bc801c4ea Issue #7502: Fix equality comparison for DocTestCase instances.
Patch by Cédric Krier.
2011-12-18 19:27:45 +01:00