Bug 2366250

Summary: python-faker fails to build with Python 3.14: FactoryTestCase.test_documentor: AttributeError: 'function' object has no attribute 'JSONEncoder'
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-fakerAssignee: Juan Orti Alcaine <jorti>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: jorti, ksurma, mhroncok, mikel
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-06-15 18:34:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2322407    

Description Karolina Surma 2025-05-14 14:49:57 UTC
python-faker fails to build with Python 3.14.0b1.

_______________________ FactoryTestCase.test_documentor ________________________

func = <bound method Provider.json of <faker.providers.misc.en_US.Provider object at 0x7f5dd82c9450>>

    def getfullargspec(func):
        """Get the names and default values of a callable object's parameters.
    
        A tuple of seven things is returned:
        (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations).
        'args' is a list of the parameter names.
        'varargs' and 'varkw' are the names of the * and ** parameters or None.
        'defaults' is an n-tuple of the default values of the last n parameters.
        'kwonlyargs' is a list of keyword-only parameter names.
        'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults.
        'annotations' is a dictionary mapping parameter names to annotations.
    
        Notable differences from inspect.signature():
          - the "self" parameter is always reported, even for bound methods
          - wrapper chains defined by __wrapped__ *not* unwrapped automatically
        """
        try:
            # Re: `skip_bound_arg=False`
            #
            # There is a notable difference in behaviour between getfullargspec
            # and Signature: the former always returns 'self' parameter for bound
            # methods, whereas the Signature always shows the actual calling
            # signature of the passed object.
            #
            # To simulate this behaviour, we "unbind" bound methods, to trick
            # inspect.signature to always return their first parameter ("self",
            # usually)
    
            # Re: `follow_wrapper_chains=False`
            #
            # getfullargspec() historically ignored __wrapped__ attributes,
            # so we ensure that remains the case in 3.3+
    
>           sig = _signature_from_callable(func,
                                           follow_wrapper_chains=False,
                                           skip_bound_arg=False,
                                           sigcls=Signature,
                                           eval_str=False)

/usr/lib64/python3.14/inspect.py:1261: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python3.14/inspect.py:2433: in _signature_from_callable
    sig = _get_signature_of(obj.__func__)
/usr/lib64/python3.14/inspect.py:2504: in _signature_from_callable
    return _signature_from_function(sigcls, obj,
/usr/lib64/python3.14/inspect.py:2327: in _signature_from_function
    annotations = get_annotations(func, globals=globals, locals=locals, eval_str=eval_str,
/usr/lib64/python3.14/annotationlib.py:866: in get_annotations
    ann = _get_and_call_annotate(obj, format)
/usr/lib64/python3.14/annotationlib.py:1002: in _get_and_call_annotate
    ann = call_annotate_function(annotate, format, owner=obj)
/usr/lib64/python3.14/annotationlib.py:630: in call_annotate_function
    return annotate(format)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

format = <Format.VALUE: 1>

    def json(
        self,
        data_columns: Optional[List] = None,
        num_rows: int = 10,
        indent: Optional[int] = None,
>       cls: Optional[Type[json.JSONEncoder]] = None,
    ) -> str:
E   AttributeError: 'function' object has no attribute 'JSONEncoder'

../BUILDROOT/usr/lib/python3.14/site-packages/faker/providers/misc/__init__.py:518: AttributeError

The above exception was the direct cause of the following exception:

self = <tests.test_factory.FactoryTestCase testMethod=test_documentor>

    def test_documentor(self):
        from faker.cli import print_doc
    
        output = io.StringIO()
>       print_doc(output=output)

tests/test_factory.py:24: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../BUILDROOT/usr/lib/python3.14/site-packages/faker/cli.py:107: in print_doc
    formatters = doc.get_formatters(with_args=True, with_defaults=True, excludes=unsupported)
../BUILDROOT/usr/lib/python3.14/site-packages/faker/documentor.py:44: in get_formatters
    (provider, self.get_provider_formatters(provider, **kwargs)),
../BUILDROOT/usr/lib/python3.14/site-packages/faker/documentor.py:81: in get_provider_formatters
    argspec = inspect.getfullargspec(method)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

func = <bound method Provider.json of <faker.providers.misc.en_US.Provider object at 0x7f5dd82c9450>>

    def getfullargspec(func):
        """Get the names and default values of a callable object's parameters.
    
        A tuple of seven things is returned:
        (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations).
        'args' is a list of the parameter names.
        'varargs' and 'varkw' are the names of the * and ** parameters or None.
        'defaults' is an n-tuple of the default values of the last n parameters.
        'kwonlyargs' is a list of keyword-only parameter names.
        'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults.
        'annotations' is a dictionary mapping parameter names to annotations.
    
        Notable differences from inspect.signature():
          - the "self" parameter is always reported, even for bound methods
          - wrapper chains defined by __wrapped__ *not* unwrapped automatically
        """
        try:
            # Re: `skip_bound_arg=False`
            #
            # There is a notable difference in behaviour between getfullargspec
            # and Signature: the former always returns 'self' parameter for bound
            # methods, whereas the Signature always shows the actual calling
            # signature of the passed object.
            #
            # To simulate this behaviour, we "unbind" bound methods, to trick
            # inspect.signature to always return their first parameter ("self",
            # usually)
    
            # Re: `follow_wrapper_chains=False`
            #
            # getfullargspec() historically ignored __wrapped__ attributes,
            # so we ensure that remains the case in 3.3+
    
            sig = _signature_from_callable(func,
                                           follow_wrapper_chains=False,
                                           skip_bound_arg=False,
                                           sigcls=Signature,
                                           eval_str=False)
        except Exception as ex:
            # Most of the times 'signature' will raise ValueError.
            # But, it can also raise AttributeError, and, maybe something
            # else. So to be fully backwards compatible, we catch all
            # possible exceptions here, and reraise a TypeError.
>           raise TypeError('unsupported callable') from ex
E           TypeError: unsupported callable

/usr/lib64/python3.14/inspect.py:1271: TypeError
=========================== short test summary info ============================
FAILED tests/test_factory.py::FactoryTestCase::test_documentor - TypeError: u...

https://docs.python.org/3.14/whatsnew/3.14.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14-b1/fedora-rawhide-x86_64/09037352-python-faker/

For all our attempts to build python-faker with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14-b1/package/python-faker/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14-b1/

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.