Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b551e9f0
Commit
b551e9f0
authored
May 10, 2018
by
Ivan Levkivskyi
Committed by
GitHub
May 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bug in Generic.__new__ (GH-6758)
parent
df00f048
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
1 deletion
+4
-1
Lib/test/test_typing.py
Lib/test/test_typing.py
+3
-0
Lib/typing.py
Lib/typing.py
+1
-1
No files found.
Lib/test/test_typing.py
View file @
b551e9f0
...
...
@@ -1367,6 +1367,9 @@ class GenericTests(BaseTestCase):
class
A
(
Generic
[
T
]):
pass
with
self
.
assertRaises
(
TypeError
):
A
(
'foo'
)
class
B
:
def
__new__
(
cls
):
# call object
...
...
Lib/typing.py
View file @
b551e9f0
...
...
@@ -836,7 +836,7 @@ class Generic:
if
cls
is
Generic
:
raise
TypeError
(
"Type Generic cannot be instantiated; "
"it can be used only as a base class"
)
if
super
().
__new__
is
object
.
__new__
:
if
super
().
__new__
is
object
.
__new__
and
cls
.
__init__
is
not
object
.
__init__
:
obj
=
super
().
__new__
(
cls
)
else
:
obj
=
super
().
__new__
(
cls
,
*
args
,
**
kwds
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment