Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 674
    • Issues 674
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPy
  • pypypypy
  • Issues
  • #3534
Closed
Open
Created Aug 14, 2021 by Elliott S@QuLogic

inspect.getdoc return different value with -OO

In CPython, inspect.getdoc is documented to retrieve the documentation string from the inheritance hierarchy when not provided. This is the case for things even if they have an existing docstring, when -OO is passed.

Example script:

import inspect


class Foo:
    def __init__(self):
        """Foo init"""


print(inspect.getdoc(Foo.__init__))

On CPython:

$ python --version
Python 3.7.6
$ python foo.py 
Foo init
$ python -OO foo.py 
Initialize self.  See help(type(self)) for accurate signature.

On PyPy though, it returns None:

$ python --version
Python 3.7.10 (76f47b474df0, Aug 11 2021, 11:41:05)
[PyPy 7.3.4 with GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]
$ python foo.py 
Foo init
$ python -OO foo.py 
None
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking