[issue44985] Inconsistent returned value of inspect.getfullargspec(object.__init__).

2021-08-23 Thread Mehrzad


New submission from Mehrzad :

The inspection `inspect.getfullargspec(object.__init__)` shows that 
`object.__init__` takes both varargs (starred) and varkw (double-starred) 
arguments.* However, it is impossible to call `object.__init__` with varargs or 
varkw arguments.

If one tries to call `object.__init__(SomeClass(), ...)` with either of those 
arguments, the following error is raised:

`TypeError: SomeClass.__init__() takes exactly one argument (the instance to 
initialize)`.

This error is not raised if `SomeClass()` is replaced with some literal, e.g. a 
number.



* I can not certify whether it is intended behavior or a bug, because the 
signature of `obj.__init__` takes those arguments.

--
components: Distutils, Interpreter Core, Parser
files: object_init.py
messages: 400144
nosy: Mehrzad, dstufft, eric.araujo, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Inconsistent returned value of inspect.getfullargspec(object.__init__).
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file50229/object_init.py

___
Python tracker 
<https://bugs.python.org/issue44985>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44985] Inconsistent returned value of inspect.getfullargspec(object.__init__).

2021-08-24 Thread Mehrzad


Mehrzad  added the comment:

My suggestion:

Although both `object(...)` and `object.__init__(...)`, run through the same 
method, they are semantically and intentionally different.

1. `ObjectType(...)`; implicit call of `object.__init__`: The user intends to 
create an object. If extra arguments given, the following error should rise:

'TypeError: Obj() takes no arguments'

This error is already raised from `object.__new__` before `object.__init__` is 
invoked -- the init function is not reached at all.

2. `object.__init__(object_instance, ...)`; explicit call of `object.__init__`: 
The user intends to call the `__init__` function for some reason beyond object 
instance creation. If n-ary arguments given, the following error should *not* 
rise:

'ObjectType.__init__() takes exactly one argument (the instance to 
initialize)'


One reason I suggest the error should be eliminated is the message is 
confusing; while `object.__init__` has been called, the name of the 
non-existing `ObjectType.__init__` method appears on the error message.

3. `object_instance.__init__(...)` where `type(object_instance) == object`: 
Same behavior as (2).

4. `object_instance.__init__(...)` where `type(object_instance)` is a subclass 
of `object`: Same behavior as (3).


This is one possible solution I can think of -- which also makes the title sort 
of misleading. This is of course in the case that there are no use-cases making 
the `object.__init__` exception necessary. However, even in those cases, the 
implicit and explicit init calls might be distinguishable and the exception may 
be raised outside `object.__init__`, e.g. by the parser before calling the init.

--

___
Python tracker 
<https://bugs.python.org/issue44985>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27028] BasicInterpolation issue with %()

2016-05-15 Thread Mehrzad Irani

New submission from Mehrzad Irani:

The below code works fine with ExtendedInterpolation; however with 
BasicInterpolation it _url fails with invalid variable reference.

The INI file:
[DEFAULT]
domain=abc.labs.com

[machine-details]
compilation_machine=abc1
compilation_machine_url=%(compilation_machine).%(domain)
compilation_machine_url2=${compilation_machine}.${domain}

Python Version:
Python 3.5.1

Environment:
Arch Linux

--
components: Library (Lib)
files: bg.py
messages: 265617
nosy: i.mehrzad
priority: normal
severity: normal
status: open
title: BasicInterpolation issue with %()
type: compile error
versions: Python 3.5
Added file: http://bugs.python.org/file42859/bg.py

___
Python tracker 
<http://bugs.python.org/issue27028>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com