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
e2b2ea45
Commit
e2b2ea45
authored
Dec 10, 1991
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new exceptions.
parent
f833f798
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
4 deletions
+25
-4
Python/bltinmodule.c
Python/bltinmodule.c
+25
-4
No files found.
Python/bltinmodule.c
View file @
e2b2ea45
...
...
@@ -66,7 +66,7 @@ builtin_chr(self, v)
}
x
=
getintvalue
(
v
);
if
(
x
<
0
||
x
>=
256
)
{
err_setstr
(
Runtim
eError
,
"chr() arg not in range(256)"
);
err_setstr
(
Valu
eError
,
"chr() arg not in range(256)"
);
return
NULL
;
}
s
[
0
]
=
x
;
...
...
@@ -335,7 +335,7 @@ min_max(v, sign)
}
n
=
(
*
sq
->
sq_length
)(
v
);
if
(
n
==
0
)
{
err_setstr
(
Runtim
eError
,
"min() or max() of empty sequence"
);
err_setstr
(
Valu
eError
,
"min() or max() of empty sequence"
);
return
NULL
;
}
w
=
(
*
sq
->
sq_item
)(
v
,
0
);
/* Implies INCREF */
...
...
@@ -417,7 +417,7 @@ builtin_ord(self, v)
return
NULL
;
}
if
(
getstringsize
(
v
)
!=
1
)
{
err_setstr
(
Runtim
eError
,
"ord() arg must have length 1"
);
err_setstr
(
Valu
eError
,
"ord() arg must have length 1"
);
return
NULL
;
}
return
newintobject
((
long
)(
getstringvalue
(
v
)[
0
]
&
0xff
));
...
...
@@ -488,7 +488,7 @@ builtin_range(self, v)
ilow
=
0
;
}
if
(
istep
==
0
)
{
err_setstr
(
Runtim
eError
,
"zero step for range()"
);
err_setstr
(
Valu
eError
,
"zero step for range()"
);
return
NULL
;
}
/* XXX ought to check overflow of subtraction */
...
...
@@ -594,6 +594,15 @@ object *NameError;
object
*
SystemError
;
object
*
KeyboardInterrupt
;
/* New exceptions */
object
*
AttributeError
;
object
*
IOError
;
object
*
ZeroDivisionError
;
object
*
IndexError
;
object
*
ValueError
;
object
*
KeyError
;
object
*
OverflowError
;
static
object
*
newstdexception
(
name
,
message
)
char
*
name
,
*
message
;
...
...
@@ -615,6 +624,18 @@ initerrors()
SystemError
=
newstdexception
(
"SystemError"
,
"system error"
);
KeyboardInterrupt
=
newstdexception
(
"KeyboardInterrupt"
,
"keyboard interrupt"
);
/* New exceptions */
AttributeError
=
newstdexception
(
"AttributeError"
,
"undefined attribute"
);
IOError
=
newstdexception
(
"IOError"
,
"I/O error"
);
ZeroDivisionError
=
newstdexception
(
"ZeroDivisionError"
,
"division by zero"
);
IndexError
=
newstdexception
(
"IndexError"
,
"index out of range"
);
ValueError
=
newstdexception
(
"ValueError"
,
"unacceptable value"
);
KeyError
=
newstdexception
(
"KeyError"
,
"invalid key"
);
OverflowError
=
newstdexception
(
"OverflowError"
,
"arithmetic overflow"
);
}
void
...
...
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