Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Boxiang Sun
Pyston
Commits
fe565665
Commit
fe565665
authored
Aug 21, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #130 from tjhance/fix_error_msg
fixed object.__new__ error message for >=2.7.4
parents
fe1ee643
a5cb0a5b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
4 deletions
+19
-4
src/core/options.cpp
src/core/options.cpp
+2
-0
src/core/options.h
src/core/options.h
+5
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+2
-2
src/runtime/objmodel.h
src/runtime/objmodel.h
+9
-0
src/runtime/types.cpp
src/runtime/types.cpp
+1
-1
No files found.
src/core/options.cpp
View file @
fe565665
...
...
@@ -22,6 +22,8 @@ int PYTHON_VERSION_MAJOR = DEFAULT_PYTHON_MAJOR_VERSION;
int
PYTHON_VERSION_MINOR
=
DEFAULT_PYTHON_MINOR_VERSION
;
int
PYTHON_VERSION_MICRO
=
DEFAULT_PYTHON_MICRO_VERSION
;
int
PYTHON_VERSION_HEX
=
version_hex
(
PYTHON_VERSION_MAJOR
,
PYTHON_VERSION_MINOR
,
PYTHON_VERSION_MICRO
);
int
MAX_OPT_ITERATIONS
=
1
;
bool
FORCE_OPTIMIZE
=
false
;
...
...
src/core/options.h
View file @
fe565665
...
...
@@ -22,7 +22,11 @@ extern "C" {
extern
int
GLOBAL_VERBOSITY
;
#define VERBOSITY(x) GLOBAL_VERBOSITY
// Version number we're targeting:
extern
int
PYTHON_VERSION_MAJOR
,
PYTHON_VERSION_MINOR
,
PYTHON_VERSION_MICRO
;
extern
int
PYTHON_VERSION_MAJOR
,
PYTHON_VERSION_MINOR
,
PYTHON_VERSION_MICRO
,
PYTHON_VERSION_HEX
;
inline
int
version_hex
(
int
major
,
int
minor
,
int
micro
,
int
level
=
0
,
int
serial
=
0
)
{
return
(
major
<<
24
)
|
(
minor
<<
16
)
|
(
micro
<<
8
)
|
(
level
<<
4
)
|
(
serial
<<
0
);
}
extern
int
MAX_OPT_ITERATIONS
;
...
...
src/runtime/objmodel.cpp
View file @
fe565665
...
...
@@ -3241,7 +3241,7 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp
ArgPassSpec
new_argspec
=
argspec
;
if
(
npassed_args
>
1
&&
new_attr
==
typeLookup
(
object_cls
,
_new_str
,
NULL
))
{
if
(
init_attr
==
typeLookup
(
object_cls
,
_init_str
,
NULL
))
{
raiseExcHelper
(
TypeError
,
"object.__new__() takes no parameters"
);
raiseExcHelper
(
TypeError
,
objectNewParameterTypeErrorMsg
()
);
}
else
{
new_argspec
=
ArgPassSpec
(
1
);
}
...
...
@@ -3315,7 +3315,7 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp
// assert(0 && "I don't think this should be reached");
if
(
new_attr
==
NULL
&&
npassed_args
!=
1
)
{
// TODO not npassed args, since the starargs or kwargs could be null
raiseExcHelper
(
TypeError
,
"object.__new__() takes no parameters"
);
raiseExcHelper
(
TypeError
,
objectNewParameterTypeErrorMsg
()
);
}
}
...
...
src/runtime/objmodel.h
View file @
fe565665
...
...
@@ -18,6 +18,7 @@
#include <stdint.h>
#include <string>
#include "core/options.h"
#include "core/types.h"
namespace
pyston
{
...
...
@@ -118,5 +119,13 @@ bool isUserDefined(BoxedClass* cls);
Box
*
callCLFunc
(
CLFunction
*
f
,
CallRewriteArgs
*
rewrite_args
,
int
num_output_args
,
BoxedClosure
*
closure
,
BoxedGenerator
*
generator
,
Box
*
oarg1
,
Box
*
oarg2
,
Box
*
oarg3
,
Box
**
oargs
);
static
const
char
*
objectNewParameterTypeErrorMsg
()
{
if
(
PYTHON_VERSION_HEX
>=
version_hex
(
2
,
7
,
4
))
{
return
"object() takes no parameters"
;
}
else
{
return
"object.__new__() takes no parameters"
;
}
}
}
#endif
src/runtime/types.cpp
View file @
fe565665
...
...
@@ -579,7 +579,7 @@ Box* objectNew(BoxedClass* cls, BoxedTuple* args) {
if
(
args
->
elts
.
size
()
!=
0
)
{
// TODO slow
if
(
typeLookup
(
cls
,
"__init__"
,
NULL
)
==
typeLookup
(
object_cls
,
"__init__"
,
NULL
))
raiseExcHelper
(
TypeError
,
"object.__new__() takes no parameters"
);
raiseExcHelper
(
TypeError
,
objectNewParameterTypeErrorMsg
()
);
}
assert
(
cls
->
tp_basicsize
>=
sizeof
(
Box
));
...
...
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