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
732436e4
Commit
732436e4
authored
Dec 21, 2001
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge of the release22 branch changes back into the trunk.
parent
b130ea76
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
7 deletions
+80
-7
Lib/compiler/ast.py
Lib/compiler/ast.py
+15
-0
Lib/compiler/pycodegen.py
Lib/compiler/pycodegen.py
+9
-3
Lib/compiler/symbols.py
Lib/compiler/symbols.py
+2
-0
Lib/compiler/transformer.py
Lib/compiler/transformer.py
+1
-1
Lib/test/test_cpickle.py
Lib/test/test_cpickle.py
+7
-0
Misc/NEWS
Misc/NEWS
+41
-0
Modules/cPickle.c
Modules/cPickle.c
+5
-3
No files found.
Lib/compiler/ast.py
View file @
732436e4
...
...
@@ -282,6 +282,21 @@ class Module(Node):
def
__repr__
(
self
):
return
"Module(%s, %s)"
%
(
repr
(
self
.
doc
),
repr
(
self
.
node
))
class
Expression
(
Node
):
# Expression is an artifical node class to support "eval"
nodes
[
"expression"
]
=
"Expression"
def
__init__
(
self
,
node
):
self
.
node
=
node
def
getChildren
(
self
):
return
self
.
node
,
def
getChildNodes
(
self
):
return
self
.
node
,
def
__repr__
(
self
):
return
"Expression(%s)"
%
(
repr
(
self
.
node
))
class
UnaryAdd
(
Node
):
nodes
[
"unaryadd"
]
=
"UnaryAdd"
def
__init__
(
self
,
expr
):
...
...
Lib/compiler/pycodegen.py
View file @
732436e4
...
...
@@ -34,6 +34,7 @@ EXCEPT = 2
TRY_FINALLY
=
3
END_FINALLY
=
4
# XXX this doesn't seem to be used
class
BlockStack
(
misc
.
Stack
):
__super_init
=
misc
.
Stack
.
__init__
...
...
@@ -351,6 +352,13 @@ class CodeGenerator:
self
.
emit
(
'LOAD_CONST'
,
None
)
self
.
emit
(
'RETURN_VALUE'
)
def
visitExpression
(
self
,
node
):
self
.
set_lineno
(
node
)
self
.
scopes
=
self
.
parseSymbols
(
node
)
self
.
scope
=
self
.
scopes
[
node
]
self
.
visit
(
node
.
node
)
self
.
emit
(
'RETURN_VALUE'
)
def
visitFunction
(
self
,
node
):
self
.
_visitFuncOrLambda
(
node
,
isLambda
=
0
)
if
node
.
doc
:
...
...
@@ -1158,9 +1166,7 @@ class ExpressionCodeGenerator(NestedScopeMixin, CodeGenerator):
def
__init__
(
self
,
tree
):
self
.
graph
=
pyassem
.
PyFlowGraph
(
"<expression>"
,
tree
.
filename
)
self
.
__super_init
()
self
.
set_lineno
(
tree
)
walk
(
tree
,
self
)
self
.
emit
(
'RETURN_VALUE'
)
def
get_module
(
self
):
return
self
...
...
@@ -1181,6 +1187,7 @@ class InteractiveCodeGenerator(NestedScopeMixin, CodeGenerator):
def
get_module
(
self
):
return
self
def
visitDiscard
(
self
,
node
):
# XXX Discard means it's an expression. Perhaps this is a bad
# name.
...
...
@@ -1299,7 +1306,6 @@ class ClassCodeGenerator(NestedScopeMixin, AbstractClassCode, CodeGenerator):
self
.
__super_init
(
klass
,
scopes
,
module
)
self
.
graph
.
setFreeVars
(
self
.
scope
.
get_free_vars
())
self
.
graph
.
setCellVars
(
self
.
scope
.
get_cell_vars
())
## self.graph.setFlag(CO_NESTED)
def
generateArgList
(
arglist
):
"""Generate an arg list marking TupleArgs"""
...
...
Lib/compiler/symbols.py
View file @
732436e4
...
...
@@ -206,6 +206,8 @@ class SymbolVisitor:
scope
=
self
.
module
=
self
.
scopes
[
node
]
=
ModuleScope
()
self
.
visit
(
node
.
node
,
scope
)
visitExpression
=
visitModule
def
visitFunction
(
self
,
node
,
parent
):
parent
.
add_def
(
node
.
name
)
for
n
in
node
.
defaults
:
...
...
Lib/compiler/transformer.py
View file @
732436e4
...
...
@@ -172,7 +172,7 @@ class Transformer:
def
eval_input
(
self
,
nodelist
):
# from the built-in function input()
### is this sufficient?
return
self
.
com_node
(
nodelist
[
0
]
)
return
Expression
(
self
.
com_node
(
nodelist
[
0
])
)
def
funcdef
(
self
,
nodelist
):
# funcdef: 'def' NAME parameters ':' suite
...
...
Lib/test/test_cpickle.py
View file @
732436e4
...
...
@@ -80,6 +80,13 @@ class cPickleFastPicklerTests(AbstractPickleTests):
AbstractPickleTests
.
test_recursive_multi
,
self
)
def
test_nonrecursive_deep
(
self
):
a
=
[]
for
i
in
range
(
100
):
a
=
[
a
]
b
=
self
.
loads
(
self
.
dumps
(
a
))
self
.
assertEqual
(
a
,
b
)
def
test_main
():
loader
=
unittest
.
TestLoader
()
suite
=
unittest
.
TestSuite
()
...
...
Misc/NEWS
View file @
732436e4
...
...
@@ -4,12 +4,38 @@ Release date: 21-Dec-2001
Type/class unification and new-style classes
- pickle.py, cPickle: allow pickling instances of new-style classes
with a custom metaclass.
Core and builtins
- weakref proxy object: when comparing, unwrap both arguments if both
are proxies.
Extension modules
- binascii.b2a_base64(): fix a potential buffer overrun when encoding
very short strings.
- cPickle: the obscure "fast" mode was suspected of causing stack
overflows on the Mac. Hopefully fixed this by setting the recursion
limit much smaller. If the limit is too low (it only affects
performance), you can change it by defining PY_CPICKLE_FAST_LIMIT
when compiling cPickle.c (or in pyconfig.h).
Library
- dumbdbm.py: fixed a dumb old bug (the file didn't get synched at
close or delete time).
- rfc822.py: fixed a bug where the address '<>' was converted to None
instead of an empty string (also fixes the email.Utils module).
- xmlrpclib.py: version 1.0.0; uses precision for doubles.
- test suite: the pickle and cPickle tests were not executing any code
when run from the standard regresssion test.
Tools/Demos
Build
...
...
@@ -22,8 +48,23 @@ Tests
Windows
- distutils package: fixed broken Windows installers (bdist_wininst).
- tempfile.py: prevent mysterious warnings when TemporaryFileWrapper
instances are deleted at process exit time.
- socket.py: prevent mysterious warnings when socket instances are
deleted at process exit time.
- posixmodule.c: fix a Windows crash with stat() of a filename ending
in backslash.
Mac
- The Carbon toolbox modules have been upgraded to Universal Headers
3.4, and experimental CoreGraphics and CarbonEvents modules have
been added. All only for framework-enabled MacOSX.
What's New in Python 2.2c1?
Release date: 14-Dec-2001
...
...
Modules/cPickle.c
View file @
732436e4
...
...
@@ -321,7 +321,9 @@ typedef struct Picklerobject {
PyObject
*
fast_memo
;
}
Picklerobject
;
#define FAST_LIMIT 2000
#ifndef PY_CPICKLE_FAST_LIMIT
#define PY_CPICKLE_FAST_LIMIT 50
#endif
staticforward
PyTypeObject
Picklertype
;
...
...
@@ -891,7 +893,7 @@ static int
fast_save_enter
(
Picklerobject
*
self
,
PyObject
*
obj
)
{
/* if fast_container < 0, we're doing an error exit. */
if
(
++
self
->
fast_container
>=
FAST_LIMIT
)
{
if
(
++
self
->
fast_container
>=
PY_CPICKLE_
FAST_LIMIT
)
{
PyObject
*
key
=
NULL
;
if
(
self
->
fast_memo
==
NULL
)
{
self
->
fast_memo
=
PyDict_New
();
...
...
@@ -921,7 +923,7 @@ fast_save_enter(Picklerobject *self, PyObject *obj)
int
fast_save_leave
(
Picklerobject
*
self
,
PyObject
*
obj
)
{
if
(
self
->
fast_container
--
>=
FAST_LIMIT
)
{
if
(
self
->
fast_container
--
>=
PY_CPICKLE_
FAST_LIMIT
)
{
PyObject
*
key
=
PyLong_FromVoidPtr
(
obj
);
if
(
key
==
NULL
)
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