Commit Graph

394 Commits

Author SHA1 Message Date
Serhiy Storchaka 4606eff0aa
gh-122129: Improve support of method descriptors and wrappers in the help title (GH-122157) 2024-07-23 20:45:21 +03:00
Serhiy Storchaka 31d1d72d7e
gh-120541: Improve the "less" prompt in pydoc (GH-120543)
When help() is called with non-string argument, use __qualname__ or
__name__ if available, otherwise use "{typename} object".
2024-06-15 20:56:40 +03:00
Victor Stinner 6ae254aaa0
gh-120417: Add #noqa to used imports in the stdlib (#120421)
Tools such as ruff can ignore "imported but unused" warnings if a
line ends with "# noqa: F401". It avoids the temptation to remove
an import which is used effectively.
2024-06-13 16:14:50 +02:00
Victor Stinner 4c6d4f5cb3
gh-120417: Remove unused imports in the stdlib (#120420) 2024-06-12 20:56:42 +02:00
Enrico Tröger 2080425154
bpo-37755: Use configured output in pydoc instead of pager (GH-15105)
If the Helper() class was initialized with an output, the topics, keywords
and symbols help still use the pager instead of the output.
Change the behavior so  the output is used if available while keeping the
previous behavior if no output was configured.
2024-06-08 09:19:13 +00:00
Victor Stinner 4223f1d828
gh-119856: Support exiting help() with just "exit" (#119858) 2024-06-03 10:15:04 +02:00
Jason R. Coombs c8b45a385a
gh-118673: Remove shebang and executable bits from stdlib modules. (#119658)
* gh-118673: Remove shebang and executable bits from stdlib modules.

* Removed shebangs and exe bits on turtledemo scripts.

The setting was inappropriate for '__main__' and inconsistent across the other modules. The scripts can still be executed directly by invoking with the desired interpreter.
2024-05-29 12:43:19 -04:00
Serhiy Storchaka 153b3f7530
gh-118465: Add __firstlineno__ attribute to class (GH-118475)
It is set by compiler with the line number of the first line of
the class definition.
2024-05-06 12:02:37 +03:00
Pablo Galindo Salgado f27f8c790a
gh-111201: A new Python REPL (GH-111567)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Marta Gómez Macías <mgmacias@google.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-05-05 21:32:23 +02:00
Serhiy Storchaka c917b3e8e1
gh-65824: Add "Help on ..." to the "less" prompt in pydoc (GH-116183) 2024-04-17 13:05:22 +03:00
Irit Katriel 79be75735c
gh-115775: Compiler adds __static_attributes__ field to classes (#115913) 2024-03-26 15:18:17 +00:00
Itamar Oren 02ee475ee3
gh-116143: Fix race condition in pydoc _start_server (#116144) 2024-03-06 07:39:51 -07:00
Serhiy Storchaka 0704166f9a
gh-65824: Improve the "less" prompt in pydoc (GH-116050)
Output the line number, the percentage and the help about how to get help
or quit the pager.

Inspired by the GNU man.
2024-03-01 10:03:32 +02:00
Serhiy Storchaka 72cff8d8e5
gh-113942: Show functions implemented as builtin methods (GH-115306)
Pydoc no longer skips global functions implemented as builtin methods,
such as MethodDescriptorType and WrapperDescriptorType.
2024-02-26 20:29:49 +02:00
Eugene Toder c0b0c2f201
gh-101860: Expose __name__ on property (GH-101876)
Useful for introspection and consistent with functions and other
descriptors.
2024-02-20 17:14:34 +02:00
Kirill Podoprigora b9a9e3dd62
gh-107155: Fix help() for lambda function with return annotation (GH-107401) 2024-02-17 12:47:51 +00:00
Nikita Sobolev ccc76c3e88
gh-108303: Move all `pydoc` related test files to new `test.test_pydoc` package (#114506) 2024-02-13 11:40:40 +01:00
Serhiy Storchaka 2939ad02be
gh-97959: Fix rendering of routines in pydoc (GH-113941)
* Class methods no longer have "method of builtins.type instance" note.
* Corresponding notes are now added for class and unbound methods.
* Method and function aliases now have references to the module or the
  class where the origin was defined if it differs from the current.
* Bound methods are now listed in the static methods section.
* Methods of builtin classes are now supported as well as methods of
  Python classes.
2024-02-11 15:19:44 +02:00
Zackery Spytz 1ddd773293
gh-64020: Deprecate pydoc.ispackage() (GH-20908)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-27 14:04:31 +00:00
Nikita Sobolev a9574c68f0
gh-112139: Add `inspect.Signature.format` and use it in `pydoc` (#112143)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-12-02 15:39:43 -08:00
Terry Jan Reedy b28bb130bb
gh-112007: Re-organize help utility intro message (#112017)
Most important: move how-to-quit sentence to the end and mention 'q'.
Re-group the other sentences and improve some wording.
---------
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-11-13 14:24:03 -05:00
Serhiy Storchaka a39f0a3506
gh-107782: Pydoc: fall back to __text_signature__ if inspect.signature() fails (GH-107786)
It allows to show signatures which are not representable in Python,
e.g. for getattr and dict.pop.
2023-08-11 20:51:36 +03:00
Kirill Podoprigora 0530f4f646
gh-102541: Fix Helper.help("mod") for non-existent mod (#105934)
If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in pydoc.doc. The same error is caught when output is None.
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-07-01 18:46:06 -04:00
Kirill Podoprigora ba516e70c6
gh-102541: Hide traceback in help prompt (gh-102614) 2023-06-14 21:17:12 +09:00
Yuxin Wu e95dd40aff
pydoc.safeimport: Use importlib.import_module instead of __import__ (GH-103118) 2023-05-03 16:26:39 -07:00
Barry Warsaw 326997829d
gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059)
* Remove deprecated classes from pkgutil
* Remove some other PEP 302 obsolescence
* Use find_spec instead of load_module
* Remove more tests of PEP 302 obsolete APIs
* Remove another bunch of tests using obsolete load_modules()
* Remove deleted names from __all__
* Remove obsolete footnote
* imp is removed
* Remove `imp` from generated stdlib names
* What's new and blurb
* Update zipimport documentation for the removed methods
* Fix some Windows tests
* Remove any test (or part of a test) that references `find_module()`.
* Use assertIsNone() / assertIsNotNone() consistently.
* Update Doc/reference/import.rst
* We don't need pkgutil._get_spec() any more either
*  test.test_importlib.fixtures.NullFinder
* ...BadLoaderFinder.find_module
* ...test_api.InvalidatingNullFinder.find_module
* ...test.test_zipimport test of z.find_module
* Suppress cross-references to find_loader and find_module
* Suppress cross-references to Finder
* Suppress cross-references to pkgutil.ImpImporter and pkgutil.ImpLoader

---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2023-05-03 04:55:22 -07:00
Barry Warsaw e1f14643dc
gh-98040: Remove just the `imp` module (#98573) 2023-04-28 16:17:58 -07:00
Irit Katriel 868490e327
gh-102799: Let pydoc use the exception instead of sys.exc_info (#102830) 2023-03-21 11:07:03 +00:00
Nick Drozd 024ac542d7
bpo-45975: Simplify some while-loops with walrus operator (GH-29347) 2022-11-26 14:33:25 -08:00
Dong-hee Na 4156b2fc13
gh-98374: Suppress ImportError for invalid query for help() command. (gh-98450) 2022-10-20 10:56:21 +09:00
Serhiy Storchaka 33fc3b5e42
gh-94318: Strip trailing spaces in pydoc text output (GH-94319) 2022-06-27 13:33:34 +03:00
Serhiy Storchaka f9433fff47
gh-89828: Do not relay the __class__ attribute in GenericAlias (#93754)
list[int].__class__ returned type, and isinstance(list[int], type)
returned True. It caused numerous problems in code that checks
isinstance(x, type).
2022-06-18 11:34:57 +03:00
Serhiy Storchaka 3680ebed7f
bpo-44712: Replace "type(literal)" with corresponding builtin types (GH-27294)
I suppose it is a remnants of very old code written when str, int, list, dict, etc
were functions and not classes.
2022-05-08 17:10:11 +03:00
Nikita Sobolev cb6c6648be
bpo-46547: remove leaking vars into `pydoc.Helper` namespace (#30957)
Fixes #90705
2022-05-02 16:25:52 -06:00
Hugo van Kemenade 6881ea936e
bpo-47126: Update to canonical PEP URLs specified by PEP 676 (GH-32124) 2022-03-30 12:00:27 +01:00
Irit Katriel 63f32fae79
bpo-26120: do not exclude __future__ import in pydoc of the __future__ module itself (GH-32180) 2022-03-29 23:07:15 +01:00
Irit Katriel 15ba8167d7
bpo-26120: make pydoc exclude __future__ imports from the data block of the module (GH-30888) 2022-03-28 22:02:57 +01:00
Serhiy Storchaka cd44afc573
bpo-40296: Fix supporting generic aliases in pydoc (GH-30253) 2022-03-18 11:05:18 +02:00
Christian Heimes cb2b3c8d35
bpo-40280: Emscripten has no support for subprocesses (GH-29872)
Fixes ``platform`` and ``help()`` on emscripten.

Signed-off-by: Christian Heimes <christian@python.org>

Automerge-Triggered-By: GH:tiran
2021-12-02 01:17:37 -08:00
Julien Palard c91b6f57f3
bpo-10716: Migrating pydoc to html5. (GH-28651) 2021-10-09 09:36:50 +02:00
E-Paine c9227df5a9
bpo-42278: Use tempfile.TemporaryDirectory rather than tempfile.mktemp in pydoc (GH-23200)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-08-29 13:07:51 +02:00
Gregory Anders 8868d48712
bpo-44967: pydoc: return non-zero exit code when query is not found (GH-27868) 2021-08-26 14:22:02 +02:00
Noah Kantrowitz be42c06bb0
Update URLs in comments and metadata to use HTTPS (GH-27458) 2021-07-30 15:54:46 +02:00
Mariusz Felisiak 11749e2dc2
bpo-44740: Lowercase "internet" and "web" where appropriate. (#27378)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-07-27 00:11:55 +02:00
Inada Naoki 9dfefbe3e2
bpo-43651: Fix EncodingWarning in `pydoc`. (GH-25644) 2021-04-27 12:46:20 +09:00
Victor Stinner 9b999479c0
bpo-42988: Remove the pydoc getfile feature (GH-25015)
CVE-2021-3426: Remove the "getfile" feature of the pydoc module which
could be abused to read arbitrary files on the disk (directory
traversal vulnerability). Moreover, even source code of Python
modules can contain sensitive data like passwords. Vulnerability
reported by David Schwörer.
2021-03-29 14:40:40 +02:00
Julien Palard eb9983c59b
bpo-42869: Avoid an HTTP redirection. (GH-24174) 2021-01-25 15:50:14 +01:00
Lysandros Nikolaou bcd7deed91
bpo-40939: Remove PEG parser easter egg (__new_parser__) (#20802)
It no longer serves a purpose (there's only one parser) and having "new" in any name will eventually look odd. Also, it impinges on a potential sub-namespace, `__new_...__`.
2020-06-11 09:09:21 -07:00
Lysandros Nikolaou 9727694f08
bpo-40939: Generate keyword.py using the new parser (GH-20800) 2020-06-11 13:45:15 +01:00
Serhiy Storchaka 08b47c367a
bpo-40257: Revert changes to inspect.getdoc() (GH-20073) 2020-05-18 20:25:07 +03:00