Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
76d982ef
Commit
76d982ef
authored
Jan 13, 2014
by
Paul Sokolovsky
Browse files
type->print(): Distinguish str() and repr() variety by passing extra param.
parent
24224d7c
Changes
25
Hide whitespace changes
Inline
Side-by-side
stm/main.c
View file @
76d982ef
...
...
@@ -436,7 +436,7 @@ void do_repl(void) {
}
}
else
{
// uncaught exception
mp_obj_print
((
mp_obj_t
)
nlr
.
ret_val
);
mp_obj_print
((
mp_obj_t
)
nlr
.
ret_val
,
PRINT_REPR
);
printf
(
"
\n
"
);
}
}
...
...
@@ -474,7 +474,7 @@ bool do_file(const char *filename) {
return
true
;
}
else
{
// uncaught exception
mp_obj_print
((
mp_obj_t
)
nlr
.
ret_val
);
mp_obj_print
((
mp_obj_t
)
nlr
.
ret_val
,
PRINT_REPR
);
printf
(
"
\n
"
);
return
false
;
}
...
...
@@ -656,7 +656,7 @@ typedef struct _pyb_file_obj_t {
FIL
fp
;
}
pyb_file_obj_t
;
void
file_obj_print
(
void
(
*
print
)(
void
*
env
,
const
char
*
fmt
,
...),
void
*
env
,
mp_obj_t
self_in
)
{
void
file_obj_print
(
void
(
*
print
)(
void
*
env
,
const
char
*
fmt
,
...),
void
*
env
,
mp_obj_t
self_in
,
mp_print_kind_t
kind
)
{
printf
(
"<file %p>"
,
self_in
);
}
...
...
@@ -1097,13 +1097,13 @@ soft_reset:
if
(
nlr_push
(
&
nlr
)
==
0
)
{
mp_obj_t
ret
=
rt_call_function_0
(
module_fun
);
printf
(
"done! got: "
);
mp_obj_print
(
ret
);
mp_obj_print
(
ret
,
PRINT_REPR
);
printf
(
"
\n
"
);
nlr_pop
();
}
else
{
// uncaught exception
printf
(
"exception: "
);
mp_obj_print
((
mp_obj_t
)
nlr
.
ret_val
);
mp_obj_print
((
mp_obj_t
)
nlr
.
ret_val
,
PRINT_REPR
);
printf
(
"
\n
"
);
}
...
...
stm/timer.c
View file @
76d982ef
...
...
@@ -89,7 +89,7 @@ void timer_interrupt(void) {
}
else
{
// uncaught exception
printf
(
"exception in timer interrupt
\n
"
);
mp_obj_print
((
mp_obj_t
)
nlr
.
ret_val
);
mp_obj_print
((
mp_obj_t
)
nlr
.
ret_val
,
PRINT_REPR
);
printf
(
"
\n
"
);
}
}
...
...
tests/basics/tests/exception1.py
View file @
76d982ef
# TODO: requires repr()
#a = IndexError(1, "test", [100, 200])
#print(repr(a))
print
(
repr
(
IndexError
()))
print
(
str
(
IndexError
()))
print
(
repr
(
IndexError
(
"foo"
)))
print
(
str
(
IndexError
(
"foo"
)))
a
=
IndexError
(
1
,
"test"
,
[
100
,
200
])
print
(
str
(
a
))
print
(
repr
(
a
))
unix/file.c
View file @
76d982ef
...
...
@@ -15,7 +15,7 @@ typedef struct _mp_obj_fdfile_t {
int
fd
;
}
mp_obj_fdfile_t
;
static
void
fdfile_print
(
void
(
*
print
)(
void
*
env
,
const
char
*
fmt
,
...),
void
*
env
,
mp_obj_t
self_in
)
{
static
void
fdfile_print
(
void
(
*
print
)(
void
*
env
,
const
char
*
fmt
,
...),
void
*
env
,
mp_obj_t
self_in
,
mp_print_kind_t
kind
)
{
mp_obj_fdfile_t
*
self
=
self_in
;
print
(
env
,
"<io.FileIO %d>"
,
self
->
fd
);
}
...
...
unix/main.c
View file @
76d982ef
...
...
@@ -63,7 +63,7 @@ static void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind
nlr_pop
();
}
else
{
// uncaught exception
mp_obj_print
((
mp_obj_t
)
nlr
.
ret_val
);
mp_obj_print
((
mp_obj_t
)
nlr
.
ret_val
,
PRINT_REPR
);
printf
(
"
\n
"
);
}
}
...
...
@@ -159,7 +159,7 @@ typedef struct _test_obj_t {
int
value
;
}
test_obj_t
;
static
void
test_print
(
void
(
*
print
)(
void
*
env
,
const
char
*
fmt
,
...),
void
*
env
,
mp_obj_t
self_in
)
{
static
void
test_print
(
void
(
*
print
)(
void
*
env
,
const
char
*
fmt
,
...),
void
*
env
,
mp_obj_t
self_in
,
mp_print_kind_t
kind
)
{
test_obj_t
*
self
=
self_in
;
print
(
env
,
"<test %d>"
,
self
->
value
);
}
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
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