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
f17380c4
Commit
f17380c4
authored
Dec 19, 2005
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #889500, fix line number on SyntaxWarning for global declarations.
parent
35fc3e93
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
Misc/NEWS
Misc/NEWS
+2
-0
Python/symtable.c
Python/symtable.c
+10
-7
No files found.
Misc/NEWS
View file @
f17380c4
...
@@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 1?
...
@@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 1?
Core and builtins
Core and builtins
-----------------
-----------------
- Bug #889500, fix line number on SyntaxWarning for global declarations.
- Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
- Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
- Support for converting hex strings to floats no longer works.
- Support for converting hex strings to floats no longer works.
...
...
Python/symtable.c
View file @
f17380c4
...
@@ -4,13 +4,16 @@
...
@@ -4,13 +4,16 @@
#include "symtable.h"
#include "symtable.h"
#include "structmember.h"
#include "structmember.h"
/*
two
error strings used for warnings */
/* error strings used for warnings */
#define GLOBAL_AFTER_ASSIGN \
#define GLOBAL_AFTER_ASSIGN \
"name '%.400s' is assigned to before global declaration"
"name '%.400s' is assigned to before global declaration"
#define GLOBAL_AFTER_USE \
#define GLOBAL_AFTER_USE \
"name '%.400s' is used prior to global declaration"
"name '%.400s' is used prior to global declaration"
#define IMPORT_STAR_WARNING "import * only allowed at module level"
PySTEntryObject
*
PySTEntryObject
*
PySTEntry_New
(
struct
symtable
*
st
,
identifier
name
,
_Py_block_ty
block
,
PySTEntry_New
(
struct
symtable
*
st
,
identifier
name
,
_Py_block_ty
block
,
void
*
key
,
int
lineno
)
void
*
key
,
int
lineno
)
...
@@ -152,7 +155,7 @@ PyTypeObject PySTEntry_Type = {
...
@@ -152,7 +155,7 @@ PyTypeObject PySTEntry_Type = {
};
};
static
int
symtable_analyze
(
struct
symtable
*
st
);
static
int
symtable_analyze
(
struct
symtable
*
st
);
static
int
symtable_warn
(
struct
symtable
*
st
,
char
*
msg
);
static
int
symtable_warn
(
struct
symtable
*
st
,
char
*
msg
,
int
lineno
);
static
int
symtable_enter_block
(
struct
symtable
*
st
,
identifier
name
,
static
int
symtable_enter_block
(
struct
symtable
*
st
,
identifier
name
,
_Py_block_ty
block
,
void
*
ast
,
int
lineno
);
_Py_block_ty
block
,
void
*
ast
,
int
lineno
);
static
int
symtable_exit_block
(
struct
symtable
*
st
,
void
*
ast
);
static
int
symtable_exit_block
(
struct
symtable
*
st
,
void
*
ast
);
...
@@ -686,10 +689,10 @@ symtable_analyze(struct symtable *st)
...
@@ -686,10 +689,10 @@ symtable_analyze(struct symtable *st)
static
int
static
int
symtable_warn
(
struct
symtable
*
st
,
char
*
msg
)
symtable_warn
(
struct
symtable
*
st
,
char
*
msg
,
int
lineno
)
{
{
if
(
PyErr_WarnExplicit
(
PyExc_SyntaxWarning
,
msg
,
st
->
st_filename
,
if
(
PyErr_WarnExplicit
(
PyExc_SyntaxWarning
,
msg
,
st
->
st_filename
,
st
->
st_cur
->
ste_
lineno
,
NULL
,
NULL
)
<
0
)
{
lineno
,
NULL
,
NULL
)
<
0
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_SyntaxWarning
))
{
if
(
PyErr_ExceptionMatches
(
PyExc_SyntaxWarning
))
{
PyErr_SetString
(
PyExc_SyntaxError
,
msg
);
PyErr_SetString
(
PyExc_SyntaxError
,
msg
);
PyErr_SyntaxLocation
(
st
->
st_filename
,
PyErr_SyntaxLocation
(
st
->
st_filename
,
...
@@ -1028,7 +1031,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
...
@@ -1028,7 +1031,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
GLOBAL_AFTER_USE
,
GLOBAL_AFTER_USE
,
c_name
);
c_name
);
if
(
!
symtable_warn
(
st
,
buf
))
if
(
!
symtable_warn
(
st
,
buf
,
s
->
lineno
))
return
0
;
return
0
;
}
}
if
(
!
symtable_add_def
(
st
,
name
,
DEF_GLOBAL
))
if
(
!
symtable_add_def
(
st
,
name
,
DEF_GLOBAL
))
...
@@ -1277,8 +1280,8 @@ symtable_visit_alias(struct symtable *st, alias_ty a)
...
@@ -1277,8 +1280,8 @@ symtable_visit_alias(struct symtable *st, alias_ty a)
}
}
else
{
else
{
if
(
st
->
st_cur
->
ste_type
!=
ModuleBlock
)
{
if
(
st
->
st_cur
->
ste_type
!=
ModuleBlock
)
{
i
f
(
!
symtable_warn
(
st
,
i
nt
lineno
=
st
->
st_cur
->
ste_lineno
;
"import * only allowed at module level"
))
{
if
(
!
symtable_warn
(
st
,
IMPORT_STAR_WARNING
,
lineno
))
{
Py_DECREF
(
store_name
);
Py_DECREF
(
store_name
);
return
0
;
return
0
;
}
}
...
...
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