Revision: 5206
http://jython.svn.sourceforge.net/jython/?rev=5206&view=rev
Author: fwierzbicki
Date: 2008-08-19 21:06:39 +0000 (Tue, 19 Aug 2008)
Log Message:
-----------
Merged revisions 4386,4388-4390,4392,4403,4405,4408,4418,4424-4425,4434,4466,4474,4490,4493,4496,4499-4501,4504,4523-4524,4548-4549,4577-4579,4581-4582,4585-4589,4599-4600,4603-4605,4607-4608,4613,4628,4640,4642-4643,4648,4652-4662,4665,4667,4672,4676,4678-4680,4682,4684,4693-4695,4704-4706,4708-4712,4714-4715,4720,4729,4732-4735,4740-4751,4753-4758,4761-4765,4767-4772,4774,4777-4779,4781-4802,4806-4810,4821-4843,4845-4850,4852-4853,4855-4857,4859,4863-4870,4876-4885,4887-4897,4901-4914,4916-4919,4922,4924-4925,4928,4930,4932-4937,4939-4945,4947,4949-4952,4959,4961,4963,4965,4967-4971,4973-4974,4980,4982-5100,5102-5117,5119-5166,5168-5197 via svnmerge from
https://jython.svn.sourceforge.net/svnroot/jython/branches/asm
........
r4386 | fwierzbicki | 2008-05-08 14:55:44 -0400 (Thu, 08 May 2008) | 2 lines
Recreate asmified old compiler.
........
r4388 | fwierzbicki | 2008-05-10 13:19:27 -0400 (Sat, 10 May 2008) | 3 lines
Hand merged changes in trunk to copiler code. Removed Attribute support --
needs to be replaced by either ASM Attributes or Annotations.
........
r4389 | fwierzbicki | 2008-05-12 13:48:35 -0400 (Mon, 12 May 2008) | 4 lines
Reworked Code.java back towards old API (so methods like code.dup() are back
so it is not necessary to use code.visitInsn(DUP). This makes it easier to
read the code and to compare with the old code base.
........
r4390 | fwierzbicki | 2008-05-12 22:00:02 -0400 (Mon, 12 May 2008) | 2 lines
Converted everything over to antlr from javacc.
........
r4392 | fwierzbicki | 2008-05-13 15:38:04 -0400 (Tue, 13 May 2008) | 3 lines
Moved more code to older style Code.java methods (still based on ASM).
Added Visitor and ParseException.
........
r4403 | fwierzbicki | 2008-05-15 12:39:30 -0400 (Thu, 15 May 2008) | 2 lines
Enough compiler and parser tweaking to keep site.py from exploding.
........
r4405 | fwierzbicki | 2008-05-15 15:18:26 -0400 (Thu, 15 May 2008) | 2 lines
Fix for "from mod import *" and start of setline support.
........
r4408 | fwierzbicki | 2008-05-15 19:29:22 -0400 (Thu, 15 May 2008) | 2 lines
Temporary fix for line number problems causing NPEs.
........
r4418 | fwierzbicki | 2008-05-17 12:20:34 -0400 (Sat, 17 May 2008) | 2 lines
Remove old parser.
........
r4424 | fwierzbicki | 2008-05-20 13:39:32 -0400 (Tue, 20 May 2008) | 4 lines
Added a shell script to run Jython. This was adapted from a script from the JRuby project.
I also included the same suport for The Java Interactive Profiler (JIP) that JRuby includes.
See http://jiprof.sourceforge.net/
........
r4425 | fwierzbicki | 2008-05-20 13:50:01 -0400 (Tue, 20 May 2008) | 2 lines
Alter profile.properties for Jython.
........
r4434 | pjenvey | 2008-05-20 17:11:36 -0400 (Tue, 20 May 2008) | 1 line
missed one part of the PyMethod constructor signature change in r4400, from trunk
........
r4466 | fwierzbicki | 2008-05-27 22:05:18 -0400 (Tue, 27 May 2008) | 12 lines
Now that things are close to working, time to completely
destroy things again. Switched to pulling in 2.5 Python
libraries. Took first baby step by attempting to support
def f():
yield
which is not valid 2.3 syntax. (This is actually what
motivated this -- I was about to "fix" the grammar to
disallow this when I accidentally noticed that it was
valid 2.5 syntax.
........
r4474 | fwierzbicki | 2008-05-29 15:34:22 -0400 (Thu, 29 May 2008) | 2 lines
First stab at decorator support.
........
r4490 | fwierzbicki | 2008-05-30 11:19:42 -0400 (Fri, 30 May 2008) | 15 lines
Begin experimenting with a partial parser -- that is a recognizer
that will be able to tell if a string of code from an interactive
session is a true syntax error, or if it is part of a potentially
valid string of code. For example, in the interactive session:
>>> s = """
... hello
Is the start of a valid string, and should be recognized as a
valid partial parse. On the other hand
>>> print ,
Is still a syntax error.
........
r4493 | nriley | 2008-06-01 15:50:00 -0400 (Sun, 01 Jun 2008) | 1 line
add ImportWarning; update exceptions class doc to 2.5
........
r4496 | fwierzbicki | 2008-06-01 20:11:03 -0400 (Sun, 01 Jun 2008) | 2 lines
Need to see exception print outs.
........
r4499 | fwierzbicki | 2008-06-01 21:03:08 -0400 (Sun, 01 Jun 2008) | 2 lines
Switched to 2.4 CPython lib.
........
r4500 | nriley | 2008-06-01 21:59:37 -0400 (Sun, 01 Jun 2008) | 1 line
startswith/endswith on str/unicode, passes test_str from 2.5
........
r4501 | nriley | 2008-06-01 22:34:18 -0400 (Sun, 01 Jun 2008) | 1 line
TypeError rather than NotImplemented for wrong type on str.__mul__, fixes test_mul
........
r4504 | nriley | 2008-06-01 23:55:14 -0400 (Sun, 01 Jun 2008) | 1 line
r4500 broke http://pylonshq.com/pasties/827, reverting
........
r4523 | fwierzbicki | 2008-06-03 02:39:41 -0400 (Tue, 03 Jun 2008) | 6 lines
Most of this change is generated -- the real code changes
are in Python.g, PythonWalker.g, and asdl_antlr.py.
Moving to antlr 3.1 style of AST production. Changed the
Num processing only so far.
........
r4524 | fwierzbicki | 2008-06-03 10:47:46 -0400 (Tue, 03 Jun 2008) | 6 lines
Moved Str processing from PythonWalker.g to Python.g. Made Unicode and Str
hold PyUnicode and PyString objects instead of java.lang.String objects.
This will help compatibility with CPython AST -- though *may* hurt performance
more investigation will be needed. Certainly the way CodeCompiler is working
will need adjustment if this strategy is the way to go.
........
r4548 | nriley | 2008-06-06 16:48:42 -0400 (Fri, 06 Jun 2008) | 1 line
sync sre opcodes with Python 2.4; implement SRE_OP_GROUPREF_EXISTS
........
r4549 | nriley | 2008-06-06 17:12:40 -0400 (Fri, 06 Jun 2008) | 1 line
fix comment typo
........
r4577 | nriley | 2008-06-08 22:14:13 -0400 (Sun, 08 Jun 2008) | 1 line
Jython-specific test_cmd_line
........
r4578 | fwierzbicki | 2008-06-08 22:34:43 -0400 (Sun, 08 Jun 2008) | 2 lines
Generator Expressions.
........
r4579 | nriley | 2008-06-08 22:39:10 -0400 (Sun, 08 Jun 2008) | 1 line
fix regrtest ant target dependencies so it works from clean
........
r4581 | fwierzbicki | 2008-06-08 22:58:09 -0400 (Sun, 08 Jun 2008) | 3 lines
Better name for comprehension local var (comp instead of lc -- originally
stolen from the list comprehension code).
........
r4582 | nriley | 2008-06-08 23:09:46 -0400 (Sun, 08 Jun 2008) | 1 line
cookielib works now
........
r4585 | fwierzbicki | 2008-06-09 09:06:46 -0400 (Mon, 09 Jun 2008) | 2 lines
Conditional Expression
........
r4586 | fwierzbicki | 2008-06-09 10:10:41 -0400 (Mon, 09 Jun 2008) | 3 lines
switch to _(1_1) style names for the temporaries of gen expressions, so that vars
with unlikely but possible names like __gen1_1 do not get clobbered.
........
r4587 | nriley | 2008-06-09 17:19:49 -0400 (Mon, 09 Jun 2008) | 1 line
provenance of test_cmd_line
........
r4588 | fwierzbicki | 2008-06-09 22:29:18 -0400 (Mon, 09 Jun 2008) | 2 lines
Remove unnecessary vars.
........
r4589 | fwierzbicki | 2008-06-10 07:40:31 -0400 (Tue, 10 Jun 2008) | 2 lines
Remove comment that I no longer believe :)
........
r4599 | fwierzbicki | 2008-06-11 17:26:33 -0400 (Wed, 11 Jun 2008) | 6 lines
Make ParseException the only exception that comes out of the antlr
parsing. Unfortunately I haven't figured out how to remove
"throws RecognitionException" from the generated code, so some
references remain. Also renamed PythonGrammer -> ModuleParser, and
some other related refactorings.
........
r4600 | fwierzbicki | 2008-06-11 17:40:36 -0400 (Wed, 11 Jun 2008) | 2 lines
More descriptive name antlr.java -> ParserFacade.java
........
r4603 | fwierzbicki | 2008-06-11 21:34:06 -0400 (Wed, 11 Jun 2008) | 4 lines
Added a null guard for lexing errors (they have no token) and added an
experimental getOffset() method on ParseException which intends to get
the char position from the start of the file where the error occured.
........
r4604 | fwierzbicki | 2008-06-11 21:38:05 -0400 (Wed, 11 Jun 2008) | 2 lines
Crap, left in debugging. Removed.
........
r4605 | fwierzbicki | 2008-06-11 22:14:26 -0400 (Wed, 11 Jun 2008) | 2 lines
Fix offset for lexer errors.
........
r4607 | fwierzbicki | 2008-06-12 11:27:35 -0400 (Thu, 12 Jun 2008) | 2 lines
oops, wrong directory position.
........
r4608 | fwierzbicki | 2008-06-12 17:08:38 -0400 (Thu, 12 Jun 2008) | 5 lines
pep 263. There is some roughness remaining, especially a strange
problem around utf-8 that I need to look into (I ended up letting
Jython go with its default in the case of a utf-8 encoding
specified for now).
........
r4613 | fwierzbicki | 2008-06-13 13:33:31 -0400 (Fri, 13 Jun 2008) | 4 lines
Add a token source for partial parsing (for now -- can probably become
a subclass of PythonTokenSource once the kinks are out). Unterminated
triple strings now pass.
........
r4628 | zyasoft | 2008-06-14 19:23:52 -0400 (Sat, 14 Jun 2008) | 1 line
Added visitWith to support the with-statement. Changed ClassFile so that it does frame analysis with COMPUTE_FRAMES (used by Java 6, seems OK with Java 5 - and prevents code from being compiled that would fail bytecode verifier. Generally that would be a good thing. Fixed threading.Lock.__enter__ so it returns the lock object, not just do an acquire.
........
r4640 | zyasoft | 2008-06-15 01:13:59 -0400 (Sun, 15 Jun 2008) | 1 line
Changed Code.ldc such that for large string constants (>32767 char), it splits into chunked ldcsand assembles with a StringBuilder
........
r4642 | nriley | 2008-06-15 17:45:22 -0400 (Sun, 15 Jun 2008) | 1 line
jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r179
........
r4643 | nriley | 2008-06-15 18:04:11 -0400 (Sun, 15 Jun 2008) | 1 line
os.stat, chmod, getegid, geteuid, getgid, getlogin, getpgrp, getpid, getppid, getuid, setpgrp, setsid via jna-posix
........
r4648 | nriley | 2008-06-16 01:23:39 -0400 (Mon, 16 Jun 2008) | 1 line
enable test_posix
........
r4652 | fwierzbicki | 2008-06-16 15:23:38 -0400 (Mon, 16 Jun 2008) | 3 lines
Extrated PythonTreeAdaptor from the *Parser classes, some
work to improve offsets.
........
r4653 | zyasoft | 2008-06-16 15:51:12 -0400 (Mon, 16 Jun 2008) | 1 line
Now supports coroutines. At this point, I have only done limited testing, especially with respect to exceptions.
........
r4654 | fwierzbicki | 2008-06-16 16:35:50 -0400 (Mon, 16 Jun 2008) | 2 lines
More offset work for IDE support.
........
r4655 | zyasoft | 2008-06-16 18:54:40 -0400 (Mon, 16 Jun 2008) | 1 line
Reordered public members of PyGenerator so that dir will have the same order as CPython
........
r4656 | fwierzbicki | 2008-06-16 19:11:25 -0400 (Mon, 16 Jun 2008) | 2 lines
Move some imaginary tokens to concrete tokens.
........
r4657 | zyasoft | 2008-06-16 20:21:52 -0400 (Mon, 16 Jun 2008) | 1 line
Added support of __future__.with_statement; this includes aligning PyTableCode with __future__.py as of 2.5. Does not yet support interactive future import of the with_statement, however
........
r4658 | fwierzbicki | 2008-06-16 20:26:20 -0400 (Mon, 16 Jun 2008) | 3 lines
pass statement turned to concrete token. Also preparing to absorb more
of PythonWalker.g into Python.g.
........
r4659 | pjenvey | 2008-06-16 20:42:38 -0400 (Mon, 16 Jun 2008) | 1 line
we want the absolute path here
........
r4660 | fwierzbicki | 2008-06-16 22:34:20 -0400 (Mon, 16 Jun 2008) | 3 lines
parameter passing that I am not using yet. Will be crucial for a
one pass parse.
........
r4661 | fwierzbicki | 2008-06-16 22:47:21 -0400 (Mon, 16 Jun 2008) | 2 lines
break and continue only newed in Python.g
........
r4662 | fwierzbicki | 2008-06-17 11:12:43 -0400 (Tue, 17 Jun 2008) | 2 lines
Slowly adding more needed params to Python.g from PythonWalker.g.
........
r4665 | fwierzbicki | 2008-06-18 10:59:31 -0400 (Wed, 18 Jun 2008) | 3 lines
Introduce an ENDMARK imaginary token to handle unfinished but
partially valid statements.
........
r4667 | fwierzbicki | 2008-06-18 16:21:10 -0400 (Wed, 18 Jun 2008) | 2 lines
Incremental improvement on interactive mode.
........
r4672 | fwierzbicki | 2008-06-18 21:26:41 -0400 (Wed, 18 Jun 2008) | 3 lines
Fix PythonPartialTester. Added some info to toStringTree output of
PythonTree.
........
r4676 | fwierzbicki | 2008-06-19 11:30:05 -0400 (Thu, 19 Jun 2008) | 3 lines
Added an ImaginaryToken type so that the char positions of
INDENT and DEDENT can be easily tracked.
........
r4678 | fwierzbicki | 2008-06-19 13:58:08 -0400 (Thu, 19 Jun 2008) | 2 lines
Replace many imaginary tokens with concrete tokens.
........
r4679 | fwierzbicki | 2008-06-19 18:31:55 -0400 (Thu, 19 Jun 2008) | 2 lines
whitespace
........
r4680 | fwierzbicki | 2008-06-19 19:50:49 -0400 (Thu, 19 Jun 2008) | 2 lines
Update comments and rule positions compared to CPython's Grammar/Grammar
........
r4682 | pjenvey | 2008-06-19 20:07:46 -0400 (Thu, 19 Jun 2008) | 1 line
fix whitespace
........
r4684 | pjenvey | 2008-06-19 20:50:11 -0400 (Thu, 19 Jun 2008) | 4 lines
compile inplace operations to a PyObject._ixx wrapper (which uses _binop_rule,
like _xxx), instead of __ixx__
for #1873148
........
r4693 | pjenvey | 2008-06-20 01:45:14 -0400 (Fri, 20 Jun 2008) | 5 lines
o fix builtin inplace methods to work as MethodType.BINARY
o add missing inplace functions to operator module
o fix CPython specific usage of __iadd__ in lists_tests to operator.__iadd__
for #1873148
........
r4694 | pjenvey | 2008-06-20 02:01:14 -0400 (Fri, 20 Jun 2008) | 3 lines
make deriveds inplace ops work like binary ops
for #1873148
........
r4695 | zyasoft | 2008-06-20 02:21:29 -0400 (Fri, 20 Jun 2008) | 1 line
Updated most builtins to 2.5; intern, object do not yet conform. Float conversion is richer in Java than it is in Python for hex (Java supports floating point hex values, test_float). Derived longs are failing (test_longconversion). cmp might be fixed by Leo Soto. Remaining issues are probably due to partial parse problems. Added contextlib, functools. The latter uses a pure-Python implementation, so it does not look like a native type for some of the tests in test_functools; TBD.
........
r4704 | fwierzbicki | 2008-06-20 13:32:49 -0400 (Fri, 20 Jun 2008) | 3 lines
Cleared up some bad behavior in Python.g (was reporting and recovering
from missing tokens).
........
r4705 | fwierzbicki | 2008-06-20 13:35:59 -0400 (Fri, 20 Jun 2008) | 2 lines
Switch debugging off.
........
r4706 | fwierzbicki | 2008-06-20 14:33:18 -0400 (Fri, 20 Jun 2008) | 2 lines
Repaired partial strings. Partial lists, dicts, etc *sometimes* work.
........
r4708 | fwierzbicki | 2008-06-20 15:58:27 -0400 (Fri, 20 Jun 2008) | 2 lines
Pretty good nested [,(,{ support for interactive mode.
........
r4709 | zyasoft | 2008-06-20 21:16:24 -0400 (Fri, 20 Jun 2008) | 1 line
Added wsgiref from 2.5
........
r4710 | fwierzbicki | 2008-06-21 08:20:13 -0400 (Sat, 21 Jun 2008) | 2 lines
whitespace.
........
r4711 | fwierzbicki | 2008-06-21 08:39:06 -0400 (Sat, 21 Jun 2008) | 2 lines
Now simple tests of the interactive mode are working well.
........
r4712 | pjenvey | 2008-06-21 19:42:05 -0400 (Sat, 21 Jun 2008) | 1 line
always re-generate .class until APIVersion is fixed
........
r4714 | nriley | 2008-06-22 22:38:45 -0400 (Sun, 22 Jun 2008) | 1 line
os.isatty, file.isatty support
........
r4715 | fwierzbicki | 2008-06-23 11:57:31 -0400 (Mon, 23 Jun 2008) | 2 lines
Fix for one line compound statements in interactive mode.
........
r4720 | fwierzbicki | 2008-06-23 15:28:04 -0400 (Mon, 23 Jun 2008) | 2 lines
return None for getfilesystemencoding for now.
........
r4729 | pjenvey | 2008-06-23 18:06:02 -0400 (Mon, 23 Jun 2008) | 7 lines
merge trunk/jython@... to branches/asm
branches/pep352 failures:
test_coercion test_deque test_doctest test_exceptions test_extcall
test_generators test_pickletools
new asm failures:
test_coercion test_deque test_pickletools test_wsgiref
........
r4732 | fwierzbicki | 2008-06-23 19:41:21 -0400 (Mon, 23 Jun 2008) | 2 lines
moving to 2.5 Lib. Also small fix for encoding check.
........
r4733 | pjenvey | 2008-06-23 20:31:42 -0400 (Mon, 23 Jun 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_exceptions.py@...>
........
r4734 | pjenvey | 2008-06-23 20:45:53 -0400 (Mon, 23 Jun 2008) | 3 lines
o 2.5 EnvironmentError needs a custom __reduce__
o disable failing testInfiniteRecursion
........
r4735 | fwierzbicki | 2008-06-23 21:14:18 -0400 (Mon, 23 Jun 2008) | 2 lines
better order for suite subrule.
........
r4740 | pjenvey | 2008-06-23 22:07:21 -0400 (Mon, 23 Jun 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_support.py@...>
........
r4741 | fwierzbicki | 2008-06-23 22:10:11 -0400 (Mon, 23 Jun 2008) | 4 lines
Realized that CPython forces an extra newline for *all* compound
statments (including statments like "class Foo:pass"). Greatly
simplified the grammar.
........
r4742 | pjenvey | 2008-06-23 22:14:19 -0400 (Mon, 23 Jun 2008) | 1 line
merge Jython specific changes back into 2.5 test_support
........
r4743 | fwierzbicki | 2008-06-23 22:36:57 -0400 (Mon, 23 Jun 2008) | 2 lines
Fix exploding newlines on interactive prompt.
........
r4744 | pjenvey | 2008-06-23 22:43:05 -0400 (Mon, 23 Jun 2008) | 1 line
re-enable setdict, fixed by pep352
........
r4745 | pjenvey | 2008-06-24 03:01:10 -0400 (Tue, 24 Jun 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_optparse.py@...>
........
r4746 | pjenvey | 2008-06-24 03:03:33 -0400 (Tue, 24 Jun 2008) | 1 line
allow imports outside of test
........
r4747 | pjenvey | 2008-06-24 03:04:43 -0400 (Tue, 24 Jun 2008) | 1 line
don't assume __builtins__ and skip a CPython specific test
........
r4748 | fwierzbicki | 2008-06-24 09:59:06 -0400 (Tue, 24 Jun 2008) | 2 lines
Finally - the threshold for a version change has been hit. Yay!
........
r4749 | zyasoft | 2008-06-24 11:45:48 -0400 (Tue, 24 Jun 2008) | 1 line
Use CPythonLib's re.py, not our own
........
r4750 | fwierzbicki | 2008-06-24 12:46:35 -0400 (Tue, 24 Jun 2008) | 2 lines
Support longs regardless of radix.
........
r4751 | fwierzbicki | 2008-06-24 13:10:39 -0400 (Tue, 24 Jun 2008) | 3 lines
move the Jython specific test_array out of the way so we can test against
the CPython test_array
........
r4753 | pjenvey | 2008-06-24 17:31:29 -0400 (Tue, 24 Jun 2008) | 1 line
disable test_asynchat for now, re #1064
........
r4754 | pjenvey | 2008-06-24 17:31:42 -0400 (Tue, 24 Jun 2008) | 1 line
small cleanup
........
r4755 | pjenvey | 2008-06-24 19:12:17 -0400 (Tue, 24 Jun 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_logging.py@...>
........
r4756 | pjenvey | 2008-06-24 19:13:31 -0400 (Tue, 24 Jun 2008) | 1 line
re-integrate r4098:4167
........
r4757 | pjenvey | 2008-06-24 19:57:42 -0400 (Tue, 24 Jun 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/doctest.py@...>
........
r4758 | pjenvey | 2008-06-24 20:11:28 -0400 (Tue, 24 Jun 2008) | 5 lines
o bring in decimal (test_decimal passes). also hashlib and platform
which don't quite work yet
o Jython changes for doctest, though test_doctest still fails. bring
in trace for test_doctest
........
r4761 | fwierzbicki | 2008-06-25 13:22:09 -0400 (Wed, 25 Jun 2008) | 3 lines
removed special handling of RecognitionException, since errors
are always of type ParseException now anyway.
........
r4762 | fwierzbicki | 2008-06-25 13:51:08 -0400 (Wed, 25 Jun 2008) | 3 lines
Created a flag so that external tools can use Python.g with
Antlr's default error handling.
........
r4763 | fwierzbicki | 2008-06-25 14:10:21 -0400 (Wed, 25 Jun 2008) | 4 lines
antlrErrorHandling needs to be public to be used by external tools.
Looking at the nice error messages that are coming out makes me
wonder if I might want to rethink my error handling mechanism.
........
r4764 | pjenvey | 2008-06-25 15:03:08 -0400 (Wed, 25 Jun 2008) | 1 line
reapply compiled name as <module> from r4321
........
r4765 | pjenvey | 2008-06-25 15:05:09 -0400 (Wed, 25 Jun 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/inspect.py@...>
........
r4767 | pjenvey | 2008-06-25 15:45:51 -0400 (Wed, 25 Jun 2008) | 1 line
re-integrate r4053
........
r4768 | pjenvey | 2008-06-25 15:49:17 -0400 (Wed, 25 Jun 2008) | 3 lines
o fix string exceptions which I broke in r4754
o kill OverflowWarning and the custom warnings.py that we no longer need
........
r4769 | pjenvey | 2008-06-25 16:12:14 -0400 (Wed, 25 Jun 2008) | 1 line
match messages to CPython 2.5
........
r4770 | pjenvey | 2008-06-25 16:27:31 -0400 (Wed, 25 Jun 2008) | 1 line
small cleanup to unpackSequence
........
r4771 | pjenvey | 2008-06-25 16:46:49 -0400 (Wed, 25 Jun 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/regrtest.py@...>
........
r4772 | pjenvey | 2008-06-25 16:48:27 -0400 (Wed, 25 Jun 2008) | 2 lines
re-integrate jython specifics: mostly just -e support and java platform
test defines
........
r4774 | fwierzbicki | 2008-06-25 19:08:30 -0400 (Wed, 25 Jun 2008) | 2 lines
Can't live without -m.
........
r4777 | pjenvey | 2008-06-25 20:12:35 -0400 (Wed, 25 Jun 2008) | 4 lines
skip a number of tests we won't pass anytime soon. mark most of the
cjkencodings tests and xml_etree as perm failures for now. re-enable
test_unicode as it's close to passing
........
r4778 | pjenvey | 2008-06-25 20:12:50 -0400 (Wed, 25 Jun 2008) | 1 line
test_uuid passes
........
r4779 | nriley | 2008-06-25 21:16:20 -0400 (Wed, 25 Jun 2008) | 1 line
Return permission denied for files opened for reading.
........
r4781 | nriley | 2008-06-25 21:47:39 -0400 (Wed, 25 Jun 2008) | 1 line
Match CPython behavior, hiding banner/prompt if stdin is not interactive and showing prompt if file argument is a tty; remove related workaround from test_cmd_line.
........
r4782 | fwierzbicki | 2008-06-26 13:11:56 -0400 (Thu, 26 Jun 2008) | 2 lines
hexoct is passing.
........
r4783 | fwierzbicki | 2008-06-26 13:15:03 -0400 (Thu, 26 Jun 2008) | 3 lines
Corner case for fplist fixed. def foo((x)) should be treated the same as
def foo(x).
........
r4784 | fwierzbicki | 2008-06-26 16:11:35 -0400 (Thu, 26 Jun 2008) | 2 lines
genexp should be sole argument if no parens. First half of fix.
........
r4785 | zyasoft | 2008-06-26 18:43:05 -0400 (Thu, 26 Jun 2008) | 1 line
Removed old Jython-specific tests in favor of CPythonLib versions (except that test_urllib.py has a dependency on fileno being int, so changed accordingly). Cleaned up SRE engine code such that it more closely follows _sre.c. Removed optimization of Unicode charset in sre_compile since for UCS-4 for CPython, it doesn't appear to use this optimization anyway.
........
r4786 | zyasoft | 2008-06-26 20:44:30 -0400 (Thu, 26 Jun 2008) | 1 line
re.sub, re.subn now coerce to the right type (unicode/str), based on the spec provided by test_re.test_bug_1140
........
r4787 | zyasoft | 2008-06-26 20:50:25 -0400 (Thu, 26 Jun 2008) | 1 line
Removed obsolete test, superseded by 2.5 coercion rules for emptry strings on re.sub
........
r4788 | pjenvey | 2008-06-26 21:14:25 -0400 (Thu, 26 Jun 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_urllib2_localnet.py@...>
........
r4789 | pjenvey | 2008-06-26 21:15:47 -0400 (Thu, 26 Jun 2008) | 1 line
explicitly close the server socket instead of relying on GC
........
r4790 | zyasoft | 2008-06-26 21:26:29 -0400 (Thu, 26 Jun 2008) | 1 line
test_re now passes completely. This was done by commenting inapplicable tests re recursion limits, since we are not going to implement a non-recursive variant, as well as adding the unimplemented typecodes for PyArray. Too bad that there's a lot more to do to get array working as well!
........
r4791 | pjenvey | 2008-06-26 21:30:12 -0400 (Thu, 26 Jun 2008) | 2 lines
upgrade socket._fileobject to 2.5's
........
r4792 | pjenvey | 2008-06-26 22:39:20 -0400 (Thu, 26 Jun 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_hashlib.py@...>
........
r4793 | pjenvey | 2008-06-26 22:52:59 -0400 (Thu, 26 Jun 2008) | 3 lines
add _hashlib with support for everything but sha224, via
java.security.MessageDigest. supersedes our md5 module
........
r4794 | pjenvey | 2008-06-26 23:04:45 -0400 (Thu, 26 Jun 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_hmac.py@...>
........
r4795 | zyasoft | 2008-06-26 23:14:37 -0400 (Thu, 26 Jun 2008) | 1 line
Added stack_size to thread, threading since it's available since 1.4, but only as a hint to the JVM. test_re was not added in the prev commit. test_threading's test of foreign threads doesn't make sense for Jython, or so I decree
........
r4796 | pjenvey | 2008-06-26 23:25:09 -0400 (Thu, 26 Jun 2008) | 3 lines
optimize _hashlib.HASH to take advantage of MessageDigest.clone which is
supported for all of our hashing types
........
r4797 | pjenvey | 2008-06-26 23:26:55 -0400 (Thu, 26 Jun 2008) | 3 lines
o sha is superceded by hashlib
o special case test_hmac to avoid our lack of sha224 support
........
r4798 | zyasoft | 2008-06-26 23:50:14 -0400 (Thu, 26 Jun 2008) | 1 line
Fixed test_bigmem to reflect Java realities. Didn't get the commit in last time of commenting out test_foreign_thread, not applicable to Jython
........
r4799 | zyasoft | 2008-06-27 00:17:33 -0400 (Fri, 27 Jun 2008) | 1 line
Working too fast here, here's the test_bigmem.py fixes. Also added all methods to threading such that it passes tests in test_contextlib
........
r4800 | pjenvey | 2008-06-27 00:27:32 -0400 (Fri, 27 Jun 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/fileinput.py@...>
........
r4801 | pjenvey | 2008-06-27 00:28:43 -0400 (Fri, 27 Jun 2008) | 1 line
reapply Jython workaround for lack of fstat
........
r4802 | zyasoft | 2008-06-27 00:30:59 -0400 (Fri, 27 Jun 2008) | 1 line
Enable testing of stack size changing for java platform
........
r4806 | zyasoft | 2008-06-27 00:50:06 -0400 (Fri, 27 Jun 2008) | 1 line
NA'ed test_traceback.test_members since it depends on sys.exc_traceback global var, which is not implemented in Jython (not threadsafe/deprecated since Python 1.5)
........
r4807 | zyasoft | 2008-06-27 01:28:40 -0400 (Fri, 27 Jun 2008) | 1 line
binascii.a2b_qp now escapes '= ' to '= '. a2b_uu takes empty strings
........
r4808 | pjenvey | 2008-06-27 01:45:44 -0400 (Fri, 27 Jun 2008) | 1 line
unused var
........
r4809 | zyasoft | 2008-06-27 03:24:14 -0400 (Fri, 27 Jun 2008) | 1 line
Added to os module: devnull, urandom. Worked around issue in java.io.File#mkdirs when adding directory like x/y/z/.
........
r4810 | fwierzbicki | 2008-06-27 13:47:50 -0400 (Fri, 27 Jun 2008) | 8 lines
Cleaned up Call node creation, and
now gen expressions are checked from both sides so that:
foo(x for x in range(10), 100)
foo(100, x for x in range(10))
properly fail.
........
r4821 | zyasoft | 2008-06-30 03:06:55 -0400 (Mon, 30 Jun 2008) | 1 line
Rewrote cStringIO to use StringBuffer instead of managing its own buffer (also not StringBuilder)
........
r4822 | zyasoft | 2008-06-30 03:41:08 -0400 (Mon, 30 Jun 2008) | 1 line
Fixed cStringIO to support ops for cPickle
........
r4823 | zyasoft | 2008-06-30 04:18:38 -0400 (Mon, 30 Jun 2008) | 1 line
Fixed unicode coercion for str.__mod__ with unicode args
........
r4824 | zyasoft | 2008-06-30 04:59:43 -0400 (Mon, 30 Jun 2008) | 1 line
Fixed unicode coercion logic for PyString.__mod__. Removed 2.5 contextlib.py in favor of direct from CPythonLib
........
r4825 | zyasoft | 2008-06-30 12:14:30 -0400 (Mon, 30 Jun 2008) | 1 line
Change cStringIO to use StringBuilder semantics. Use via thread confinement, or with external locking. Keep it simple, keep it lightweight.
........
r4826 | zyasoft | 2008-06-30 14:08:37 -0400 (Mon, 30 Jun 2008) | 1 line
Restored cStringIO.getString
........
r4827 | zyasoft | 2008-07-01 09:52:38 -0400 (Tue, 01 Jul 2008) | 1 line
Removed modules and tests exactly duplicated from CPythonLib
........
r4828 | zyasoft | 2008-07-01 11:50:43 -0400 (Tue, 01 Jul 2008) | 1 line
Removed modules/tests that are trivially changed with respect to CPythonLib
........
r4829 | zyasoft | 2008-07-01 13:21:43 -0400 (Tue, 01 Jul 2008) | 1 line
Removed modules/tests that should be updated to CPythonLib. Incidentally, test_cmath now tests that cmath.log takes a base
........
r4830 | zyasoft | 2008-07-01 16:38:05 -0400 (Tue, 01 Jul 2008) | 1 line
test_mailbox has been rewritten since 2.2, the version that was committed
........
r4831 | zyasoft | 2008-07-01 17:12:34 -0400 (Tue, 01 Jul 2008) | 1 line
Removed spurious placement of test_bigmem
........
r4832 | leosoto | 2008-07-01 17:30:12 -0400 (Tue, 01 Jul 2008) | 1 line
pyBoolean.__tojava__(Object.class) now returns a Boolean instead of an Integer. Also used valueOf static methods instead of constructors.
........
r4833 | zyasoft | 2008-07-01 18:02:55 -0400 (Tue, 01 Jul 2008) | 1 line
cStringIO#readline should not insert backslash-n (ambigous reading, but CPython implementation says otherwise)
........
r4834 | leosoto | 2008-07-01 18:24:50 -0400 (Tue, 01 Jul 2008) | 1 line
zxJDBC: Added BigInteger support to the PostgreSQLDataHandler
........
r4835 | leosoto | 2008-07-01 19:38:37 -0400 (Tue, 01 Jul 2008) | 1 line
zxJDBC: Avoid preparing a statement when executemany() is called with an empty sequence
........
r4836 | leosoto | 2008-07-01 20:33:20 -0400 (Tue, 01 Jul 2008) | 1 line
Workaround for issue 1047. At least on my system (jdk 1.6.0_06) it makes pulldom usable
........
r4837 | leosoto | 2008-07-01 23:51:43 -0400 (Tue, 01 Jul 2008) | 1 line
Another string interpolation fix, this time when the left operand is an unicode containing non-ascii chars and there are no unicodes on the right argument
........
r4838 | zyasoft | 2008-07-02 01:56:10 -0400 (Wed, 02 Jul 2008) | 1 line
cmath.log now takes a base parameter; all functions now test for ValueError to reraise as a TypeError, to be consistent with CPython
........
r4839 | leosoto | 2008-07-02 16:17:29 -0400 (Wed, 02 Jul 2008) | 1 line
Updated eclipse configuration to use the antlr3.1b1 JAR instead of 3.0.1
........
r4840 | leosoto | 2008-07-02 17:09:14 -0400 (Wed, 02 Jul 2008) | 1 line
Syncing PyBaseExceptionDerived
........
r4841 | leosoto | 2008-07-02 17:43:16 -0400 (Wed, 02 Jul 2008) | 1 line
Fixing Derived#__cmp__ to avoid raise TypeError when __cmp__ has not been overrided and super.__cmp__() returns -2 (see #1031)
........
r4842 | leosoto | 2008-07-02 20:36:50 -0400 (Wed, 02 Jul 2008) | 1 line
Enable utf-8 source encoding support (the test_cookielib issue was fixed upstream: http://bugs.python.org/issue3261). Also recognize 'latin-1' as an alias for 'iso8859-1'
........
r4843 | leosoto | 2008-07-02 22:39:07 -0400 (Wed, 02 Jul 2008) | 1 line
Limiting the buffer size used for discovering the encoding, to avoid crashing when reading big files (such as django/tests/regressiontests/forms/fields.py), as the default size of BufferedReader was too close to the readlimit set by the mark() call
........
r4845 | fwierzbicki | 2008-07-03 21:13:07 -0400 (Thu, 03 Jul 2008) | 3 lines
change token name from ENDMARK to ENDMARKER to better fit with
CPython's Grammar/Grammar file. Alse some tabs->spaces.
........
r4846 | fwierzbicki | 2008-07-03 21:49:41 -0400 (Thu, 03 Jul 2008) | 3 lines
Introduced ENDMARKER to Python.g -- needed for files that
lack a newline.
........
r4847 | fwierzbicki | 2008-07-03 22:01:44 -0400 (Thu, 03 Jul 2008) | 2 lines
import test_support.
........
r4848 | fwierzbicki | 2008-07-04 08:21:30 -0400 (Fri, 04 Jul 2008) | 3 lines
Removed ENDMARKER from Python.g and applied Leo Soto's patch to
add a newline to the end of input that ends w/o a newline.
........
r4849 | fwierzbicki | 2008-07-04 08:33:14 -0400 (Fri, 04 Jul 2008) | 2 lines
Formatting and remove unused variable.
........
r4850 | fwierzbicki | 2008-07-04 17:25:24 -0400 (Fri, 04 Jul 2008) | 3 lines
Moved the actual emit of the generated newline (for input
w/o a newline) to *after* dedents are emitted.
........
r4852 | leosoto | 2008-07-05 20:37:12 -0400 (Sat, 05 Jul 2008) | 20 lines
StringFormatter: '%d' and '%f' support for the __int__ and __float__ protocol
respectively.
The implementation is more convulted than it should be, because we have PyString
implementing __float__ and __int__ at the "java level" but not at the "python
level". For string formatting, only "python level" __float__ and __int__ must be
supported.
Also, considering that __int__ can return a PyLong, this case needs special
care. Basically formatInteger now can call formatLong if a PyLong is found as
the result of calling __int__. Then, as formatLong can also be called from
formatInteger, __hex__, __oct__ and __str__ conversions were moved inside
formatLong.
Finally, test_format_jy was changed to stop checking that we don't support big
floats on '%d' (CPython doesn't, but that seems a limitation of the specific
implementation and I can't imagine a program that could break on Jython because we
*support* it).
........
r4853 | pjenvey | 2008-07-05 21:51:20 -0400 (Sat, 05 Jul 2008) | 1 line
always recompile bytecode from zipimporter too
........
r4855 | fwierzbicki | 2008-07-07 05:08:22 -0400 (Mon, 07 Jul 2008) | 3 lines
Create a jython-complete.jar to make it easier to put out
a 2.5 alpha.
........
r4856 | zyasoft | 2008-07-07 07:22:16 -0400 (Mon, 07 Jul 2008) | 1 line
Removed double-checked locking used to init ThreadStateMap; didn't make sense to do any locking here anyway. Moved trycatch emit in visitWith to be where it ahappens (doesn't change output, but makes it easier to follow code).
........
r4857 | pjenvey | 2008-07-07 15:59:32 -0400 (Mon, 07 Jul 2008) | 1 line
no need to go through __builtin__ for issubclass
........
r4859 | pjenvey | 2008-07-07 19:21:43 -0400 (Mon, 07 Jul 2008) | 1 line
simplify
........
r4863 | pjenvey | 2008-07-07 21:14:55 -0400 (Mon, 07 Jul 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_enumerate.py@...>
........
r4864 | pjenvey | 2008-07-07 21:15:40 -0400 (Mon, 07 Jul 2008) | 1 line
avoid implementation detail tests
........
r4865 | pjenvey | 2008-07-08 01:20:37 -0400 (Tue, 08 Jul 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_iter.py@...>
........
r4866 | pjenvey | 2008-07-08 01:24:17 -0400 (Tue, 08 Jul 2008) | 4 lines
o make StopIteration (and the like) a 'sink state' in iter and call-iter, to
fix the test_iter test_sinkstate_* tests
o workaround test_iter test_unpack_iter GC related issues
........
r4867 | pjenvey | 2008-07-08 01:37:05 -0400 (Tue, 08 Jul 2008) | 5 lines
o wrap the fstat usage in is_jython instead of commenting it out
o "sync" with:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_largefile.py@...>
(no changes; equiv to 2.3's)
........
r4868 | pjenvey | 2008-07-08 02:20:46 -0400 (Tue, 08 Jul 2008) | 4 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_repr.py@...>
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_richcmp.py@...>
........
r4869 | pjenvey | 2008-07-08 03:27:03 -0400 (Tue, 08 Jul 2008) | 4 lines
o workaround jython issues in test_richcmp and test_repr
o our custom test_operations isn't really necessary and we pass stdlib's. also
now pass stdlib's test_long
........
r4870 | fwierzbicki | 2008-07-08 04:59:37 -0400 (Tue, 08 Jul 2008) | 2 lines
some tweaks to help the install task.
........
r4876 | pjenvey | 2008-07-08 15:55:47 -0400 (Tue, 08 Jul 2008) | 3 lines
always re-generating byte code is more trouble than it's worth right now
(breaks the imp module)
........
r4877 | pjenvey | 2008-07-08 16:38:02 -0400 (Tue, 08 Jul 2008) | 5 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_scope.py@...>
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_types.py@...>
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_zlib.py@...>
........
r4878 | pjenvey | 2008-07-08 17:05:48 -0400 (Tue, 08 Jul 2008) | 4 lines
o allow a length argument to zlib decompressobj flush
o workarounds for 2.5 test_scope test_types (which output now matches stdlib's)
and test_zlib
........
r4879 | pjenvey | 2008-07-08 20:41:01 -0400 (Tue, 08 Jul 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/platform.py@...>
........
r4880 | pjenvey | 2008-07-08 20:42:59 -0400 (Tue, 08 Jul 2008) | 1 line
s/java.os/os/g
........
r4881 | nriley | 2008-07-08 23:50:19 -0400 (Tue, 08 Jul 2008) | 1 line
overriding fillInStackTrace for PyException speeds things up quite a bit
........
r4882 | nriley | 2008-07-10 01:12:05 -0400 (Thu, 10 Jul 2008) | 1 line
need bash to test the script, too
........
r4883 | leosoto | 2008-07-10 15:51:37 -0400 (Thu, 10 Jul 2008) | 1 line
zxJDBC: Map SQLExceptions to zxJDBC.IntegrityError if the sqlState says the exception was caused by a integrity violation
........
r4884 | pjenvey | 2008-07-10 23:36:29 -0400 (Thu, 10 Jul 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_support.py@...>
........
r4885 | pjenvey | 2008-07-10 23:46:09 -0400 (Thu, 10 Jul 2008) | 3 lines
add a -j option to regrtest for capturing test output to JUnit XML files (one
file per TestCase or module import or doctest) in the specified dir
........
r4887 | fwierzbicki | 2008-07-11 07:52:55 -0400 (Fri, 11 Jul 2008) | 3 lines
move "not needed" checks into separate task because all such tasks *are* needed
during a full build regardless of up to date status of files.
........
r4888 | zyasoft | 2008-07-11 08:16:28 -0400 (Fri, 11 Jul 2008) | 1 line
Begin port of PyPy's _rawffi, which with their pure-Python ctypes wrapper, implements ctypes
........
r4889 | fwierzbicki | 2008-07-11 08:45:41 -0400 (Fri, 11 Jul 2008) | 4 lines
added svnant-jars by default for more convenient full-build.
Fixed jarjar and jar-complete (so jarjar only recompiles on
changes and jar-complete properly depends on jarjar).
........
r4890 | zyasoft | 2008-07-11 10:05:13 -0400 (Fri, 11 Jul 2008) | 1 line
From PyPy's test__rawffi, broke out standard ctypes_test code they use (to avoid using their compilation toolchain). Implemented minimum to get test__rawffi.test_short_addition to pass.
........
r4891 | pjenvey | 2008-07-11 15:37:19 -0400 (Fri, 11 Jul 2008) | 1 line
test_pep263 passes now
........
r4892 | pjenvey | 2008-07-11 16:10:32 -0400 (Fri, 11 Jul 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/string_tests.py@...>
........
r4893 | pjenvey | 2008-07-11 16:16:53 -0400 (Fri, 11 Jul 2008) | 5 lines
o re-integrate workarounds for string_tests
o add rsplit
fixes #1023
thanks Nimish Telang
........
r4894 | pjenvey | 2008-07-11 20:10:28 -0400 (Fri, 11 Jul 2008) | 2 lines
fix unicode(str_subclass) not using its __unicode__ method
........
r4895 | pjenvey | 2008-07-11 20:13:15 -0400 (Fri, 11 Jul 2008) | 3 lines
fix some odder 2.5 tests of string count/find/rfind. rewrite join to act like
CPython's, mainly so: a.join([b]) is b
........
r4896 | pjenvey | 2008-07-11 20:33:21 -0400 (Fri, 11 Jul 2008) | 1 line
fix java exception names being prefixed with <unknown> in Python tracebacks
........
r4897 | pjenvey | 2008-07-11 20:53:44 -0400 (Fri, 11 Jul 2008) | 1 line
fake reload(sys), like reload(PyJavaClass). fix ClassCastException in reload
........
r4901 | pjenvey | 2008-07-11 21:28:39 -0400 (Fri, 11 Jul 2008) | 1 line
expect test_mhlib to pass on posix and skip elsewhere
........
r4902 | zyasoft | 2008-07-12 05:13:38 -0400 (Sat, 12 Jul 2008) | 1 line
Removed tests not appropriate for Jython, test_peepholer, test_profile; added test_strptime, test_csv
........
r4903 | zyasoft | 2008-07-12 06:08:11 -0400 (Sat, 12 Jul 2008) | 1 line
Replaced Lib/datetime.py with version from PyPy, http://codespeak.net/svn/pypy/dist/pypy/lib/datetime.py@...>
........
r4904 | zyasoft | 2008-07-12 09:50:19 -0400 (Sat, 12 Jul 2008) | 1 line
Fixed str|string|unicode.replace for PyString or PyUnicode in the basic plane
........
r4905 | zyasoft | 2008-07-12 09:51:06 -0400 (Sat, 12 Jul 2008) | 1 line
Removed tests not relevant to Jython around CPython code compilation
........
r4906 | zyasoft | 2008-07-12 10:09:20 -0400 (Sat, 12 Jul 2008) | 1 line
Operations on unicode objs in basic plane can only result in basic plane objs (btw, not true of astral)
........
r4907 | zyasoft | 2008-07-12 11:42:09 -0400 (Sat, 12 Jul 2008) | 1 line
Added datetime.strptime
........
r4908 | zyasoft | 2008-07-12 11:55:44 -0400 (Sat, 12 Jul 2008) | 1 line
datetime.fromtimestamp now rounds seconds,microseconds within 1 microsecond of an integer second to that second
........
r4909 | zyasoft | 2008-07-12 12:50:22 -0400 (Sat, 12 Jul 2008) | 1 line
ascii codec will always be in basic plane, so at least optimize setting of that when constructing unicode
........
r4910 | leosoto | 2008-07-12 15:50:43 -0400 (Sat, 12 Jul 2008) | 1 line
Now test_strptime pass. This is done by improving the current SimpleDateFormat-backed implementation a bit, and delegating to _strptime.strptime for formats not supported by SimpleDateFormat.
........
r4911 | leosoto | 2008-07-12 15:52:59 -0400 (Sat, 12 Jul 2008) | 1 line
Removing a duplicate line on CPythonLib.includes I introduced on r4910
........
r4912 | pjenvey | 2008-07-12 15:57:48 -0400 (Sat, 12 Jul 2008) | 4 lines
o add popen2.cleanup for CPython compat. and to fix test_popen2
o make threading.currentThread() is threading.currentThread() (with the help of
a WeakKeyDictionary) to allow _threading_local to work
........
r4913 | pjenvey | 2008-07-12 20:47:08 -0400 (Sat, 12 Jul 2008) | 4 lines
max_read_chunk of 10mb kills test_gzip.test_many_append's performance due to
repeated 10mb reads. CPython doesn't suffer from this -- maybe its allocator
recycles the same 10mb. lowering to 256K speeds test time from 15 to 1 second
........
r4914 | pjenvey | 2008-07-12 22:07:51 -0400 (Sat, 12 Jul 2008) | 1 line
add C_EXTENSION because pkgutil references it
........
r4916 | pjenvey | 2008-07-12 23:36:31 -0400 (Sat, 12 Jul 2008) | 2 lines
fix to make the 'g' formatter closer to CPython's. fixes test_tokenize
........
r4917 | zyasoft | 2008-07-14 06:47:01 -0400 (Mon, 14 Jul 2008) | 1 line
split and rsplit do not need to be UTF-16 aware
........
r4918 | zyasoft | 2008-07-14 06:52:18 -0400 (Mon, 14 Jul 2008) | 3 lines
From
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_str@...>
........
r4919 | zyasoft | 2008-07-14 07:03:54 -0400 (Mon, 14 Jul 2008) | 1 line
Removed inapplicable test due to different algorithm in expandtabs which cannot overflow in Jython
........
r4922 | zyasoft | 2008-07-14 07:44:28 -0400 (Mon, 14 Jul 2008) | 1 line
time.struct_time can now take any obj that can be turned into a list and converted into 9 integers
........
r4924 | zyasoft | 2008-07-14 08:11:26 -0400 (Mon, 14 Jul 2008) | 3 lines
From
http://svn.python.org/projects/python/branches/release25-maint/Lib/uu.py@...>
........
r4925 | zyasoft | 2008-07-14 08:19:10 -0400 (Mon, 14 Jul 2008) | 2 lines
Fixed uu.encode, decode so that it does not rely on refcounting to close files
........
r4928 | zyasoft | 2008-07-14 11:19:01 -0400 (Mon, 14 Jul 2008) | 3 lines
ReferenceQueue objs, by their nature, only make sense if transient.
So make them so, this enables interoperation with Terracotta.
........
r4930 | pjenvey | 2008-07-14 15:24:49 -0400 (Mon, 14 Jul 2008) | 1 line
couple small array fixes
........
r4932 | fwierzbicki | 2008-07-14 15:25:59 -0400 (Mon, 14 Jul 2008) | 2 lines
unbreak --memo again :)
........
r4933 | pjenvey | 2008-07-14 15:26:58 -0400 (Mon, 14 Jul 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/distutils@...>
........
r4934 | fwierzbicki | 2008-07-14 15:27:40 -0400 (Mon, 14 Jul 2008) | 3 lines
generate newlines before the dedents again. Although the reverse
was solving some problems, it was creating more.
........
r4935 | pjenvey | 2008-07-14 15:31:38 -0400 (Mon, 14 Jul 2008) | 3 lines
o re-integrate Jython distutils changes
o check for $py.class on Jython instead of pyc in test_build_py
........
r4936 | leosoto | 2008-07-14 16:12:27 -0400 (Mon, 14 Jul 2008) | 1 line
Allow derived types written in Jython to implement a __tojava__ method. This will allow better integration with java for python types such as decimal.Decimal, datetime.date, etc.
........
r4937 | fwierzbicki | 2008-07-15 11:23:32 -0400 (Tue, 15 Jul 2008) | 4 lines
Fixes in build.xml to make full-build work again. Some cleanup
like the removal of old parser and old website tasks. Changed
README to describe 2.5 alpha release.
........
r4939 | leosoto | 2008-07-15 12:13:50 -0400 (Tue, 15 Jul 2008) | 1 line
decimal.py from http://svn.python.org/projects/python/branches/release25-maint/Lib/decimal.py@...>
........
r4940 | leosoto | 2008-07-15 12:24:18 -0400 (Tue, 15 Jul 2008) | 1 line
Implemented decimal.Decimal.__tojava__ to convert decimal instances to java BigDecimal when python -> java conversion is requested
........
r4941 | leosoto | 2008-07-15 13:16:16 -0400 (Tue, 15 Jul 2008) | 1 line
Implemented __tojava__ on datetime.time, datetime.date and datetime.datetime. On the current implementation, they can be converted to java.sql.Time, java.sql.Date, java.sql.Timestamp, respectively. All of them can also be converted to java.util.Calendar. Only one caveat: the tzinfo attribute of times and datetimes is currently ignored
........
r4942 | leosoto | 2008-07-15 14:00:57 -0400 (Tue, 15 Jul 2008) | 1 line
Removing decimal.py from CPythonLib.includes. I forgot to do that on r4939
........
r4943 | fwierzbicki | 2008-07-15 14:33:40 -0400 (Tue, 15 Jul 2008) | 2 lines
build tweaks + workaround for an NT problem in site.py
........
r4944 | nriley | 2008-07-15 14:42:08 -0400 (Tue, 15 Jul 2008) | 1 line
fix for startup problem on Windows - AttributeError was accidentally trapping posixpath abspath failure
........
r4945 | fwierzbicki | 2008-07-15 15:27:53 -0400 (Tue, 15 Jul 2008) | 3 lines
already incrementing to 2.5a1 -- sourceforge is caching the old one too hard
and I really need to get Windows fixed.
........
r4947 | leosoto | 2008-07-15 17:21:30 -0400 (Tue, 15 Jul 2008) | 18 lines
Improvements to the zxJDBC default DataHandler:
- Map DATE, TIME and TIMESTAMP columns to datetime.date, datetime.time and
datetime.datetime respectively. Factory methods to create instances of
datetime.* were added to Py.java.
- Map VARCHAR columns to unicode instead of str.
- Don't try to guess the precision of NUMERIC columns .
- Use Py.True and Py.False instead of Py.One and Py.Zero.
Some of this changes may cause backwards-incompatibility, so I've copied the old
DataHandler logic into Jython22DataHandler. Then, old code should simply setup
this datahandler on its connections if it is not going to be adapted to the new
DataHandler default behaviour.
........
r4949 | amak | 2008-07-15 17:33:35 -0400 (Tue, 15 Jul 2008) | 1 line
Merging support for IPv6 and UDP <broadcast>
........
r4950 | nriley | 2008-07-15 18:33:04 -0400 (Tue, 15 Jul 2008) | 1 line
(Partial) Windows port of Jython launcher script; should work on Windows 2000 and later.
........
r4951 | nriley | 2008-07-15 18:37:38 -0400 (Tue, 15 Jul 2008) | 1 line
Oops, left some debugging code in.
........
r4952 | amak | 2008-07-15 18:51:51 -0400 (Tue, 15 Jul 2008) | 1 line
Backing out what I thought were simple changes, which appear to have broken the build.
........
r4959 | pjenvey | 2008-07-16 21:23:59 -0400 (Wed, 16 Jul 2008) | 1 line
add symlink on posix
........
r4961 | pjenvey | 2008-07-16 23:21:35 -0400 (Wed, 16 Jul 2008) | 5 lines
fix the symlink related tests by adding readlink, using _posix.lstat and
utilizing _posix symlink stuff in posixpath.
also utilize real stat results in posixpath, and re-enable ismount in ntpath
since we can support it in posixpath
........
r4963 | pjenvey | 2008-07-17 00:59:53 -0400 (Thu, 17 Jul 2008) | 9 lines
o fix PythonPOSIXHandler getEnv/getCurrentWorkingDirectory return signatures
o fix posixpath.__all__
o only enable os.symlink/readlink and posixpath friends if the posix factory
appears native. pure java support for symlinks is still sketchy -- in
particular with dead links -- switching these on enables tests in test_glob,
test_posixpath, test_tarfile that utilize dead links and are doomed to failure
o allow partial filling of stat results from jna-posix, padding the rest with
0s
........
r4965 | fwierzbicki | 2008-07-17 17:19:56 -0400 (Thu, 17 Jul 2008) | 2 lines
added custom toStringTree to each node.
........
r4967 | pjenvey | 2008-07-17 20:28:49 -0400 (Thu, 17 Jul 2008) | 3 lines
boost the mark limit even higher for the lenghty lines in
pygments.lexers._vimbuiltins
........
r4968 | nriley | 2008-07-18 15:20:39 -0400 (Fri, 18 Jul 2008) | 1 line
Work with jython-complete.jar; handle spaces in $JAVA_HOME.
........
r4969 | nriley | 2008-07-18 15:21:37 -0400 (Fri, 18 Jul 2008) | 1 line
Actually use JYTHON_OPTS; correct error message and properly delete _JYTHON_HOME.
........
r4970 | nriley | 2008-07-18 16:40:17 -0400 (Fri, 18 Jul 2008) | 1 line
Make ant regrtest work on Windows again.
........
r4971 | nriley | 2008-07-18 16:51:00 -0400 (Fri, 18 Jul 2008) | 1 line
Conditionalize launcher test; no need for Cygwin test.
........
r4973 | nriley | 2008-07-19 01:54:20 -0400 (Sat, 19 Jul 2008) | 1 line
Clean up install targets; allow install to be run without full-build; normalize source directory structure between checked-out and installed versions.
........
r4974 | fwierzbicki | 2008-07-19 18:48:21 -0400 (Sat, 19 Jul 2008) | 4 lines
Make PythonTree's toStringTree more easily comparable with ast/astview.py
output. This will help with the walkerless Python.g, as it doesn't quite
parse ast/astview.py yet.
........
r4980 | pjenvey | 2008-07-21 01:00:49 -0400 (Mon, 21 Jul 2008) | 1 line
integrate the sink state conditions
........
r4982 | pjenvey | 2008-07-21 15:11:48 -0400 (Mon, 21 Jul 2008) | 1 line
fix exposed __getitem__ possibly returning null
........
r4983 | pjenvey | 2008-07-21 15:45:12 -0400 (Mon, 21 Jul 2008) | 3 lines
o fix filter to pass test_builtin.test_filter and test_filter_subclasses
o remove the unnecessary __builtin__.tuple
........
r4984 | pjenvey | 2008-07-21 15:48:17 -0400 (Mon, 21 Jul 2008) | 1 line
make the failure verbose because test_site_flag occasionally fails on the buildbot mysteriously
........
r4985 | pjenvey | 2008-07-22 21:18:53 -0400 (Tue, 22 Jul 2008) | 4 lines
o make Py.makeCharacter consisitent in never returning unicode unless it was asked for
o move calculateIndex into PySequence for PyArray
o allow PyLong.getLong access for PyArray
........
r4986 | pjenvey | 2008-07-22 21:19:34 -0400 (Tue, 22 Jul 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_array.py@...>
........
r4987 | pjenvey | 2008-07-22 21:21:32 -0400 (Tue, 22 Jul 2008) | 1 line
many various PyArray fixes for 2.5 test_array
........
r4988 | fwierzbicki | 2008-07-22 21:58:01 -0400 (Tue, 22 Jul 2008) | 4 lines
Made Str offsets better match CPython.
PythonTree now extends BaseTree (too much of CommonTree was getting changed anyway).
astdump.py repaired so that it is a useful testing ground for ast comparisons.
........
r4989 | fwierzbicki | 2008-07-23 14:39:09 -0400 (Wed, 23 Jul 2008) | 2 lines
Offset fixes for Try/Catch and Call.
........
r4990 | fwierzbicki | 2008-07-23 15:13:04 -0400 (Wed, 23 Jul 2008) | 6 lines
Made except blocks optional in PythonPartial.g since:
try:
Is a valid partial parse.
........
r4991 | pjenvey | 2008-07-23 16:36:42 -0400 (Wed, 23 Jul 2008) | 2 lines
o fix passing chars > 256 to Py.makeCharacter
o make struct.error a class and raise struct.errors instead of OverflowErrors
........
r4992 | pjenvey | 2008-07-23 16:55:03 -0400 (Wed, 23 Jul 2008) | 3 lines
support the new float.__get/setformat__ classmethods -- they just claim our
formats are 'unknown'
........
r4993 | pjenvey | 2008-07-24 03:22:38 -0400 (Thu, 24 Jul 2008) | 2 lines
fix a regression from the bug 1140 fix
........
r4994 | pjenvey | 2008-07-24 03:29:54 -0400 (Thu, 24 Jul 2008) | 3 lines
add codecs.charmap_build which builds optimized encoding maps now used by the
charmap encoder
........
r4995 | fwierzbicki | 2008-07-24 09:51:47 -0400 (Thu, 24 Jul 2008) | 2 lines
Make stopCharIndex consistent.
........
r4996 | fwierzbicki | 2008-07-24 12:58:24 -0400 (Thu, 24 Jul 2008) | 2 lines
Fix for wrong line numbers in func.co_firstlineno.
........
r4997 | pjenvey | 2008-07-24 19:42:09 -0400 (Thu, 24 Jul 2008) | 1 line
cleanup unused var
........
r4998 | nriley | 2008-07-25 02:07:24 -0400 (Fri, 25 Jul 2008) | 1 line
Suppress exception truncating /dev/null when opening it for write on Linux and Solaris; should fix test_os.
........
r4999 | fwierzbicki | 2008-07-25 21:27:25 -0400 (Fri, 25 Jul 2008) | 3 lines
Re-enabled APIVersion checking in imp.java. Used ASM to read and write APIVersion
as an annotation. Incremented APIVersion from 12 to 13.
........
r5000 | fwierzbicki | 2008-07-25 21:34:48 -0400 (Fri, 25 Jul 2008) | 2 lines
Small cleanups in imp.
........
r5001 | fwierzbicki | 2008-07-25 21:51:48 -0400 (Fri, 25 Jul 2008) | 2 lines
Small cleanup in Py.java -- killing stray System.outs.
........
r5002 | fwierzbicki | 2008-07-25 21:55:04 -0400 (Fri, 25 Jul 2008) | 2 lines
Removed stray System.outs.
........
r5003 | fwierzbicki | 2008-07-26 10:41:46 -0400 (Sat, 26 Jul 2008) | 2 lines
Changing comment convention back to proper style (start with Returns).
........
r5004 | fwierzbicki | 2008-07-27 09:21:12 -0400 (Sun, 27 Jul 2008) | 2 lines
comment out DEBUG.class in the repo.
........
r5005 | fwierzbicki | 2008-07-27 22:41:38 -0400 (Sun, 27 Jul 2008) | 2 lines
Better error messages in the face of parser errors (line numbers + char column).
........
r5006 | pjenvey | 2008-07-28 00:56:03 -0400 (Mon, 28 Jul 2008) | 3 lines
o add os.link (fixes test_shutil)
o fix test_re's test output -- it shouldn't have any now
........
r5007 | pjenvey | 2008-07-28 02:38:44 -0400 (Mon, 28 Jul 2008) | 7 lines
PEP 357 (__index__), adds:
o PyObject.isIndex - true if int, long or implements __index__
o PyObject.asIndex - like asInt for indexes
o also fixed a dispatching to __get/set/delitem__ vs __get/set/delslice__ bug
and __get/set/delitem__ indices weren't utilizing __len__ when available (fixes
test_userstring)
........
r5008 | pjenvey | 2008-07-28 02:40:09 -0400 (Mon, 28 Jul 2008) | 2 lines
deriveds changes for __index__
........
r5009 | zyasoft | 2008-07-28 07:51:51 -0400 (Mon, 28 Jul 2008) | 3 lines
test__rawffi will now skip if it cannot load ctypes_test, a test
dynamic library that we do not yet have an ant task to create.
........
r5010 | zyasoft | 2008-07-28 08:13:52 -0400 (Mon, 28 Jul 2008) | 3 lines
Replaced test_inspect.py with rewritten version (using unittest!) from 2.5:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_inspect.py@...>
........
r5011 | zyasoft | 2008-07-28 09:33:50 -0400 (Mon, 28 Jul 2008) | 5 lines
Excluded test cases that depend on tuple unpacking in the arg
specification, since this depends on introspecing bytecode. (Perhaps
we should provide a Jython-specific version where appropriate metadata
is emitted in the compiled code object?)
........
r5012 | pjenvey | 2008-07-28 15:46:39 -0400 (Mon, 28 Jul 2008) | 5 lines
fix stock UserList/test_userlist:
o handle __get/set/delslice__ start/stop as null or None in PySlice.indices2
o fix list slice assignments of the same underlying list (always copy first
as CPython does)
........
r5013 | pjenvey | 2008-07-28 15:50:43 -0400 (Mon, 28 Jul 2008) | 1 line
include UserList
........
r5014 | nriley | 2008-07-28 18:55:35 -0400 (Mon, 28 Jul 2008) | 1 line
jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r210
........
r5015 | nriley | 2008-07-28 18:56:55 -0400 (Mon, 28 Jul 2008) | 1 line
pwd, grp; test_posix no longer skipped
........
r5016 | pjenvey | 2008-07-28 19:13:21 -0400 (Mon, 28 Jul 2008) | 1 line
fix chdir('/') on windows
........
r5017 | fwierzbicki | 2008-07-28 21:40:32 -0400 (Mon, 28 Jul 2008) | 2 lines
IParserHost is no longer used.
........
r5018 | fwierzbicki | 2008-07-29 08:31:46 -0400 (Tue, 29 Jul 2008) | 2 lines
Move testing classes out of main code.
........
r5019 | pjenvey | 2008-07-29 16:29:08 -0400 (Tue, 29 Jul 2008) | 4 lines
add an InputStream tie-in to TextIOBases, for parsing in universal newlines
mode
fixes #1082
........
r5020 | zyasoft | 2008-07-29 18:33:56 -0400 (Tue, 29 Jul 2008) | 5 lines
cStringIO.tell needs to return an int for it to be used by __len__
(perhaps that should be relaxed instead?). Found by testing against
PyAMF which uses cStringIO as a backing store for its
BufferedByteStream objs.
........
r5021 | pjenvey | 2008-07-29 18:40:05 -0400 (Tue, 29 Jul 2008) | 2 lines
fix readChunk reading more than CHUNK_SIZE, which'll blow up packReadahead
........
r5022 | zyasoft | 2008-07-30 11:46:31 -0400 (Wed, 30 Jul 2008) | 4 lines
Support inf, -inf, nan literals (and any
uppercasing). struct.pack("d") ducktypes like CPython and calls
__float__. This fixes a number of issues for PyAMF.
........
r5023 | zyasoft | 2008-07-30 15:57:16 -0400 (Wed, 30 Jul 2008) | 3 lines
Changed default format for __getformat__/__setformat__ to "IEEE,
big-endian", and supported switching back and forth with "unknown".
........
r5024 | pjenvey | 2008-07-30 18:39:24 -0400 (Wed, 30 Jul 2008) | 2 lines
add a builtin _functools.partial type
........
r5025 | pjenvey | 2008-07-30 19:00:32 -0400 (Wed, 30 Jul 2008) | 1 line
include functools
........
r5026 | fwierzbicki | 2008-07-31 09:10:57 -0400 (Thu, 31 Jul 2008) | 2 lines
Switch to Antlr 3.1b2.
........
r5027 | nriley | 2008-07-31 12:03:59 -0400 (Thu, 31 Jul 2008) | 1 line
Update Eclipse classpath to Antlr 3.1b2.
........
r5028 | fwierzbicki | 2008-07-31 12:14:55 -0400 (Thu, 31 Jul 2008) | 14 lines
Adding a Jython specific version of CommonErrorNode to use when there are errors
in the AST but we want to continue parsing (for now this is only of use by external
tools, but I'm considering making it an option since the information can be useful.
Thanks to Allan Davis for the original version of CommonErrorNode. I've refactored his
version so that PythonErrorNode does not repeat much of CommonErrorNode and put the
creation logic into PythonTreeAdaptor.
I have also added an interface ErrorHandler that allows the error handling in antlr to
be customized. FailFastHandler implements the default behavior of dying on the first
parse error. I also made the parse error output more useful, and factored a BaseParser
out of the org/python/antlr/*Parser classes.
........
r5029 | pjenvey | 2008-07-31 14:47:34 -0400 (Thu, 31 Jul 2008) | 3 lines
rearrange imports to fix test_threaded_import -- a bogus fix, but also what
CPython did for this problem
........
r5030 | pjenvey | 2008-07-31 15:50:45 -0400 (Thu, 31 Jul 2008) | 4 lines
o fix test_softspace and reset softspace (and append a newline) in various
places (equiv. of CPython's ceval.c::Py_FlushLine)
o fix traceback source lines without trailing newlines (fixes #1087)
........
r5031 | fwierzbicki | 2008-07-31 16:13:12 -0400 (Thu, 31 Jul 2008) | 2 lines
Fixed generator args check (antlr3.1b2 broke this, fixed it again).
........
r5032 | fwierzbicki | 2008-07-31 16:50:59 -0400 (Thu, 31 Jul 2008) | 3 lines
Tightened up signature of ErrorHandler and added a ListErrorHandler that
mimics Antlr default behavior for error handling.
........
r5033 | pjenvey | 2008-07-31 18:07:13 -0400 (Thu, 31 Jul 2008) | 1 line
deprecate complex divmod(), // and %
........
r5034 | pjenvey | 2008-07-31 19:16:37 -0400 (Thu, 31 Jul 2008) | 1 line
move __index__ out of the generated code section
........
r5035 | pjenvey | 2008-07-31 19:18:33 -0400 (Thu, 31 Jul 2008) | 1 line
sync with a couple of manual changes PyInstance has had
........
r5036 | pjenvey | 2008-07-31 19:32:03 -0400 (Thu, 31 Jul 2008) | 2 lines
support threading._RLock, as twisted uses it
fixes #1079
........
r5037 | pjenvey | 2008-07-31 19:49:50 -0400 (Thu, 31 Jul 2008) | 5 lines
fix a couple test_coercion cases:
o fix broken PyComplex.__rfloordiv__
o prevent stack overflows when old style classes return __coerce__ args in
reversed order
........
r5038 | pjenvey | 2008-07-31 19:57:11 -0400 (Thu, 31 Jul 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_operator.py@...>
........
r5039 | pjenvey | 2008-07-31 19:59:25 -0400 (Thu, 31 Jul 2008) | 2 lines
o filter operator slice args through __index__
o workaround Jython's lack of a real repeat/concat binop in test_operator
........
r5040 | fwierzbicki | 2008-07-31 20:50:28 -0400 (Thu, 31 Jul 2008) | 2 lines
remove unneeded member.
........
r5041 | nriley | 2008-08-01 16:06:44 -0400 (Fri, 01 Aug 2008) | 1 line
Make the ihooks module importable.
........
r5042 | nriley | 2008-08-01 16:07:47 -0400 (Fri, 01 Aug 2008) | 1 line
Support one-argument builtin apply.
........
r5043 | nriley | 2008-08-01 16:22:22 -0400 (Fri, 01 Aug 2008) | 1 line
Replace python.prepath with python.path.
........
r5044 | fwierzbicki | 2008-08-01 16:37:46 -0400 (Fri, 01 Aug 2008) | 3 lines
Better handling of bad dedent. Not perfect since it throws the
wrong exception.
........
r5045 | pjenvey | 2008-08-01 17:47:30 -0400 (Fri, 01 Aug 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_class.py@...>
........
r5046 | pjenvey | 2008-08-01 17:49:29 -0400 (Fri, 01 Aug 2008) | 1 line
fix instancemethod cmp to make test_class pass
........
r5047 | nriley | 2008-08-01 18:28:33 -0400 (Fri, 01 Aug 2008) | 1 line
Read python.executable from whole registry, not just top level.
........
r5048 | pjenvey | 2008-08-01 18:28:52 -0400 (Fri, 01 Aug 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_descrtut.py@...>
........
r5049 | pjenvey | 2008-08-01 18:38:32 -0400 (Fri, 01 Aug 2008) | 3 lines
list.__nonzero__ needn't be exposed, couple test_descrtut fixes (though it
still fails due to parser problems)
........
r5050 | nriley | 2008-08-01 19:02:47 -0400 (Fri, 01 Aug 2008) | 1 line
JYTHONPATH support.
........
r5051 | nriley | 2008-08-02 04:48:11 -0400 (Sat, 02 Aug 2008) | 1 line
Handle scripts on stdin.
........
r5052 | nriley | 2008-08-02 04:49:57 -0400 (Sat, 02 Aug 2008) | 1 line
jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r213 + patch in http://jira.codehaus.org/browse/JRUBY-2885 for isatty on Windows
........
r5053 | pjenvey | 2008-08-02 15:51:15 -0400 (Sat, 02 Aug 2008) | 5 lines
switch some new style unary ops to throw TypeErrors instead of AttributeErrors
when not implemented. the old styles still raise AttributeErrors (both styles
now match CPython). we assume __len/int/long/float/complex__ raise
AttributeErrors in many places so leaving them alone for now
........
r5054 | zyasoft | 2008-08-02 17:35:23 -0400 (Sat, 02 Aug 2008) | 3 lines
Raise a ValueError if attempt to set thread.stack_size > 0 but <
32768. Fixes test_thread.
........
r5055 | zyasoft | 2008-08-02 17:40:59 -0400 (Sat, 02 Aug 2008) | 4 lines
threading does not maintain a dict of limbo threads, since this
doesn't make sense in Jython. Remove code testing cleanup of
threading._limbo in test_support.threading_setup/thread_cleanup
........
r5056 | zyasoft | 2008-08-02 17:43:22 -0400 (Sat, 02 Aug 2008) | 5 lines
Fixed roundtripping so that eval(str(a)) == a where a uses a typecode
of a Java object, along with other similar minor issues. Rewrote
test_array_jy to use unittest, and removed testing now being done by
standard 2.5 test_array
........
r5057 | pjenvey | 2008-08-02 22:13:36 -0400 (Sat, 02 Aug 2008) | 3 lines
o pre and xreadlines were removed in CPython 2.4
o include some other modules I hope actually work
........
r5058 | zyasoft | 2008-08-02 23:09:49 -0400 (Sat, 02 Aug 2008) | 4 lines
Unicode arrays -- array.array('u') -- now work as expected, by special
casing the fact that we are storing them as an array of codepoints
(ints). Because of this, byteswap doesn't make sense.
........
r5059 | nriley | 2008-08-03 00:33:38 -0400 (Sun, 03 Aug 2008) | 1 line
Remove workaround for issue 1059 (was fixed in r4713).
........
r5060 | nriley | 2008-08-03 00:45:30 -0400 (Sun, 03 Aug 2008) | 1 line
jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r213 + patch in http://jira.codehaus.org/browse/JRUBY-2885 for isatty on Windows + patch in http://jira.codehaus.org/browse/JRUBY-2887 for atime setting
........
r5061 | zyasoft | 2008-08-03 00:45:39 -0400 (Sun, 03 Aug 2008) | 5 lines
Allow typecodes of B, H, I to fully use their storage. Don't run
test_byteswap for u (Unicode) because it doesn't make sense given
UTF-16 decoding.
Fixes test_array.
........
r5062 | nriley | 2008-08-03 00:47:37 -0400 (Sun, 03 Aug 2008) | 1 line
Support setting atime from os.utime.
........
r5063 | nriley | 2008-08-03 00:49:27 -0400 (Sun, 03 Aug 2008) | 1 line
Don't create file opened with r+; better validate file modes (fixes test_mailbox).
........
r5064 | zyasoft | 2008-08-03 01:11:47 -0400 (Sun, 03 Aug 2008) | 2 lines
Basic cleanup so that test_socket is runnable under current testing.
........
r5065 | nriley | 2008-08-03 03:42:24 -0400 (Sun, 03 Aug 2008) | 1 line
Fix mistaken assumption that 'r+' will create a file.
........
r5066 | nriley | 2008-08-03 05:50:01 -0400 (Sun, 03 Aug 2008) | 1 line
jna-posix from http://svn.codehaus.org/jruby-contrib/trunk/jna-posix r213 + patch in http://jira.codehaus.org/browse/JRUBY-2885 for isatty on Windows + patch in http://jira.codehaus.org/browse/JRUBY-2887 for atime setting (now with Windows support)
........
r5067 | fwierzbicki | 2008-08-03 10:42:44 -0400 (Sun, 03 Aug 2008) | 7 lines
Passed filename along to parsers and PythonTokenSource. created
a PyIndentationError to allow me derive IndentationErrors from
ParseException. Added a "type" to ParseException to recognize
when an IndentationError is needed. Changed test_traceback slightly
because I believe Antlr comes up with a better placement for the
carot vs CPython (at the indent and not end of line for indent errors.
........
r5068 | fwierzbicki | 2008-08-03 12:30:08 -0400 (Sun, 03 Aug 2008) | 5 lines
Small change for Jython -- it will be too hard in the short term to use
CPython's "Store" where Jython uses "AugStore" for AugAssigns. Eventually I do
intend to fix this, but it will take a little more work in the compiler than I
want to do just now.
........
r5069 | pjenvey | 2008-08-03 14:14:53 -0400 (Sun, 03 Aug 2008) | 1 line
expand tabs
........
r5070 | pjenvey | 2008-08-03 14:18:34 -0400 (Sun, 03 Aug 2008) | 2 lines
o FileIO whitespace, small refactor
o re-enable test_ast
........
r5071 | fwierzbicki | 2008-08-03 16:17:40 -0400 (Sun, 03 Aug 2008) | 2 lines
Partial fix for #1092 (just a comment no newline).
........
r5072 | fwierzbicki | 2008-08-03 17:45:49 -0400 (Sun, 03 Aug 2008) | 2 lines
whitespace
........
r5073 | fwierzbicki | 2008-08-03 18:54:14 -0400 (Sun, 03 Aug 2008) | 3 lines
CommonToken now appears to cover the cases that ClassicToken was left around
to cover. Removed all ClassicToken.
........
r5074 | fwierzbicki | 2008-08-03 21:15:48 -0400 (Sun, 03 Aug 2008) | 2 lines
Fixes to handle parsing with files that have no newline at the end.
........
r5075 | fwierzbicki | 2008-08-03 22:36:46 -0400 (Sun, 03 Aug 2008) | 2 lines
Some checks for assignment to None.
........
r5076 | nriley | 2008-08-03 23:23:57 -0400 (Sun, 03 Aug 2008) | 1 line
Truncate files opened with the 'w+' mode; some FileIO cleanup. Re-fixes test_fileno.
........
r5077 | fwierzbicki | 2008-08-04 13:57:34 -0400 (Mon, 04 Aug 2008) | 15 lines
In test_decorators.py, test_eval_order cleverly instruments a decorated call so
the order of evaluation and calls can be determined. It also checks to see if
the decoration works exactly the same when translated to nested function calls.
Jython was evaluating the arguments before the function name, the opposite of
CPython. This patch makes the order correct for both decorators and normal
function calls. Also, PyObject.invoke states in its comments that it is for use
from Java and shows the equivalent
o.__getattr__(name).__call__(args, keywords)
which is how I am constructing a call in the bytecode. I also thought that
"Invoke" with a capitalized name was non-ideal, so I changed the name to
invokeNoKeywords, which also allowed me to remove a comment that conveyed the
same meaning.
........
r5078 | pjenvey | 2008-08-04 17:34:24 -0400 (Mon, 04 Aug 2008) | 1 line
gather more info about the flakey test_hash OutOfMemoryError
........
r5079 | fwierzbicki | 2008-08-05 12:55:18 -0400 (Tue, 05 Aug 2008) | 4 lines
Reworked lexing of newlines and EOF. Broke up PythonTokenSource into more
useful methods. Removed inSingle from Python.g and added it to
PythonTokenSource.
........
r5080 | fwierzbicki | 2008-08-05 13:16:19 -0400 (Tue, 05 Aug 2008) | 2 lines
Guard against null text in PySyntaxError.
........
r5081 | fwierzbicki | 2008-08-05 16:21:24 -0400 (Tue, 05 Aug 2008) | 3 lines
Commenting out the strange eval parsing errors - I'm working elsewhere at the
moment and having test_jy_compile as a coal mine canary will be very helpful.
........
r5082 | fwierzbicki | 2008-08-05 18:39:04 -0400 (Tue, 05 Aug 2008) | 3 lines
Fix test_pkgimport for Jython (was deleting .pyc and .pyo files, now
deleted $py.class files on Jython).
........
r5083 | fwierzbicki | 2008-08-05 18:40:19 -0400 (Tue, 05 Aug 2008) | 2 lines
Forgot our convention.
........
r5084 | fwierzbicki | 2008-08-05 18:45:16 -0400 (Tue, 05 Aug 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_pkgimport.py@...>
........
r5085 | fwierzbicki | 2008-08-05 18:51:03 -0400 (Tue, 05 Aug 2008) | 3 lines
Fix test_pkgimport for Jython. Now deleting $py.class files on Jython, and
using __builtin__ instead of the CPython implementatin specific __buitlins__.
........
r5086 | fwierzbicki | 2008-08-05 19:44:49 -0400 (Tue, 05 Aug 2008) | 2 lines
2 new passing tests.
........
r5087 | fwierzbicki | 2008-08-05 19:46:30 -0400 (Tue, 05 Aug 2008) | 2 lines
Finish out "IN" as a token.
........
r5088 | fwierzbicki | 2008-08-05 22:19:54 -0400 (Tue, 05 Aug 2008) | 2 lines
fix for Java integration ("in" and "class" can now be used as non-keywords).
........
r5089 | fwierzbicki | 2008-08-05 22:27:45 -0400 (Tue, 05 Aug 2008) | 2 lines
Extra comment as a reminder about keywords.
........
r5090 | pjenvey | 2008-08-05 22:48:46 -0400 (Tue, 05 Aug 2008) | 4 lines
PEP 305 (csv module)
patches from Paul Drummond, Dave Kuhlman (thanks!)
fixes #1650802
........
r5091 | fwierzbicki | 2008-08-06 07:59:35 -0400 (Wed, 06 Aug 2008) | 4 lines
call clean if grammars change. Really only needed when *tokens* change,
but token changes break things so subtly, and so few work on the grammars
anyway, that this is the way to go I think.
........
r5092 | fwierzbicki | 2008-08-06 08:08:16 -0400 (Wed, 06 Aug 2008) | 2 lines
trigger jarjar if grammar changes (since clean is triggered).
........
r5093 | fwierzbicki | 2008-08-06 09:05:15 -0400 (Wed, 06 Aug 2008) | 8 lines
Support "in" as an attribute for Java compatibility, but not as a
NAME since this is overkill and causes errors (for example:
for x, in ((1,),(2,)):
parses "x, in" as a tuple (x,in) if "in" is treated like a name. bad.
........
r5094 | fwierzbicki | 2008-08-06 13:54:07 -0400 (Wed, 06 Aug 2008) | 10 lines
Changed grammars to allow most keywords to be used as attributes for Java
compatibility. Also added some tests. Removed a couple of tests that use
keywords as function names as this is no longer permitted. Allowing keywords to
be used as arbitrary NAMEs causes very weird grammar issues. For example
for x, in ((1,),(2,)):
matched "x, in" as a tuple. Now the permitted use is limited to things like
foo.in()
........
r5095 | fwierzbicki | 2008-08-06 14:15:17 -0400 (Wed, 06 Aug 2008) | 4 lines
improved jarjar conditional -- but made build.xml slightly more impenetrable.
Sigh.
........
r5096 | pjenvey | 2008-08-06 14:45:50 -0400 (Wed, 06 Aug 2008) | 3 lines
fix zipimport not handling mismatched APIVersion, and imp.load_module not
handling it either for packages
........
r5097 | fwierzbicki | 2008-08-06 15:05:52 -0400 (Wed, 06 Aug 2008) | 2 lines
More thorough keyword testing.
........
r5098 | fwierzbicki | 2008-08-06 15:35:41 -0400 (Wed, 06 Aug 2008) | 10 lines
Line and column position for
from __future__ import braces
Also fixed
from __future__ import GIL
Good thing there are unit tests for this :)
........
r5099 | fwierzbicki | 2008-08-06 19:51:03 -0400 (Wed, 06 Aug 2008) | 4 lines
Putting in fake SystemRandom that throws NotImplementedError on
all accesses so the rest of test_random.py can run (and fail for
better reasons).
........
r5100 | leosoto | 2008-08-06 22:27:08 -0400 (Wed, 06 Aug 2008) | 1 line
Experimental interpreter restarting support, aimed at webapp dev-server 'reloading', without having to resort to process forking. There is more info here: <http://codereview.appspot.com/2810>, where I posted the first attempt of this patch
........
r5102 | nriley | 2008-08-07 13:11:16 -0400 (Thu, 07 Aug 2008) | 1 line
Don't attempt to test AWT if we have no display.
........
r5103 | zyasoft | 2008-08-07 17:07:09 -0400 (Thu, 07 Aug 2008) | 3 lines
From
http://svn.python.org/projects/python/branches/release25-maint/Lib/pkgutil.py@...>
........
r5104 | zyasoft | 2008-08-07 17:18:44 -0400 (Thu, 07 Aug 2008) | 9 lines
Replaces pkgutil.read_code with read_jython_code (diff args); this
depends on the actual bytecode storage, so we have to have something
specific here. get_loader special cases for the sys module, since
Jython doesn't actually implement this as a module (and it appears to
be a non-trivial decoupling to make it so with the current
PySystemState).
This fixes test_runpy.
........
r5105 | zyasoft | 2008-08-08 11:37:43 -0400 (Fri, 08 Aug 2008) | 7 lines
With statements now keep their own stack of exit functions in PyFrame
so that they don't get stepped on by generators save/restore of local
temporary registers. Fixes most problems in test_with, including JVM
verification errors. (Remaining issues seem to be with generator exit
issues, to be resolved separately.)
........
r5106 | fwierzbicki | 2008-08-08 13:42:06 -0400 (Fri, 08 Aug 2008) | 3 lines
make jarjar run all of the time until I figure out why the conditionals
are not working.
........
r5107 | fwierzbicki | 2008-08-08 13:56:53 -0400 (Fri, 08 Aug 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_codeop.py@...>
........
r5108 | fwierzbicki | 2008-08-08 14:24:44 -0400 (Fri, 08 Aug 2008) | 10 lines
Various fixes to improve Jython compatibility with CPython, especially when
passing PyCF_DONT_IMPLY_DEDENT. Added PyCF_DONT_IMPLY_DEDENT to codeop.py,
PyTableCode.java, and CompilerFlags.java to help test_codeop.py run. Began to
integrate tests from test_jy_compile.py, which appears to have started as a copy
of test_codeop.py, into test_codeop.py. Once test_jy_compile is fully
integrated into test_codeop.py I should be able to delete test_jy_compile. Also
added eval support to PythonPartial.g, since test_codeop exercises that
functionality.
........
r5109 | fwierzbicki | 2008-08-08 15:24:38 -0400 (Fri, 08 Aug 2008) | 2 lines
Remove debug string.
........
r5110 | fwierzbicki | 2008-08-08 15:30:38 -0400 (Fri, 08 Aug 2008) | 5 lines
Extracted the actions from the grammars into a single GrammarActions
file. This will help if I ever get far enough on integrating the two
grammars into one. Also started an ErrorStmt node to handle bogus
statements in the walker.
........
r5111 | pjenvey | 2008-08-08 18:07:24 -0400 (Fri, 08 Aug 2008) | 5 lines
o another fix to make 'currentThread() is currentThread()' from
thread.start_new_thread threads. use a WeakHashMap because weakrefs of
javainstances ref the wrapper, not the actual java object
o custom toString for FunctionThread
........
r5112 | fwierzbicki | 2008-08-08 19:54:06 -0400 (Fri, 08 Aug 2008) | 2 lines
New error nodes for tool ASTs. Added errorhandling methods to ErrorHandler.
........
r5113 | pjenvey | 2008-08-08 20:37:11 -0400 (Fri, 08 Aug 2008) | 1 line
allow subclasses in getPyObjectByType
........
r5114 | zyasoft | 2008-08-09 01:36:17 -0400 (Sat, 09 Aug 2008) | 3 lines
Reordered code to test for raising exceptions thrown into a generator,
fixing test cases in test_contextlib, test_generators, and test_with.
........
r5115 | pjenvey | 2008-08-09 02:12:17 -0400 (Sat, 09 Aug 2008) | 2 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/list_tests.py@...>
........
r5116 | pjenvey | 2008-08-09 02:17:43 -0400 (Sat, 09 Aug 2008) | 4 lines
o re-integrate list_tests workaround and use stock 2.5 seq_tests
o fix list.index handling of long start values and slice assignment of strings
o raise MemoryErrors as per seq_tests.test_bigrepeat
........
r5117 | pjenvey | 2008-08-09 02:18:29 -0400 (Sat, 09 Aug 2008) | 1 line
fix test_weakref, re-enable 2.5isms
........
r5119 | fwierzbicki | 2008-08-09 09:52:14 -0400 (Sat, 09 Aug 2008) | 3 lines
debug() is not really all that necessary now that these have been extracted from
the .g files.
........
r5120 | fwierzbicki | 2008-08-09 10:00:30 -0400 (Sat, 09 Aug 2008) | 2 lines
Surely a typo?
........
r5121 | fwierzbicki | 2008-08-09 10:25:25 -0400 (Sat, 09 Aug 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test_genexps.py@...>
........
r5122 | fwierzbicki | 2008-08-09 12:27:42 -0400 (Sat, 09 Aug 2008) | 4 lines
added #doctest: +IGNORE_EXCEPTION_DETAIL for SyntaxErrors that
just have "invalid syntax" as the detail, since this is the
default message and Antlr actually gives more information.
........
r5123 | fwierzbicki | 2008-08-09 13:07:19 -0400 (Sat, 09 Aug 2008) | 2 lines
Don't allow generator expressions on left side of assignment.
........
r5124 | fwierzbicki | 2008-08-09 13:35:06 -0400 (Sat, 09 Aug 2008) | 2 lines
Call __iter__ on the iter part of gen expressions.
........
r5125 | pjenvey | 2008-08-09 17:53:44 -0400 (Sat, 09 Aug 2008) | 3 lines
fix remove() not fully zeroing out the end of the array, causing a small memory
leak. fixes test_deque.test_weakref
........
r5126 | pjenvey | 2008-08-09 18:02:39 -0400 (Sat, 09 Aug 2008) | 2 lines
reprStack isn't exposed anywhere, simplify it as a Stack
........
r5127 | pjenvey | 2008-08-09 18:05:00 -0400 (Sat, 09 Aug 2008) | 2 lines
typo/thinko
pointed out by lsoto
........
r5128 | pjenvey | 2008-08-09 19:02:50 -0400 (Sat, 09 Aug 2008) | 1 line
oops, Stack won't work because we need to compare via identity. revert r5126
........
r5129 | nriley | 2008-08-09 19:40:43 -0400 (Sat, 09 Aug 2008) | 1 line
Don't try tests expecting MemoryError which can pass with large Java heaps.
........
r5130 | fwierzbicki | 2008-08-10 11:03:21 -0400 (Sun, 10 Aug 2008) | 3 lines
Ignoring other SyntaxError details for now -- though I probably want to
re-enable these two later.
........
r5131 | fwierzbicki | 2008-08-10 11:31:52 -0400 (Sun, 10 Aug 2008) | 4 lines
Choose a name for the bound parameter to generator expressions that can't
collide with a real NAME. Arbitrarily picked _(x) just because it looks a bit
like the names of the gen expressions themselves.
........
r5132 | zyasoft | 2008-08-10 15:52:51 -0400 (Sun, 10 Aug 2008) | 5 lines
After a more careful reading of PEP 342: need to emit bytecode for
getGeneratorInput and possible raising exception before any yields;
and after each yield point.
This one-line change fixes test_contextlib
........
r5133 | leosoto | 2008-08-10 16:50:55 -0400 (Sun, 10 Aug 2008) | 3 lines
Added coercion to the cmp() algorithm, which is also used for comparison operators in the absence of rich cmp methods (See #1031). In the process, __coerce_ex__ was added to deriveds, and a slight refactor was made on types exposing __coerce__ to avoid using the __coerce_ex__ virtual method on the exposed methods code.
Fixes test_coercion.
........
r5134 | leosoto | 2008-08-10 17:09:42 -0400 (Sun, 10 Aug 2008) | 1 line
Added test_cmp_jy, with should have tests to ensure CPython compatibility on cmp(). Currently, it only contains test cases for the problems exposed on http://bugs.jython.org/issue1889394
........
r5135 | leosoto | 2008-08-10 17:14:36 -0400 (Sun, 10 Aug 2008) | 1 line
Added cmp test for http://bugs.jython.org/issue1869347
........
r5136 | leosoto | 2008-08-10 17:19:00 -0400 (Sun, 10 Aug 2008) | 1 line
Added test for http://bugs.jython.org/issue1804011 (derived_dict() must be equal to {})
........
r5137 | pjenvey | 2008-08-10 17:30:15 -0400 (Sun, 10 Aug 2008) | 3 lines
o __float__ should always return a PyFloat, no need to cast in complex new
o prefer PyObject.isCallable to __builtin__'s
........
r5138 | zyasoft | 2008-08-10 18:57:07 -0400 (Sun, 10 Aug 2008) | 3 lines
Properly closes a generator upon close/throw including throwing
StopIteration upon a send to a closed generator.
........
r5139 | zyasoft | 2008-08-10 19:14:13 -0400 (Sun, 10 Aug 2008) | 2 lines
Import test_support from test
........
r5140 | fwierzbicki | 2008-08-10 20:32:24 -0400 (Sun, 10 Aug 2008) | 3 lines
Can't assign to Num and better placement for checkAssign, so
lambdef and fplist also get checks for args.
........
r5141 | zyasoft | 2008-08-10 22:56:53 -0400 (Sun, 10 Aug 2008) | 3 lines
from X import * now raises the appropriate syntax errors (for nested
scopes) or warning (otherwise).
........
r5142 | zyasoft | 2008-08-10 23:17:44 -0400 (Sun, 10 Aug 2008) | 5 lines
Commented out inappropriate doctest in test_genexps that tested for
the reuse of memory objects. This obviously doesn't apply to Jython
and other nonrefcounted implementations.
Fixes test_genexps
........
r5143 | zyasoft | 2008-08-11 00:09:35 -0400 (Mon, 11 Aug 2008) | 3 lines
From
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_generators.py@...>
........
r5144 | leosoto | 2008-08-11 01:35:18 -0400 (Mon, 11 Aug 2008) | 1 line
Really fix coercion on derived this time
........
r5145 | fwierzbicki | 2008-08-11 01:37:15 -0400 (Mon, 11 Aug 2008) | 2 lines
Properly handle tuples in subscripts (last test_grammar problem!)
........
r5146 | zyasoft | 2008-08-11 01:52:43 -0400 (Mon, 11 Aug 2008) | 4 lines
Another corner case for generators: .throw on a just-started generator
should immediately raise an exception in the current context. Also
fixed buggy tests in test_generators.
........
r5147 | pjenvey | 2008-08-11 02:59:28 -0400 (Mon, 11 Aug 2008) | 4 lines
o change PySlice.indices to work like CPython's PySlice_GetIndicesEx (include a
slicelength value)
o reject PySequence slice assignments with a step and mismatching slicelengths
........
r5148 | pjenvey | 2008-08-11 03:03:25 -0400 (Mon, 11 Aug 2008) | 1 line
cleanup/coding standards
........
r5149 | fwierzbicki | 2008-08-11 08:44:54 -0400 (Mon, 11 Aug 2008) | 2 lines
Switch to for-each syntax in walker.
........
r5150 | fwierzbicki | 2008-08-11 12:43:44 -0400 (Mon, 11 Aug 2008) | 2 lines
Added 3 arg and 4 arg __call__
........
r5151 | fwierzbicki | 2008-08-11 14:31:41 -0400 (Mon, 11 Aug 2008) | 3 lines
remove LeadingSpaceSkippingStream and replace with LEADING_WS in Python.g.
No idea what I was thinking with LeadingSpaceSkippingStream...
........
r5152 | fwierzbicki | 2008-08-11 15:25:46 -0400 (Mon, 11 Aug 2008) | 2 lines
Tightened up eval and uncommented tests in test_jy_compile.
........
r5153 | fwierzbicki | 2008-08-11 15:48:31 -0400 (Mon, 11 Aug 2008) | 2 lines
Moved buffered stream creation from many places to one place.
........
r5154 | pjenvey | 2008-08-11 18:24:20 -0400 (Mon, 11 Aug 2008) | 3 lines
make the stepless slice ops more consistent with the compiler by passing null
for step instead of Py.One, fixes test_operator.test_setslice
........
r5155 | leosoto | 2008-08-11 19:27:27 -0400 (Mon, 11 Aug 2008) | 1 line
__findattr__ refactor. The overridable version is not called __findattr_ex__ (in the abscense of a better name), and can return null or raise AttributeError, whatever is more efficient for the implementing code. This makes *Derived getattr() more correct and fixes #1041 and #1095.
........
r5156 | fwierzbicki | 2008-08-12 13:17:12 -0400 (Tue, 12 Aug 2008) | 4 lines
Implement BOM handling as much as CPython 2.5 does. Altered
bad_coding2.py because Java, unlike CPython accepts "utf8" as
a synonymn for "utf-8"
........
r5157 | fwierzbicki | 2008-08-12 14:11:38 -0400 (Tue, 12 Aug 2008) | 2 lines
Disallow encodings from unicode input. Fixes one test in test_compile.py.
........
r5158 | fwierzbicki | 2008-08-12 14:17:00 -0400 (Tue, 12 Aug 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_compile.py@...>
........
r5159 | fwierzbicki | 2008-08-12 14:24:24 -0400 (Tue, 12 Aug 2008) | 2 lines
Don't try really long args on Jython for now.
........
r5160 | fwierzbicki | 2008-08-12 14:40:38 -0400 (Tue, 12 Aug 2008) | 2 lines
Trailing commas not allowed outside of parens.
........
r5161 | fwierzbicki | 2008-08-12 14:57:22 -0400 (Tue, 12 Aug 2008) | 3 lines
Since the comment for test_leading_newlines suggests that this
may be CPython implementation specific, skip.
........
r5162 | fwierzbicki | 2008-08-12 15:47:24 -0400 (Tue, 12 Aug 2008) | 2 lines
fixes, workarounds, and a couple of punts for test_compile.py.
........
r5163 | leosoto | 2008-08-12 18:58:47 -0400 (Tue, 12 Aug 2008) | 1 line
subprocess.Popen now "inherits" os.environ if env is not explictely set. Fixes #1104
........
r5164 | fwierzbicki | 2008-08-12 20:30:38 -0400 (Tue, 12 Aug 2008) | 4 lines
Before this check-in there was an AST inconsistency with CPython. To pick one
example, CPython's AST for --1 is (USub(-1)) and Jython is (Usub(Usub(1)). This
fixes that inconsistency.
........
r5165 | fwierzbicki | 2008-08-12 20:53:09 -0400 (Tue, 12 Aug 2008) | 4 lines
Avoiding a test for constant folding -- I think it is an implementation detail
though I think it wouldn't be too hard to fix in the grammar. It's just not a
top priority.
........
r5166 | fwierzbicki | 2008-08-12 23:48:00 -0400 (Tue, 12 Aug 2008) | 2 lines
Remove direct exception throwing for tooling.
........
r5168 | fwierzbicki | 2008-08-13 10:52:12 -0400 (Wed, 13 Aug 2008) | 2 lines
Jython can handle atof with hex floats and large unicode values.
........
r5169 | fwierzbicki | 2008-08-13 12:21:18 -0400 (Wed, 13 Aug 2008) | 2 lines
remove comment that is no longer True, thanks to Leo Soto for pointing this out.
........
r5170 | fwierzbicki | 2008-08-13 15:25:13 -0400 (Wed, 13 Aug 2008) | 3 lines
from:
http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_syntax.py@...>
........
r5171 | fwierzbicki | 2008-08-13 15:48:08 -0400 (Wed, 13 Aug 2008) | 2 lines
Make errtext optional in test_syntax and fixed illegal delete of function call.
........
r5172 | pjenvey | 2008-08-13 19:35:12 -0400 (Wed, 13 Aug 2008) | 3 lines
fix alignment of little and big endian long longs. caused extra padding which
broke test_zipfile zip64 tests
........
r5173 | fwierzbicki | 2008-08-13 20:07:31 -0400 (Wed, 13 Aug 2008) | 2 lines
Add EOF check for file_input.
........
r5174 | fwierzbicki | 2008-08-13 20:35:01 -0400 (Wed, 13 Aug 2008) | 2 lines
antlr 3.1 final.
........
r5175 | fwierzbicki | 2008-08-13 22:00:01 -0400 (Wed, 13 Aug 2008) | 2 lines
Add EOF to single_input.
........
r5176 | fwierzbicki | 2008-08-14 13:51:34 -0400 (Thu, 14 Aug 2008) | 2 lines
Updated comment.
........
r5177 | fwierzbicki | 2008-08-14 14:48:37 -0400 (Thu, 14 Aug 2008) | 4 lines
Ignoring exception message details. This actually allows more of this test to
run (the doctests don't run if any of the regular tests fail). This reveals
more legitimate failures than before.
........
r5178 | fwierzbicki | 2008-08-15 07:43:53 -0400 (Fri, 15 Aug 2008) | 2 lines
Use same lexer and token source for parsing and partial parsing.
........
r5179 | fwierzbicki | 2008-08-15 13:55:20 -0400 (Fri, 15 Aug 2008) | 2 lines
small name change.
........
r5180 | fwierzbicki | 2008-08-15 14:37:14 -0400 (Fri, 15 Aug 2008) | 3 lines
don't allow assignment to yields. Fixes 2 doctests in test_generator as long as we
ignore the exact error message.
........
r5181 | fwierzbicki | 2008-08-15 15:44:57 -0400 (Fri, 15 Aug 2008) | 2 lines
Refactor: put repeated code into one method.
........
r5182 | leosoto | 2008-08-15 16:15:50 -0400 (Fri, 15 Aug 2008) | 1 line
A start for unicodedata. Only implements normalize()
........
r5183 | leosoto | 2008-08-15 19:03:17 -0400 (Fri, 15 Aug 2008) | 1 line
Reverted r5182, as the implementation of unicodedata.normalize required Java 1.6. Sorry!
........
r5184 | zyasoft | 2008-08-16 01:35:48 -0400 (Sat, 16 Aug 2008) | 18 lines
Fixes for and in test_builtin:
* test_builtin.test_cmp because we let Jython compare objects with cycles
in them, unlike CPython
* test_builtin.test_general_eval - Jython can use arbitrary maps for
globals; this was discussed for CPython. Not in current 2.6,
perhaps because it touched a lot of code or issues with performance
(see http://bugs.python.org/issue1402289)
* __builtin__#eval/compile - Now validate that locals or globals are
in fact mapping objects, as well as ensure that locals().keys() is
a PyList (to avoid throwing a CheckCastException)
* Py#compile_flags - if passed in a String to compile, ensure it does
not contain a null byte
........
r5185 | nriley | 2008-08-16 02:09:33 -0400 (Sat, 16 Aug 2008) | 1 line
Permit removal/modification of attributes on PySystemState; add __name__.
........
r5186 | nriley | 2008-08-16 02:18:30 -0400 (Sat, 16 Aug 2008) | 1 line
Update Eclipse classpath to Antlr 3.1 final.
........
r5187 | zyasoft | 2008-08-16 02:22:40 -0400 (Sat, 16 Aug 2008) | 5 lines
input and raw_input now appropriately raise a RuntimeError if
sys.stdin/stdout are deleted (via the facade of
PySystemState.PyAttributeDeleted)
........
r5188 | fwierzbicki | 2008-08-16 09:56:28 -0400 (Sat, 16 Aug 2008) | 2 lines
Method not used.
........
r5189 | fwierzbicki | 2008-08-16 15:31:55 -0400 (Sat, 16 Aug 2008) | 2 lines
Shouldn't be discarding hidden tokens.
........
r5190 | fwierzbicki | 2008-08-16 18:46:04 -0400 (Sat, 16 Aug 2008) | 2 lines
Fix comment/newline parsing problems in interactive (single) parsing.
........
r5191 | fwierzbicki | 2008-08-16 20:02:42 -0400 (Sat, 16 Aug 2008) | 3 lines
check for Py.None in runCode as well as null for locals
and globals. Fixes test_decorators.py
........
r5192 | nriley | 2008-08-16 22:23:19 -0400 (Sat, 16 Aug 2008) | 1 line
Option to enable bytecode verifier.
........
r5193 | nriley | 2008-08-17 11:24:17 -0400 (Sun, 17 Aug 2008) | 1 line
Better comment for PySystemState method hack: depends on "functions" in __dict__ appearing as methods.
........
r5194 | leosoto | 2008-08-17 22:12:34 -0400 (Sun, 17 Aug 2008) | 1 line
PythonInterpreter#cflags initialization moved to PythonInterpreter itself. Fixes a crash on modjy
........
r5195 | leosoto | 2008-08-17 22:39:57 -0400 (Sun, 17 Aug 2008) | 1 line
PyArray#array_fromunicode: Worked around the issue described on #1105 (wrong exposed bytecode when receiving a PyUnicode argument on a exposed method), by receiving a PyObject and doing the type-check manually
........
r5196 | zyasoft | 2008-08-18 03:17:46 -0400 (Mon, 18 Aug 2008) | 7 lines
Strings are UTF-8 encoded in the runtime constant pool, meaning that
naively (and that is a reasonable strategy here), we need up to 4
bytes per codepoint. So allocate string constants up to 16000 bytes
and combine as necessary. This resolves one Pygments problem (and the
one we can directly do anything about, the other is isolated
surrogates in unistring.Cs).
........
r5197 | nriley | 2008-08-18 10:46:22 -0400 (Mon, 18 Aug 2008) | 1 line
Run Jython regrtest (on unix) with bytecode verification.
........
Modified Paths:
--------------
trunk/jython/.classpath
trunk/jython/CPythonLib.includes
trunk/jython/CoreExposed.includes
trunk/jython/Lib/codeop.py
trunk/jython/Lib/datetime.py
trunk/jython/Lib/distutils/ccompiler.py
trunk/jython/Lib/distutils/command/bdist.py
trunk/jython/Lib/distutils/command/bdist_dumb.py
trunk/jython/Lib/distutils/command/install.py
trunk/jython/Lib/distutils/command/sdist.py
trunk/jython/Lib/distutils/file_util.py
trunk/jython/Lib/distutils/spawn.py
trunk/jython/Lib/distutils/sysconfig.py
trunk/jython/Lib/distutils/util.py
trunk/jython/Lib/doctest.py
trunk/jython/Lib/fileinput.py
trunk/jython/Lib/gzip.py
trunk/jython/Lib/inspect.py
trunk/jython/Lib/ntpath.py
trunk/jython/Lib/os.py
trunk/jython/Lib/popen2.py
trunk/jython/Lib/posixpath.py
trunk/jython/Lib/site.py
trunk/jython/Lib/socket.py
trunk/jython/Lib/subprocess.py
trunk/jython/Lib/test/list_tests.py
trunk/jython/Lib/test/regrtest.py
trunk/jython/Lib/test/string_tests.py
trunk/jython/Lib/test/test_ast.py
trunk/jython/Lib/test/test_builtin.py
trunk/jython/Lib/test/test_deque.py
trunk/jython/Lib/test/test_descr.py
trunk/jython/Lib/test/test_descr_jy.py
trunk/jython/Lib/test/test_descrtut.py
trunk/jython/Lib/test/test_dict_jy.py
trunk/jython/Lib/test/test_enumerate.py
trunk/jython/Lib/test/test_file_newlines.py
trunk/jython/Lib/test/test_float_jy.py
trunk/jython/Lib/test/test_format.py
trunk/jython/Lib/test/test_format_jy.py
trunk/jython/Lib/test/test_grammar_jy.py
trunk/jython/Lib/test/test_importhooks.py
trunk/jython/Lib/test/test_inspect.py
trunk/jython/Lib/test/test_iter.py
trunk/jython/Lib/test/test_iter_jy.py
trunk/jython/Lib/test/test_java_integration.py
trunk/jython/Lib/test/test_javashell.py
trunk/jython/Lib/test/test_jreload.py
trunk/jython/Lib/test/test_jser2.py
trunk/jython/Lib/test/test_jy_compile.py
trunk/jython/Lib/test/test_jy_internals.py
trunk/jython/Lib/test/test_largefile.py
trunk/jython/Lib/test/test_logging.py
trunk/jython/Lib/test/test_long_int_args.py
trunk/jython/Lib/test/test_mhlib.py
trunk/jython/Lib/test/test_optparse.py
trunk/jython/Lib/test/test_re_jy.py
trunk/jython/Lib/test/test_repr.py
trunk/jython/Lib/test/test_richcmp.py
trunk/jython/Lib/test/test_scope.py
trunk/jython/Lib/test/test_select.py
trunk/jython/Lib/test/test_select_new.py
trunk/jython/Lib/test/test_slots_jy.py
trunk/jython/Lib/test/test_socket.py
trunk/jython/Lib/test/test_str_jy.py
trunk/jython/Lib/test/test_subclasses.py
trunk/jython/Lib/test/test_sys_jy.py
trunk/jython/Lib/test/test_time.py
trunk/jython/Lib/test/test_types.py
trunk/jython/Lib/test/test_zlib.py
trunk/jython/Lib/threading.py
trunk/jython/Lib/xml/dom/pulldom.py
trunk/jython/Lib/zlib.py
trunk/jython/Misc/make_binops.py
trunk/jython/NEWS
trunk/jython/README.txt
trunk/jython/ast/asdl_antlr.py
trunk/jython/ast/astdump.py
trunk/jython/build.xml
trunk/jython/grammar/Python.g
trunk/jython/grammar/PythonWalker.g
trunk/jython/src/com/ziclix/python/sql/DataHandler.java
trunk/jython/src/com/ziclix/python/sql/Fetch.java
trunk/jython/src/com/ziclix/python/sql/PyConnection.java
trunk/jython/src/com/ziclix/python/sql/PyCursor.java
trunk/jython/src/com/ziclix/python/sql/PyExtendedCursor.java
trunk/jython/src/com/ziclix/python/sql/PyStatement.java
trunk/jython/src/com/ziclix/python/sql/connect/Connect.java
trunk/jython/src/com/ziclix/python/sql/connect/Connectx.java
trunk/jython/src/com/ziclix/python/sql/connect/Lookup.java
trunk/jython/src/com/ziclix/python/sql/handler/PostgresqlDataHandler.java
trunk/jython/src/com/ziclix/python/sql/util/BCP.java
trunk/jython/src/com/ziclix/python/sql/zxJDBC.java
trunk/jython/src/org/python/antlr/ExpressionParser.java
trunk/jython/src/org/python/antlr/InteractiveParser.java
trunk/jython/src/org/python/antlr/ParseException.java
trunk/jython/src/org/python/antlr/PythonTokenSource.java
trunk/jython/src/org/python/antlr/PythonTree.java
trunk/jython/src/org/python/antlr/ast/Assert.java
trunk/jython/src/org/python/antlr/ast/Assign.java
trunk/jython/src/org/python/antlr/ast/Attribute.java
trunk/jython/src/org/python/antlr/ast/AugAssign.java
trunk/jython/src/org/python/antlr/ast/BinOp.java
trunk/jython/src/org/python/antlr/ast/BoolOp.java
trunk/jython/src/org/python/antlr/ast/Break.java
trunk/jython/src/org/python/antlr/ast/Call.java
trunk/jython/src/org/python/antlr/ast/ClassDef.java
trunk/jython/src/org/python/antlr/ast/Compare.java
trunk/jython/src/org/python/antlr/ast/Continue.java
trunk/jython/src/org/python/antlr/ast/Delete.java
trunk/jython/src/org/python/antlr/ast/Dict.java
trunk/jython/src/org/python/antlr/ast/Ellipsis.java
trunk/jython/src/org/python/antlr/ast/Exec.java
trunk/jython/src/org/python/antlr/ast/Expr.java
trunk/jython/src/org/python/antlr/ast/Expression.java
trunk/jython/src/org/python/antlr/ast/ExtSlice.java
trunk/jython/src/org/python/antlr/ast/For.java
trunk/jython/src/org/python/antlr/ast/FunctionDef.java
trunk/jython/src/org/python/antlr/ast/GeneratorExp.java
trunk/jython/src/org/python/antlr/ast/Global.java
trunk/jython/src/org/python/antlr/ast/If.java
trunk/jython/src/org/python/antlr/ast/IfExp.java
trunk/jython/src/org/python/antlr/ast/Import.java
trunk/jython/src/org/python/antlr/ast/ImportFrom.java
trunk/jython/src/org/python/antlr/ast/Index.java
trunk/jython/src/org/python/antlr/ast/Interactive.java
trunk/jython/src/org/python/antlr/ast/Lambda.java
trunk/jython/src/org/python/antlr/ast/List.java
trunk/jython/src/org/python/antlr/ast/ListComp.java
trunk/jython/src/org/python/antlr/ast/Module.java
trunk/jython/src/org/python/antlr/ast/Name.java
trunk/jython/src/org/python/antlr/ast/Num.java
trunk/jython/src/org/python/antlr/ast/Pass.java
trunk/jython/src/org/python/antlr/ast/Print.java
trunk/jython/src/org/python/antlr/ast/Raise.java
trunk/jython/src/org/python/antlr/ast/Repr.java
trunk/jython/src/org/python/antlr/ast/Return.java
trunk/jython/src/org/python/antlr/ast/Slice.java
trunk/jython/src/org/python/antlr/ast/Str.java
trunk/jython/src/org/python/antlr/ast/Subscript.java
trunk/jython/src/org/python/antlr/ast/Suite.java
trunk/jython/src/org/python/antlr/ast/TryExcept.java
trunk/jython/src/org/python/antlr/ast/TryFinally.java
trunk/jython/src/org/python/antlr/ast/Tuple.java
trunk/jython/src/org/python/antlr/ast/UnaryOp.java
trunk/jython/src/org/python/antlr/ast/Unicode.java
trunk/jython/src/org/python/antlr/ast/VisitorBase.java
trunk/jython/src/org/python/antlr/ast/While.java
trunk/jython/src/org/python/antlr/ast/With.java
trunk/jython/src/org/python/antlr/ast/Yield.java
trunk/jython/src/org/python/antlr/ast/aliasType.java
trunk/jython/src/org/python/antlr/ast/argumentsType.java
trunk/jython/src/org/python/antlr/ast/comprehensionType.java
trunk/jython/src/org/python/antlr/ast/excepthandlerType.java
trunk/jython/src/org/python/antlr/ast/exprType.java
trunk/jython/src/org/python/antlr/ast/keywordType.java
trunk/jython/src/org/python/antlr/ast/modType.java
trunk/jython/src/org/python/antlr/ast/sliceType.java
trunk/jython/src/org/python/antlr/ast/stmtType.java
trunk/jython/src/org/python/compiler/APIVersion.java
trunk/jython/src/org/python/compiler/AdapterMaker.java
trunk/jython/src/org/python/compiler/ArgListCompiler.java
trunk/jython/src/org/python/compiler/ClassFile.java
trunk/jython/src/org/python/compiler/Code.java
trunk/jython/src/org/python/compiler/CodeCompiler.java
trunk/jython/src/org/python/compiler/CompilationContext.java
trunk/jython/src/org/python/compiler/Constant.java
trunk/jython/src/org/python/compiler/Future.java
trunk/jython/src/org/python/compiler/JavaMaker.java
trunk/jython/src/org/python/compiler/LineNumberTable.java
trunk/jython/src/org/python/compiler/Module.java
trunk/jython/src/org/python/compiler/ProxyMaker.java
trunk/jython/src/org/python/compiler/ScopeInfo.java
trunk/jython/src/org/python/compiler/ScopesCompiler.java
trunk/jython/src/org/python/compiler/SourceFile.java
trunk/jython/src/org/python/core/AbstractArray.java
trunk/jython/src/org/python/core/ArgParser.java
trunk/jython/src/org/python/core/AutoInternalTables.java
trunk/jython/src/org/python/core/CompilerFlags.java
trunk/jython/src/org/python/core/FunctionThread.java
trunk/jython/src/org/python/core/IdImpl.java
trunk/jython/src/org/python/core/NewCompilerResources.java
trunk/jython/src/org/python/core/Options.java
trunk/jython/src/org/python/core/Py.java
trunk/jython/src/org/python/core/PyArray.java
trunk/jython/src/org/python/core/PyArrayDerived.java
trunk/jython/src/org/python/core/PyBoolean.java
trunk/jython/src/org/python/core/PyBooleanDerived.java
trunk/jython/src/org/python/core/PyCallIter.java
trunk/jython/src/org/python/core/PyClass.java
trunk/jython/src/org/python/core/PyClassMethodDerived.java
trunk/jython/src/org/python/core/PyComplex.java
trunk/jython/src/org/python/core/PyComplexDerived.java
trunk/jython/src/org/python/core/PyDictionaryDerived.java
trunk/jython/src/org/python/core/PyEnumerateDerived.java
trunk/jython/src/org/python/core/PyException.java
trunk/jython/src/org/python/core/PyFastSequenceIter.java
trunk/jython/src/org/python/core/PyFileDerived.java
trunk/jython/src/org/python/core/PyFloat.java
trunk/jython/src/org/python/core/PyFloatDerived.java
trunk/jython/src/org/python/core/PyFrame.java
trunk/jython/src/org/python/core/PyFrozenSetDerived.java
trunk/jython/src/org/python/core/PyGenerator.java
trunk/jython/src/org/python/core/PyInstance.java
trunk/jython/src/org/python/core/PyInteger.java
trunk/jython/src/org/python/core/PyIntegerDerived.java
trunk/jython/src/org/python/core/PyJavaClass.java
trunk/jython/src/org/python/core/PyJavaPackage.java
trunk/jython/src/org/python/core/PyList.java
trunk/jython/src/org/python/core/PyListDerived.java
trunk/jython/src/org/python/core/PyLong.java
trunk/jython/src/org/python/core/PyLongDerived.java
trunk/jython/src/org/python/core/PyMethod.java
trunk/jython/src/org/python/core/PyModule.java
trunk/jython/src/org/python/core/PyModuleDerived.java
trunk/jython/src/org/python/core/PyObject.java
trunk/jython/src/org/python/core/PyObjectDerived.java
trunk/jython/src/org/python/core/PyPropertyDerived.java
trunk/jython/src/org/python/core/PySequence.java
trunk/jython/src/org/python/core/PySequenceIter.java
trunk/jython/src/org/python/core/PySet.java
trunk/jython/src/org/python/core/PySetDerived.java
trunk/jython/src/org/python/core/PySlice.java
trunk/jython/src/org/python/core/PySliceDerived.java
trunk/jython/src/org/python/core/PyString.java
trunk/jython/src/org/python/core/PyStringDerived.java
trunk/jython/src/org/python/core/PySuper.java
trunk/jython/src/org/python/core/PySuperDerived.java
trunk/jython/src/org/python/core/PySyntaxError.java
trunk/jython/src/org/python/core/PySystemState.java
trunk/jython/src/org/python/core/PyTableCode.java
trunk/jython/src/org/python/core/PyTraceback.java
trunk/jython/src/org/python/core/PyTuple.java
trunk/jython/src/org/python/core/PyTupleDerived.java
trunk/jython/src/org/python/core/PyType.java
trunk/jython/src/org/python/core/PyTypeDerived.java
trunk/jython/src/org/python/core/PyUnicode.java
trunk/jython/src/org/python/core/PyUnicodeDerived.java
trunk/jython/src/org/python/core/StdoutWrapper.java
trunk/jython/src/org/python/core/ThreadState.java
trunk/jython/src/org/python/core/ThreadStateMapping.java
trunk/jython/src/org/python/core/__builtin__.java
trunk/jython/src/org/python/core/codecs.java
trunk/jython/src/org/python/core/exceptions.java
trunk/jython/src/org/python/core/imp.java
trunk/jython/src/org/python/core/io/FileIO.java
trunk/jython/src/org/python/core/io/StreamIO.java
trunk/jython/src/org/python/core/io/TextIOBase.java
trunk/jython/src/org/python/modules/ArrayModule.java
trunk/jython/src/org/python/modules/Setup.java
trunk/jython/src/org/python/modules/_codecs.java
trunk/jython/src/org/python/modules/_sre.java
trunk/jython/src/org/python/modules/_weakref/ProxyType.java
trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java
trunk/jython/src/org/python/modules/binascii.java
trunk/jython/src/org/python/modules/cPickle.java
trunk/jython/src/org/python/modules/cStringIO.java
trunk/jython/src/org/python/modules/cmath.java
trunk/jython/src/org/python/modules/collections/PyDefaultDictDerived.java
trunk/jython/src/org/python/modules/collections/PyDeque.java
trunk/jython/src/org/python/modules/collections/PyDequeDerived.java
trunk/jython/src/org/python/modules/imp.java
trunk/jython/src/org/python/modules/operator.java
trunk/jython/src/org/python/modules/random/PyRandomDerived.java
trunk/jython/src/org/python/modules/sre/MatchObject.java
trunk/jython/src/org/python/modules/sre/PatternObject.java
trunk/jython/src/org/python/modules/sre/SRE_STATE.java
trunk/jython/src/org/python/modules/struct.java
trunk/jython/src/org/python/modules/thread/PyLocalDerived.java
trunk/jython/src/org/python/modules/thread/thread.java
trunk/jython/src/org/python/modules/time/PyTimeTuple.java
trunk/jython/src/org/python/modules/time/Time.java
trunk/jython/src/org/python/modules/zipimport/zipimport.java
trunk/jython/src/org/python/modules/zipimport/zipimporter.java
trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java
trunk/jython/src/org/python/util/InteractiveConsole.java
trunk/jython/src/org/python/util/InteractiveInterpreter.java
trunk/jython/src/org/python/util/PythonInterpreter.java
trunk/jython/src/org/python/util/jython.java
trunk/jython/src/shell/jython
trunk/jython/src/templates/gderived-defs
trunk/jython/src/templates/make_binops.py
trunk/jython/src/templates/mappings
trunk/jython/src/templates/object.derived
trunk/jython/tests/shell/test-jython.sh
Added Paths:
-----------
trunk/jython/Lib/_rawffi.py
trunk/jython/Lib/decimal.py
trunk/jython/Lib/distutils/tests/
trunk/jython/Lib/distutils/tests/test_build_py.py
trunk/jython/Lib/grp.py
trunk/jython/Lib/pkgutil.py
trunk/jython/Lib/platform.py
trunk/jython/Lib/posix.py
trunk/jython/Lib/pwd.py
trunk/jython/Lib/random.py
trunk/jython/Lib/sre_compile.py
trunk/jython/Lib/test/bad_coding2.py
trunk/jython/Lib/test/junit_xml.py
trunk/jython/Lib/test/test__rawffi.py
trunk/jython/Lib/test/test_array.py
trunk/jython/Lib/test/test_array_jy.py
trunk/jython/Lib/test/test_bigmem.py
trunk/jython/Lib/test/test_class.py
trunk/jython/Lib/test/test_cmd_line.py
trunk/jython/Lib/test/test_cmp_jy.py
trunk/jython/Lib/test/test_codeop.py
trunk/jython/Lib/test/test_compile.py
trunk/jython/Lib/test/test_exceptions.py
trunk/jython/Lib/test/test_exceptions_jy.py
trunk/jython/Lib/test/test_functools.py
trunk/jython/Lib/test/test_generators.py
trunk/jython/Lib/test/test_genexps.py
trunk/jython/Lib/test/test_hashlib.py
trunk/jython/Lib/test/test_hmac.py
trunk/jython/Lib/test/test_isatty.py
trunk/jython/Lib/test/test_operator.py
trunk/jython/Lib/test/test_pkgimport.py
trunk/jython/Lib/test/test_re.py
trunk/jython/Lib/test/test_str.py
trunk/jython/Lib/test/test_subprocess_jy.py
trunk/jython/Lib/test/test_support.py
trunk/jython/Lib/test/test_syntax.py
trunk/jython/Lib/test/test_thread.py
trunk/jython/Lib/test/test_threading.py
trunk/jython/Lib/test/test_traceback.py
trunk/jython/Lib/test/test_tuple.py
trunk/jython/Lib/test/test_urllib.py
trunk/jython/Lib/test/test_urllib2_localnet.py
trunk/jython/Lib/uu.py
trunk/jython/extlibs/antlr-3.1.jar
trunk/jython/extlibs/antlr-runtime-3.1.jar
trunk/jython/extlibs/jna-posix.jar
trunk/jython/extlibs/jna.jar
trunk/jython/extlibs/stringtemplate-3.2.jar
trunk/jython/extlibs/svnant-jars/
trunk/jython/extlibs/svnant-jars/svnClientAdapter.jar
trunk/jython/extlibs/svnant-jars/svnant.jar
trunk/jython/extlibs/svnant-jars/svnjavahl.jar
trunk/jython/grammar/PythonPartial.g
trunk/jython/src/com/ziclix/python/sql/Jython22DataHandler.java
trunk/jython/src/org/python/antlr/BaseParser.java
trunk/jython/src/org/python/antlr/ErrorHandler.java
trunk/jython/src/org/python/antlr/FailFastHandler.java
trunk/jython/src/org/python/antlr/GrammarActions.java
trunk/jython/src/org/python/antlr/ListErrorHandler.java
trunk/jython/src/org/python/antlr/ModuleParser.java
trunk/jython/src/org/python/antlr/NoCloseReaderStream.java
trunk/jython/src/org/python/antlr/PythonErrorNode.java
trunk/jython/src/org/python/antlr/PythonTreeAdaptor.java
trunk/jython/src/org/python/antlr/Visitor.java
trunk/jython/src/org/python/antlr/ast/Context.java
trunk/jython/src/org/python/antlr/ast/ErrorExpr.java
trunk/jython/src/org/python/antlr/ast/ErrorMod.java
trunk/jython/src/org/python/antlr/ast/ErrorSlice.java
trunk/jython/src/org/python/antlr/ast/ErrorStmt.java
trunk/jython/src/org/python/core/APIReader.java
trunk/jython/src/org/python/core/ParserFacade.java
trunk/jython/src/org/python/core/PyBaseException.java
trunk/jython/src/org/python/core/PyBaseExceptionDerived.java
trunk/jython/src/org/python/core/PyIndentationError.java
trunk/jython/src/org/python/core/io/TextIOInputStream.java
trunk/jython/src/org/python/modules/_csv/
trunk/jython/src/org/python/modules/_csv/PyDialect.java
trunk/jython/src/org/python/modules/_csv/PyDialectDerived.java
trunk/jython/src/org/python/modules/_csv/PyReader.java
trunk/jython/src/org/python/modules/_csv/PyWriter.java
trunk/jython/src/org/python/modules/_csv/QuoteStyle.java
trunk/jython/src/org/python/modules/_csv/_csv.java
trunk/jython/src/org/python/modules/_functools/
trunk/jython/src/org/python/modules/_functools/PyPartial.java
trunk/jython/src/org/python/modules/_functools/PyPartialDerived.java
trunk/jython/src/org/python/modules/_functools/_functools.java
trunk/jython/src/org/python/modules/_hashlib.java
trunk/jython/src/org/python/modules/_systemrestart.java
trunk/jython/src/shell/jython.bat
trunk/jython/src/templates/BaseException.derived
trunk/jython/src/templates/dialect.derived
trunk/jython/src/templates/partial.derived
trunk/jython/tests/c/
trunk/jython/tests/c/ctypes_test.c
trunk/jython/tests/java/org/python/antlr/
trunk/jython/tests/java/org/python/antlr/GrammarTester.java
trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java
trunk/jython/tests/java/org/python/antlr/PythonTreeTester.java
trunk/jython/tests/java/org/python/antlr/WalkerTester.java
Removed Paths:
-------------
trunk/jython/Lib/Queue.py
trunk/jython/Lib/UserList.py
trunk/jython/Lib/UserString.py
trunk/jython/Lib/copy.py
trunk/jython/Lib/distutils/tests/test_build_py.py
trunk/jython/Lib/re.py
trunk/jython/Lib/sre_compile.py
trunk/jython/Lib/test/mapping_tests.py
trunk/jython/Lib/test/output/test_array
trunk/jython/Lib/test/output/test_operations
trunk/jython/Lib/test/output/test_re
trunk/jython/Lib/test/output/test_types
trunk/jython/Lib/test/seq_tests.py
trunk/jython/Lib/test/test_array.py
trunk/jython/Lib/test/test_bisect.py
trunk/jython/Lib/test/test_call.py
trunk/jython/Lib/test/test_dict.py
trunk/jython/Lib/test/test_exceptions_jy.py
trunk/jython/Lib/test/test_funcattrs.py
trunk/jython/Lib/test/test_generators.py
trunk/jython/Lib/test/test_iterlen.py
trunk/jython/Lib/test/test_list.py
trunk/jython/Lib/test/test_long.py
trunk/jython/Lib/test/test_mailbox.py
trunk/jython/Lib/test/test_math.py
trunk/jython/Lib/test/test_operations.py
trunk/jython/Lib/test/test_popen.py
trunk/jython/Lib/test/test_queue.py
trunk/jython/Lib/test/test_slice.py
trunk/jython/Lib/test/test_socket_ipv6.py
trunk/jython/Lib/test/test_support.py
trunk/jython/Lib/test/test_unicodedata.py
trunk/jython/Lib/test/test_urllib.py
trunk/jython/Lib/test/test_userlist.py
trunk/jython/Lib/uu.py
trunk/jython/Lib/weakref.py
trunk/jython/extlibs/antlr-3.1b1.jar
trunk/jython/extlibs/antlr-runtime-3.1b1.jar
trunk/jython/extlibs/stringtemplate-3.1b1.jar
trunk/jython/extlibs/svnant-jars/svnClientAdapter.jar
trunk/jython/extlibs/svnant-jars/svnant.jar
trunk/jython/extlibs/svnant-jars/svnjavahl.jar
trunk/jython/src/org/python/antlr/GrammarTester.java
trunk/jython/src/org/python/antlr/IParserHost.java
trunk/jython/src/org/python/antlr/LeadingSpaceSkippingStream.java
trunk/jython/src/org/python/antlr/PythonGrammar.java
trunk/jython/src/org/python/antlr/PythonTreeTester.java
trunk/jython/src/org/python/antlr/WalkerTester.java
trunk/jython/src/org/python/compiler/Attribute.java
trunk/jython/src/org/python/compiler/ConstantPool.java
trunk/jython/src/org/python/compiler/Label.java
trunk/jython/src/org/python/core/antlr.java
trunk/jython/src/org/python/core/parser.java
trunk/jython/src/org/python/modules/MD5Module.java
trunk/jython/src/org/python/modules/MD5Object.java
trunk/jython/src/org/python/modules/SHA1.java
trunk/jython/src/org/python/modules/_csv/PyDialect.java
trunk/jython/src/org/python/modules/_csv/PyDialectDerived.java
trunk/jython/src/org/python/modules/_csv/PyReader.java
trunk/jython/src/org/python/modules/_csv/PyWriter.java
trunk/jython/src/org/python/modules/_csv/QuoteStyle.java
trunk/jython/src/org/python/modules/_csv/_csv.java
trunk/jython/src/org/python/modules/_functools/PyPartial.java
trunk/jython/src/org/python/modules/_functools/PyPartialDerived.java
trunk/jython/src/org/python/modules/_functools/_functools.java
trunk/jython/src/org/python/modules/md.java
trunk/jython/src/org/python/modules/sha.java
trunk/jython/src/org/python/modules/xreadlines.java
trunk/jython/src/org/python/parser/
trunk/jython/tests/c/ctypes_test.c
trunk/jython/tests/java/org/python/antlr/GrammarTester.java
trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java
trunk/jython/tests/java/org/python/antlr/PythonTreeTester.java
trunk/jython/tests/java/org/python/antlr/WalkerTester.java
Property Changed:
----------------
trunk/jython/
Property changes on: trunk/jython
___________________________________________________________________
Modified: svn:externals
- CPythonLib http://svn.python.org/projects/python/branches/release23-maint/Lib/
+ CPythonLib http://svn.python.org/projects/python/branches/release25-maint/Lib/
Modified: svnmerge-integrated
- /branches/asm:1-4384
+ /branches/asm:1-5205
Modified: trunk/jython/.classpath
===================================================================
--- trunk/jython/.classpath 2008-08-19 15:07:48 UTC (rev 5205)
+++ trunk/jython/.classpath 2008-08-19 21:06:39 UTC (rev 5206)
@@ -14,7 +14,7 @@
<classpathentry kind="lib" path="extlibs/postgresql-8.3-603.jdbc4.jar"/>
<classpathentry kind="lib" path="extlibs/servlet-api-2.5.jar"/>
<classpathentry kind="lib" path="build/jarjar"/>
- <classpathentry kind="lib" path="extlibs/antlr-3.0.1.jar"/>
<classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/>
+ <classpathentry kind="lib" path="extlibs/antlr-runtime-3.1.jar"/>
<classpathentry kind="output" path="bugtests/classes"/>
</classpath>
Modified: trunk/jython/CPythonLib.includes
===================================================================
--- trunk/jython/CPythonLib.includes 2008-08-19 15:07:48 UTC (rev 5205)
+++ trunk/jython/CPythonLib.includes 2008-08-19 21:06:39 UTC (rev 5206)
@@ -11,6 +11,10 @@
# Lib files, in alphabetical order:
__future__.py
+_LWPCookieJar.py
+_MozillaCookieJar.py
+_strptime.py
+_threading_local.py
aifc.py
anydbm.py
atexit.py
@@ -33,14 +37,18 @@
colorsys.py
commands.py
compileall.py
+contextlib.py
ConfigParser.py
+cookielib.py
copy.py
copy_reg.py
Cookie.py
+csv.py
difflib.py
dircache.py
dircmp.py
dis.py
+DocXMLRPCServer.py
dospath.py
dumbdbm.py
exceptions.py
@@ -50,17 +58,20 @@
formatter.py
fpformat.py
ftplib.py
+functools.py
getopt.py
gettext.py
glob.py
gopherlib.py
gzip.py
+hashlib.py
heapq.py
hmac.py
htmlentitydefs.py
htmllib.py
HTMLParser.py
httplib.py
+ihooks.py
imaplib.py
imghdr.py
inspect.py
@@ -72,6 +83,7 @@
mailbox.py
mailcap.py
markupbase.py
+md5.py
mhlib.py
mimetools.py
mimetypes.py
@@ -91,6 +103,7 @@
pickletools.py
pipes.py
pkgutil.py
+platform.py
poplib.py
posixfile.py
pprint.py
@@ -101,11 +114,15 @@
Queue.py
quopri.py
random.py
+re.py
reconvert.py
repr.py
rfc822.py
rlcompleter.py
+robotparser.py
+runpy.py
sched.py
+sha.py
sets.py
sgmllib.py
shelve.py
@@ -123,12 +140,14 @@
string.py
StringIO.py
symbol.py
+tabnanny.py
this.py
threading.py
textwrap.py
timeit.py
token.py
tokenize.py
+trace.py
traceback.py
tzparse.py
unittest.py
@@ -137,12 +156,15 @@
urlparse.py
user.py
UserDict.py
+UserList.py
UserString.py
uu.py
+uuid.py
warnings.py
weakref.py
whichdb.py
whrandom.py
+wsgiref/*.py
xdrlib.py
xmllib.py
xmlrpclib.py
Modified: trunk/jython/CoreExposed.includes
===================================================================
--- trunk/jython/CoreExposed.includes 2008-08-19 15:07:48 UTC (rev 5205)
+++ trunk/jython/CoreExposed.includes 2008-08-19 21:06:39 UTC (rev 5206)
@@ -1,5 +1,6 @@
org/python/core/PyArray.class
org/python/core/PyBaseString.class
+org/python/core/PyBaseException.class
org/python/core/PyBoolean.class
org/python/core/PyBuiltinFunction.class
org/python/core/PyCell.class
@@ -34,9 +35,15 @@
org/python/core/PyType.class
org/python/core/PyUnicode.class
org/python/core/PyXRange.class
+org/python/modules/_codecs$EncodingMap.class
+org/python/modules/_csv/PyDialect.class
+org/python/modules/_csv/PyReader.class
+org/python/modules/_csv/PyWriter.class
+org/python/modules/_functools/PyPartial.class
org/python/modules/_weakref/CallableProxyType.class
org/python/modules/_weakref/ReferenceType.class
org/python/modules/_weakref/ProxyType.class
+org/python/modules/_hashlib$Hash.class
org/python/modules/collections/PyDefaultDict.class
org/python/modules/collections/PyDeque.class
org/python/modules/operator$PyAttrGetter.class
Deleted: trunk/jython/Lib/Queue.py
===================================================================
--- trunk/jython/Lib/Queue.py 2008-08-19 15:07:48 UTC (rev 5205)
+++ trunk/jython/Lib/Queue.py 2008-08-19 21:06:39 UTC (rev 5206)
@@ -1,215 +0,0 @@
-"""A multi-producer, multi-consumer queue."""
-
-from time import time as _time
-from collections import deque
-
-__all__ = ['Empty', 'Full', 'Queue']
-
-class Empty(Exception):
- "Exception raised by Queue.get(block=0)/get_nowait()."
- pass
-
-class Full(Exception):
- "Exception raised by Queue.put(block=0)/put_nowait()."
- pass
-
-class Queue:
- """Create a queue object with a given maximum size.
-
- If maxsize is <= 0, the queue size is infinite.
- """
- def __init__(self, maxsize=0):
- try:
- import threading
- except ImportError:
- import dummy_threading as threading
- self._init(maxsize)
- # mutex must be held whenever the queue is mutating. All methods
- # that acquire mutex must release it before returning. mutex
- # is shared between the two conditions, so acquiring and
- # releasing the conditions also acquires and releases mutex.
- self.mutex = threading.Lock()
- # Notify not_empty whenever an item is added to the queue; a
- # thread waiting to get is notified then.
- self.not_empty = threading.Condition(self.mutex)
- # Notify not_full whenever an item is removed from the queue;
- # a thread waiting to put is notified then.
- self.not_full = threading.Condition(self.mutex)
- # Notify all_tasks_done whenever the number of unfinished tasks
- # drops to zero; thread waiting to join() is notified to resume
- self.all_tasks_done = threading.Condition(self.mutex)
- self.unfinished_tasks = 0
-
- def task_done(self):
- """Indicate that a formerly enqueued task is complete.
-
- Used by Queue consumer threads. For each get() used to fetch a task,
- a subsequent call to task_done() tells the queue that the processing
- on the task is complete.
-
- If a join() is currently blocking, it will resume when all items
- have been processed (meaning that a task_done() call was received
- for every item that had been put() into the queue).
-
- Raises a ValueError if called more times than there were items
- placed in the queue.
- """
- self.all_tasks_done.acquire()
- try:
- unfinished = self.unfinished_tasks - 1
- if unfinished <= 0:
- if unfinished < 0:
- raise ValueError('task_done() called too many times')
- self.all_tasks_done.notifyAll()
- self.unfinished_tasks = unfinished
- finally:
- self.all_tasks_done.release()
-
- def join(self):
- """Blocks until all items in the Queue have been gotten and processed.
-
- The count of unfinished tasks goes up whenever an item is added to the
- queue. The count goes down whenever a consumer thread calls task_done()
- to indicate the item was retrieved and all work on it is complete.
-
- When the count of unfinished tasks drops to zero, join() unblocks.
- """
- self.all_tasks_done.acquire()
- try:
- while self.unfinished_tasks:
- self.all_tasks_done.wait()
- finally:
- self.all_tasks_done.release()
-
- def qsize(self):
- """Return the approximate size of the queue (not reliable!)."""
- self.mutex.acquire()
- n = self._qsize()
- self.mutex.release()
- return n
-
- def empty(self):
- """Return True if the queue is empty, False otherwise (not reliable!)."""
- self.mutex.acquire()
- n = self._empty()
- self.mutex.release()
- return n
-
- def full(self):
- """Return True if the queue is full, False otherwise (not reliable!)."""
- self.mutex.acquire()
- n = self._full()
- self.mutex.release()
- return n
-
- def put(self, item, block=True, timeout=None):
- """Put an item into the queue.
-
- If optional args 'block' is true and 'timeout' is None (the default),
- block if necessary until a free slot is available. If 'timeout' is
- a positive number, it blocks at most 'timeout' seconds and raises
- the Full exception if no free slot was available within that time.
- Otherwise ('block' is false), put an item on the queue if a free slot
- is immediately available, else raise the Full exception ('timeout'
- is ignored in that case).
- """
- self.not_full.acquire()
- try:
- if not block:
- if self._full():
- raise Full
- elif timeout is None:
- while self._full():
- self.not_full.wait()
- else:
- if timeout < 0:
- raise ValueError("'timeout' must be a positive number")
- endtime = _time() + timeout
- while self._full():
- remaining = endtime - _time()
- if remaining <= 0.0:
- raise Full
- self.not_full.wait(remaining)
- self._put(item)
- self.unfinished_tasks += 1
- self.not_empty.notify()
- finally:
- self.not_full.release()
-
- def put_nowait(self, item):
- """Put an item into the queue without blocking.
-
- Only enqueue the item if a free slot is immediately available.
- Otherwise raise the Full exception.
- """
- return self.put(item, False)
-
- def get(self, block=True, timeout=None):
- """Remove and return an item from the queue.
-
- If optional args 'block' is true and 'timeout' is None (the default),
- block if necessary until an item is available. If 'timeout' is
- a positive number, it blocks at most 'timeout' seconds and raises
- the Empty exception if no item was available within that time.
- Otherwise ('block' is false), return an item if one is immediately
- available, else raise the Empty exception ('timeout' is ignored
- in that case).
- """
- self.not_empty.acquire()
- try:
- if not block:
- if self._empty():
- raise Empty
- elif timeout is None:
- while self._empty():
- self.not_empty.wait()
- else:
- if timeout < 0:
- raise ValueError("'timeout' must be a positive number")
- endtime = _time() + timeout
- while self._empty():
- remaining = endtime - _time()
- if remaining <= 0.0:
- raise Empty
- self.not_empty.wait(remaining)
- item = self._get()
- self.not_full.notify()
- return item
- finally:
- self.not_empty.release()
-
- def get_nowait(self):
- """Remove and return an item from the queue without blocking.
-
- Only get an item if one is immediately available. Otherwise
- raise the Empty exception.
- """
- return self.get(False)
-
- # Override these methods to implement other queue organizations
- # (e.g. stack or priority queue).
- # These will only be called with appropriate locks held
-
- # Initialize the queue representation
- def _init(self, maxsize):
- self.maxsize = maxsize
- self.queue = deque()
-
- def _qsize(self):
- return len(self.queue)
-
- # Check whether the queue is empty
- def _empty(self):
- return not self.queue
-
- # Check whether the queue is full
- def _full(self):
- return self.maxsize > 0 and len(self.queue) == self.maxsize
-
- # Put a new item in the queue
- def _put(self, item):
- self.queue.append(item)
-
- # Get an item from the queue
- def _get(self):
- return self.queue.popleft()
Deleted: trunk/jython/Lib/UserList.py
===================================================================
--- trunk/jython/Lib/UserList.py 2008-08-19 15:07:48 UTC (rev 5205)
+++ trunk/jython/Lib/UserList.py 2008-08-19 21:06:39 UTC (rev 5206)
@@ -1,94 +0,0 @@
-"""A more or less complete user-defined wrapper around list objects."""
-
-#Imported from Python 2.3.5 and added _fixindex
-class UserList:
- def __init__(self, initlist=None):
- self.data = []
- if initlist is not None:
- # XXX should this accept an arbitrary sequence?
- if type(initlist) == type(self.data):
- self.data[:] = initlist
- elif isinstance(initlist, UserList):
- self.data[:] = initlist.data[:]
- else:
- self.data = list(initlist)
- def __repr__(self): return repr(self.data)
- def __lt__(self, other): return self.data < self.__cast(other)
- def __le__(self, other): return self.data <= self.__cast(other)
- def __eq__(self, other): return self.data == self.__cast(other)
- def __ne__(self, other): return self.data != self.__cast(other)
- def __gt__(self, other): return self.data > self.__cast(other)
- def __ge__(self, other): return self.data >= self.__cast(other)
- def __cast(self, other):
- if isinstance(other, UserList): return other.data
- else: return other
- def __cmp__(self, other):
- return cmp(self.data, self.__cast(other))
- def __contains__(self, item): return item in self.data
- def __len__(self): return len(self.data)
- def __getitem__(self, i): return self.data[i]
- def __setitem__(self, i, item): self.data[i] = item
- def __delitem__(self, i): del self.data[i]
- def __getslice__(self, i, j):
- i = self._fixindex(i); j = self._fixindex(j)
- return self.__class__(self.data[i:j])
- def __setslice__(self, i, j, other):
- i = self._fixindex(i); j = self._fixindex(j)
- if isinstance(other, UserList):
- self.data[i:j] = other.data
- elif isinstance(other, type(self.data)):
- self.data[i:j] = other
- else:
- self.data[i:j] = list(other)
- def __delslice__(self, i, j):
- i = self._fixindex(i); j = self._fixindex(j)
- del self.data[i:j]
- def __add__(self, other):
- if isinstance(other, UserList):
- return self.__class__(self.data + other.data)
- elif isinstance(other, type(self.data)):
- return self.__class__(self.data + other)
- else:
- return self.__class__(self.data + list(other))
- def __radd__(self, other):
- if isinstance(other, UserList):
- return self.__class__(other.data + self.data)
- elif isinstance(other, type(self.data)):
- return self.__class__(other + self.data)
- else:
- return self.__class__(list(other) + self.data)
- def __iadd__(self, other):
- if isinstance(other, UserList):
- self.data += other.data
- elif isinstance(other, type(self.data)):
- self.data += other
- else:
- self.data += list(other)
- return self
- def __mul__(self, n):
- return self.__class__(self.data*n)
- __rmul__ = __mul__
- def __imul__(self, n):
- self.data *= n
- return self
- def append(self, item): self.data.append(item)
- def insert(self, i, item): self.data.insert(i, item)
- def pop(self, i=-1): return self.data.pop(i)
- def remove(self, item): self.data.remove(item)
- def count(self, item): return self.data.count(item)
- def index(self, item, *args): return self.data.index(item, *args)
- def reverse(self): self.data.reverse()
- def sort(self, *args): self.data.sort(*args)
- def extend(self, other):
- if isinstance(other, UserList):
- self.data.extend(other.data)
- else:
- self.data.extend(other)
- def _fixindex(self, index):
- if index < 0:
- index += len(self.data)
- elif index > len(self.data):
- index = len(self.data)
- index = max(index, 0)
- return index
-
Deleted: trunk/jython/Lib/UserString.py
===================================================================
--- trunk/jython/Lib/UserString.py 2008-08-19 15:07:48 UTC (rev 5205)
+++ trunk/jython/Lib/UserString.py 2008-08-19 21:06:39 UTC (rev 5206)
@@ -1,194 +0,0 @@
-#!/usr/bin/env python
-## vim:ts=4:et:nowrap
-"""A user-defined wrapper around string objects
-
-Note: string objects have grown methods in Python 1.6
-This module requires Python 1.6 or later.
-"""
-import sys
-
-__all__ = ["UserString","MutableString"]
-
-class UserString:
- def __init__(self, seq):
- if isinstance(seq, basestring):
- self.data = seq
- elif isinstance(seq, UserString):
- self.data = seq.data[:]
- else:
- self.data = str(seq)
- def __str__(self): return str(self.data)
- def __repr__(self): return repr(self.data)
- def __int__(self): return int(self.data)
- def __long__(self): return long(self.data)
- def __float__(self): return float(self.data)
- def __complex__(self): return complex(self.data)
- def __hash__(self): return hash(self.data)
-
- def __cmp__(self, string):
- if isinstance(string, UserString):
- return cmp(self.data, string.data)
- else:
- return cmp(self.data, string)
- def __contains__(self, char):
- return char in self.data
-
- def __len__(self): return len(self.data)
- def __getitem__(self, index): return self.__class__(self.data[index])
- def __getslice__(self, start, end):
- start = max(start, 0); end = max(end, 0)
- return self.__class__(self.data[start:end])
-
- def __add__(self, other):
- if isinstance(other, UserString):
- return self.__class__(self.data + other.data)
- elif isinstance(other, basestring):
- return self.__class__(self.data + other)
- else:
- return self.__class__(self.data + str(other))
- def __radd__(self, other):
- if isinstance(other, basestring):
- return self.__class__(other + self.data)
- else:
- return self.__class__(str(other) + self.data)
- def __mul__(self, n):
- return self.__class__(self.data*n)
- __rmul__ = __mul__
- def __mod__(self, args):
- return self.__class__(self.data % args)
-
- # the following methods are defined in alphabetical order:
- def capitalize(self): return self.__class__(self.data.capitalize())
- def center(self, width, *args):
- return self.__class__(self.data.center(width, *args))
- def count(self, sub, start=0, end=sys.maxint):
- return self.data.count(sub, start, end)
- def decode(self, encoding=None, errors=None): # XXX improve this?
- if encoding:
- if errors:
- return self.__class__(self.data.decode(encoding, errors))
- else:
- return self.__class__(self.data.decode(encoding))
- else:
- return self.__class__(self.data.decode())
- def encode(self, encoding=None, errors=None): # XXX improve this?
- if encoding:
- if errors:
- return self.__class__(self.data.encode(encoding, errors))
- else:
- return self.__class__(self.data.encode(encoding))
- else:
- return self.__class__(self.data.encode())
- def endswith(self, suffix, start=0, end=sys.maxint):
- return self.data.endswith(suffix, start, end)
- def expandtabs(self, tabsize=8):
- return self.__class__(self.data.expandtabs(tabsize))
- def find(self, sub, start=0, end=sys.maxint):
- return self.data.find(sub, start, end)
- def index(self, sub, start=0, end=sys.maxint):
- return self.data.index(sub, start, end)
- def isalpha(self): return self.data.isalpha()
- def isalnum(self): return self.data.isalnum()
- def isdecimal(self): return self.data.isdecimal()
- def isdigit(self): return self.data.isdigit()
- def islower(self): return self.data.islower()
- def isnumeric(self): return self.data.isnumeric()
- def isspace(self): return self.data.isspace()
- def istitle(self): return self.data.istitle()
- def isupper(self): return self.data.isupper()
- def join(self, seq): return self.data.join(seq)
- def ljust(self, width, *args):
- return self.__class__(self.data.ljust(width, *args))
- def lower(self): return self.__class__(self.data.lower())
- def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars))
- def partition(self, sep):
- return self.data.partition(sep)
- def replace(self, old, new, maxsplit=-1):
- return self.__class__(self.data.replace(old, new, maxsplit))
- def rfind(self, sub, start=0, end=sys.maxint):
- return self.data.rfind(sub, start, end)
- def rindex(self, sub, start=0, end=sys.maxint):
- return self.data.rindex(sub, start, end)
- def rjust(self, width, *args):
- return self.__class__(self.data.rjust(width, *args))
- def rpartition(self, sep):
- return self.data.rpartition(sep)
- def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars))
- def split(self, sep=None, maxsplit=-1):
- return self.data.split(sep, maxsplit)
- def rsplit(self, sep=None, maxsplit=-1):
- return self.data.rsplit(sep, maxsplit)
- def splitlines(self, keepends=0): return self.data.splitlines(keepends)
- def startswith(self, prefix, start=0, end=sys.maxint):
- return self.data.startswith(prefix, start, end)
- def strip(self, chars=None): return self.__class__(self.data.strip(chars))
- def swapcase(self): return self.__class__(self.data.swapcase())
- def title(self): return self.__class__(self.data.title())
- def translate(self, *args):
- return self.__class__(self.data.translate(*args))
- def upper(self): return self.__class__(self.data.upper())
- def zfill(self, width): return self.__class__(self.data.zfill(width))
-
-class MutableString(UserString):
- """mutable string objects
-
- Python strings are immutable objects. This has the advantage, that
- strings may be used as dictionary keys. If this property isn't needed
- and you insist on changing string values in place instead, you may cheat
- and use MutableString.
-
- But the purpose of this class is an educational one: to prevent
- people from inventing their own mutable string class derived
- from UserString and than forget thereby to remove (override) the
- __hash__ method inherited from UserString. This would lead to
- errors that would be very hard to track down.
-
- A faster and better solution is to rewrite your program using lists."""
- def __init__(self, string=""):
- self.data = string
- def __hash__(self):
- raise TypeError, "unhashable type (it is mutable)"
- def __setitem__(self, index, sub):
- if index < 0:
- index += len(self.data)
- if index < 0 or index >= len(self.data): raise IndexError
- self.data = self.data[:index] + sub + self.data[index+1:]
- def __delitem__(self, index):
- if index < 0:
- index += len(self.data)
- if index < 0 or index >= len(self.data): raise IndexError
- self.data = self.data[:index] + self.data[index+1:]
- def __setslice__(self, start, end, sub):
- start = max(start, 0); end = max(end, 0)
- if isinstance(sub, UserString):
- self.data = self.data[:start]+sub.data+self.data[end:]
- elif isinstance(sub, basestring):
- self.data = self.data[:start]+sub+self.data[end:]
- else:
- self.data = self.data[:start]+str(sub)+self.data[end:]
- def __delslice__(self, start, end):
- start = max(start, 0); end = max(end, 0)
- self.data = self.data[:start] + self.data[end:]
- def immutable(self):
- return UserString(self.data)
- def __iadd__(self, other):
- if isinstance(other, UserString):
- self.data += other.data
- elif isinstance(other, basestring):
- self.data += other
- else:
- self.data += str(other)
- return self
- def __imul__(self, n):
- self.data *= n
- return self
-
-if __name__ == "__main__":
- # execute the regression test to stdout, if called as a script:
- import os
- called_in_dir, called_as = os.path.split(sys.argv[0])
- called_as, py = os.path.splitext(called_as)
- if '-q' in sys.argv:
- from test import test_support
- test_support.verbose = 0
- __import__('test.test_' + called_as.lower())
Copied: trunk/jython/Lib/_rawffi.py (from rev 4897, branches/asm/Lib/_rawffi.py)
===================================================================
--- trunk/jython/Lib/_rawffi.py (rev 0)
+++ trunk/jython/Lib/_rawffi.py 2008-08-19 21:06:39 UTC (rev 5206)
@@ -0,0 +1,57 @@
+import com.sun.jna as jna
+
+def get_libc():
+ return CDLL("c")
+
+typecode_map = {'h': 2, 'H': 2}
+
+class Array(object):
+ def __init__(self, typecode):
+ self.typecode = typecode
+ self.itemsize = typecode_map[typecode]
+
+ def __call__(self, size, autofree=False):
+ if not autofree:
+ raise Exception
+ return ArrayInstance(self, size)
+
+class ArrayInstance(object):
+ def __init__(self, shape, size):
+ self.shape = shape
+ self.alloc = jna.Memory(shape.itemsize * size)
+
+ def __setitem__(self, index, value):
+ self.alloc.setShort(index, value)
+
+ def __getitem__(self, index):
+ return self.alloc.getShort(index)
+
+class FuncPtr(object):
+ def __init__(self, fn, name, argtypes, restype):
+ self.fn = fn
+ self.name = name
+ self.argtypes = argtypes
+ self.restype = restype
+
+ def __call__(self, *args):
+ container = Array('H')(1, autofree=True)
+ container[0] = self.fn.invokeInt([i[0] for i in args])
+ return container
+
+class CDLL(object):
+ def __init__(self, libname):
+ self.lib = jna.NativeLibrary.getInstance(libname)
+ self.cache = dict()
+
+ def ptr(self, name, argtypes, restype):
+ key = (name, tuple(argtypes), restype)
+ try:
+ return self.cache[key]
+ except KeyError:
+ fn = self.lib.getFunction(name)
+ fnp = FuncPtr(fn, name, argtypes, restype)
+ self.cache[key] = fnp
+ return fnp
+
+
+
Modified: trunk/jython/Lib/codeop.py
===================================================================
--- trunk/jython/Lib/codeop.py 2008-08-19 15:07:48 UTC (rev 5205)
+++ trunk/jython/Lib/codeop.py 2008-08-19 21:06:39 UTC (rev 5206)
@@ -58,6 +58,7 @@
# import internals, not guaranteed interface
from org.python.core import Py,CompilerFlags
+from org.python.core.PyTableCode import PyCF_DONT_IMPLY_DEDENT
# public interface
Deleted: trunk/jython/Lib/copy.py
===================================================================
--- trunk/jython/Lib/copy.py 2008-08-19 15:07:48 UTC (rev 5205)
+++ trunk/jython/Lib/copy.py 2008-08-19 21:06:39 UTC (rev 5206)
@@ -1,413 +0,0 @@
-"""Generic (shallow and deep) copying operations.
-
-Interface summary:
-
- import copy
-
- x = copy.copy(y) # make a shallow copy of y
- x = copy.deepcopy(y) # make a deep copy of y
-
-For module specific errors, copy.Error is raised.
-
-The difference between shallow and deep copying is only relevant for
-compound objects (objects that contain other objects, like lists or
-class instances).
-
-- A shallow copy constructs a new compound object and then (to the
- extent possible) inserts *the same objects* into it that the
- original contains.
-
-- A deep copy constructs a new compound object and then, recursively,
- inserts *copies* into it of the objects found in the original.
-
-Two problems often exist with deep copy operations that don't exist
-with shallow copy operations:
-
- a) recursive objects (compound objects that, directly or indirectly,
- contain a reference to themselves) may cause a recursive loop
-
- b) because deep copy copies *everything* it may copy too much, e.g.
- administrative data structures that should be shared even between
- copies
-
-Python's deep copy operation avoids these problems by:
-
- a) keeping a table of objects already copied during the current
- copying pass
-
- b) letting user-defined classes override the copying operation or the
- set of components copied
-
-This version does not copy types like module, class, function, method,
-nor stack trace, stack frame, nor file, socket, window, nor array, nor
-any similar types.
-
-Classes can use the same interfaces to control copying that they use
-to control pickling: they can define methods called __getinitargs__(),
-__getstate__() and __setstate__(). See the documentation for module
-"pickle" for information on these methods.
-"""
-
-import types
-from copy_reg import dispatch_table
-
-class Error(Exception):
- pass
-error = Error # backward compatibility
-
-try:
- from org.python.core import PyStringMap
-except ImportError:
- PyStringMap = None
-
-__all__ = ["Error", "copy", "deepcopy"]
-
-def copy(x):
- """Shallow copy operation on arbitrary Python objects.
-
- See the module's __doc__ string for more info.
- """
-
- cls = type(x)
-
- copier = _copy_dispatch.get(cls)
- if copier:
- return copier(x)
-
- copier = getattr(cls, "__copy__", None)
- if copier:
- return copier(x)
-
- reductor = dispatch_table.get(cls)
- if reductor:
- rv = reductor(x)
- else:
- reductor = getattr(x, "__reduce_ex__", None)
- if reductor:
- rv = reductor(2)
- else:
- reductor = getattr(x, "__reduce__", None)
- if reductor:
- rv = reductor()
- else:
- raise Error("un(shallow)copyable object of type %s" % cls)
-
- return _reconstruct(x, rv, 0)
-
-
-_copy_dispatch = d = {}
-
-def _copy_immutable(x):
- return x
-for t in (type(None), int, long, float, bool, str, tuple,
- frozenset, type, xrange, types.ClassType,
- types.BuiltinFunctionType,
- types.FunctionType):
- d[t] = _copy_immutable
-for name in ("ComplexType", "UnicodeType", "CodeType"):
- t = getattr(types, name, None)
- if t is not None:
- d[t] = _copy_immutable
-
-def _copy_with_constructor(x):
- return type(x)(x)
-for t in (list, dict, set):
- d[t] = _copy_with_constructor
-
-def _copy_with_copy_method(x):
- return x.copy()
-if PyStringMap is not None:
- d[PyStringMap] = _copy_with_copy_method
-
-def _copy_inst(x):
- if hasattr(x, '__copy__'):
- return x.__copy__()
- if hasattr(x, '__getinitargs__'):
- args = x.__getinitargs__()
- y = x.__class__(*args)
- else:
- y = _EmptyClass()
- y.__class__ = x.__class__
- if hasattr(x, '__getstate__'):
- state = x.__getstate__()
- else:
- state = x.__dict__
- if hasattr(y, '__setstate__'):
- y.__setstate__(state)
- else:
- y.__dict__.update(state)
- return y
-d[types.InstanceType] = _copy_inst
-
-del d
-
-def deepcopy(x, memo=None, _nil=[]):
- """Deep copy operation on arbitrary Python objects.
-
- See the module's __doc__ string for more info.
- """
- if memo is None:
- memo = {}
-
- d = id(x)
- y = memo.get(d, _nil)
- if y is not _nil:
- return y
-
- cls = type(x)
-
- copier = _deepcopy_dispatch.get(cls)
- if copier:
- y = copier(x, memo)
- else:
- try:
- issc = issubclass(cls, type)
- except TypeError: # cls is not a class (old Boost; see SF #502085)
- issc = 0
- if issc:
- y = _deepcopy_atomic(x, memo)
- else:
- copier = getattr(x, "__deepcopy__", None)
- if copier:
- y = copier(memo)
- else:
- reductor = dispatch_table.get(cls)
- if reductor:
- rv = reductor(x)
- else:
- reductor = getattr(x, "__reduce_ex__", None)
- if reductor:
- rv = reductor(2)
- else:
- reductor = getattr(x, "__reduce__", None)
- if reductor:
- rv = reductor()
- else:
- raise Error(
- "un(deep)copyable object of type %s" % cls)
- y = _reconstruct(x, rv, 1, memo)
-
- memo[d] = y
- _keep_alive(x, memo) # Make sure x lives at least as long as d
- return y
-
-_deepcopy_dispatch = d = {}
-
-def _deepcopy_atomic(x, memo):
- return x
-d[type(None)] = _deepcopy_atomic
-d[int] = _deepcopy_atomic
-d[long] = _deepcopy_atomic
-d[float] = _deepcopy_atomic
-d[bool] = _deepcopy_atomic
-try:
- d[complex] = _deepcopy_atomic
-except NameError:
- pass
-d[str] = _deepcopy_atomic
-try:
- d[unicode] = _deepcopy_atomic
-except NameError:
- pass
-try:
- d[types.CodeType] = _deepcopy_atomic
-except AttributeError:
- pass
-d[type] = _deepcopy_atomic
-d[xrange] = _deepcopy_atomic
-d[types.ClassType] = _deepcopy_atomic
-d[types.BuiltinFunctionType] = _deepcopy_atomic
-d[types.FunctionType] = _deepcopy_atomic
-
-def _deepcopy_list(x, memo):
- y = []
- memo[id(x)] = y
- for a in x:
- y.append(deepcopy(a, memo))
- return y
-d[list] = _deepcopy_list
-
-def _deepcopy_tuple(x, memo):
- y = []
- for a in x:
- y.append(deepcopy(a, memo))
- d = id(x)
- try:
- return memo[d]
- except KeyError:
- pass
- for i in range(len(x)):
- if x[i] is not y[i]:
- y = tuple(y)
- break
- else:
- y = x
- memo[d] = y
- return y
-d[tuple] = _deepcopy_tuple
-
-def _deepcopy_dict(x, memo):
- y = {}
- memo[id(x)] = y
- for key, value in x.iteritems():
- y[deepcopy(key, memo)] = deepcopy(value, memo)
- return y
-d[dict] = _deepcopy_dict
-if PyStringMap is not None:
- d[PyStringMap] = _deepcopy_dict
-
-def _keep_alive(x, memo):
- """Keeps a reference to the object x in the memo.
-
- Because we remember objects by their id, we have
- to assure that possibly temporary objects are kept
- alive by referencing them.
- We store a reference at the id of the memo, which should
- normally not be used unless someone tries to deepcopy
- the memo itself...
- """
- try:
- memo[id(memo)].append(x)
- except KeyError:
- # aha, this is the first one :-)
- memo[id(memo)]=[x]
-
-def _deepcopy_inst(x, memo):
- if hasattr(x, '__deepcopy__'):
- return x.__deepcopy__(memo)
- if hasattr(x, '__getinitargs__'):
- args = x.__getinitargs__()
- args = deepcopy(args, memo)
- y = x.__class__(*args)
- else:
- y = _EmptyClass()
- y.__class__ = x.__class__
- memo[id(x)] = y
- if hasattr(x, '__getstate__'):
- state = x.__getstate__()
- else:
- state = x.__dict__
- state = deepcopy(state, memo)
- if hasattr(y, '__setstate__'):
- y.__setstate__(state)
- else:
- y.__dict__.update(state)
- return y
-d[types.InstanceType] = _deepcopy_inst
-
-def _reconstruct(x, info, deep, memo=None):
- if isinstance(info, str):
- return x
- assert isinstance(info, tuple)
- if memo is None:
- memo = {}
- n = len(info)
- assert n in (2, 3, 4, 5)
- callable, args = info[:2]
- if n > 2:
- state = info[2]
- else:
- state = {}
- if n > 3:
- listiter = info[3]
- else:
- listiter = None
- if n > 4:
- dictiter = info[4]
- else:
- dictiter = None
- if deep:
- args = deepcopy(args, memo)
- y = callable(*args)
- memo[id(x)] = y
- if listiter is not None:
- for item in listiter:
- if deep:
- item = deepcopy(item, memo)
- y.append(item)
- if dictiter is not None:
- for key, value in dictiter:
- if deep:
- key = deepcopy(key, memo)
- value = deepcopy(value, memo)
- y[key] = value
- if state:
- if deep:
- state = deepcopy(state, memo)
- if hasattr(y, '__setstate__'):
- y.__setstate__(state)
- else:
- if isinstance(state, tuple) and len(state) == 2:
- state, slotstate = state
- else:
- slotstate = None
- if state is not None:
- y.__dict__.update(state)
- if slotstate is not None:
- for key, value in slotstate.iteritems():
- setattr(y, key, value)
- return y
-
-del d
-
-del types
-
-# Helper for instance creation without calling __init__
-class _EmptyClass:
- pass
-
-def _test():
- l = [None, 1, 2L, 3.14, 'xyzzy', (1, 2L), [3.14, 'abc'],
- {'abc': 'ABC'}, (), [], {}]
- l1 = copy(l)
- print l1==l
- l1 = map(copy, l)
- print l1==l
- l1 = deepcopy(l)
- print l1==l
- class C:
- def __init__(self, arg=None):
- self.a = 1
- self.arg = arg
- if __name__ == '__main__':
- import sys
- file = sys.argv[0]
- else:
- file = __file__
- self.fp = open(file)
- self.fp.close()
- def __getstate__(self):
- return {'a': self.a, 'arg': self.arg}
- def __setstate__(self, state):
- for key, value in state.iteritems():
- setattr(self, key, value)
- def __deepcopy__(self, memo=None):
- new = self.__class__(deepcopy(self.arg, memo))
- new.a = self.a
- return new
- c = C('argument sketch')
- l.append(c)
- l2 = copy(l)
- print l == l2
- print l
- print l2
- l2 = deepcopy(l)
- print l == l2
- print l
- print l2
- l.append({l[1]: l, 'xyz': l[2]})
- l3 = copy(l)
- import repr
- print map(repr.repr, l)
- print map(repr.repr, l1)
- print map(repr.repr, l2)
- print map(repr.repr, l3)
- l3 = deepcopy(l)
- import repr
- print map(repr.repr, l)
- print map(repr.repr, l1)
- print map(repr.repr, l2)
- print map(repr.repr, l3)
-
-if __name__ == '__main__':
- _test()
Modified: trunk/jython/Lib/datetime.py
===================================================================
--- trunk/jython/Lib/datetime.py 2008-08-19 15:07:48 UTC (rev 5205)
+++ trunk/jython/Lib/datetime.py 2008-08-19 21:06:39 UTC (rev 5206)
@@ -12,6 +12,8 @@
Sources for time zone and DST data: http://www.twinsun.com/tz/tz-link.htm
+This was originally copied from the sandbox of the CPython CVS repository.
+Thanks to Tim Peters for suggesting using it.
"""
import time as _time
@@ -575,6 +577,8 @@
def __add__(self, other):
if isinstance(other, timedelta):
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
return timedelta(self.__days + other.__days,
self.__seconds + other.__seconds,
self.__microseconds + other.__microseconds)
@@ -593,9 +597,11 @@
return NotImplemented
def __neg__(self):
- return self.__class__(-self.__days,
- -self.__seconds,
- -self.__microseconds)
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
+ return timedelta(-self.__days,
+ -self.__seconds,
+ -self.__microseconds)
def __pos__(self):
return self
@@ -608,9 +614,11 @@
def __mul__(self, other):
if isinstance(other, (int, long)):
- return self.__class__(self.__days * other,
- self.__seconds * other,
- self.__microseconds * other)
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
+ return timedelta(self.__days * other,
+ self.__seconds * other,
+ self.__microseconds * other)
return NotImplemented
__rmul__ = __mul__
@@ -619,7 +627,7 @@
if isinstance(other, (int, long)):
usec = ((self.__days * (24*3600L) + self.__seconds) * 1000000 +
self.__microseconds)
- return self.__class__(0, 0, usec // other)
+ return timedelta(0, 0, usec // other)
return NotImplemented
__floordiv__ = __div__
@@ -728,7 +736,7 @@
if isinstance(year, str):
# Pickle support
self = object.__new__(cls)
- self.__setstate((year,))
+ self.__setstate(year)
return self
_check_date_fields(year, month, day)
self = object.__new__(cls)
@@ -901,9 +909,10 @@
self.__month,
self.__day + other.days)
self._checkOverflow(t.year)
- result = self.__class__(t.year, t.month, t.day)
+ result = date(t.year, t.month, t.day)
return result
- return NotImplemented
+ raise TypeError
+ # XXX Should be 'return NotImplemented', but there's a bug in 2.2...
__radd__ = __add__
@@ -963,16 +972,33 @@
yhi, ylo = divmod(self.__year, 256)
return ("%c%c%c%c" % (yhi, ylo, self.__month, self.__day), )
- def __setstate(self, t):
- assert isinstance(t, tuple) and len(t) == 1, `t`
- string = t[0]
- assert len(string) == 4
+ def __setstate(self, string):
+ if len(string) != 4 or not (1 <= ord(string[2]) <= 12):
+ raise TypeError("not enough arguments")
yhi, ylo, self.__month, self.__day = map(ord, string)
self.__year = yhi * 256 + ylo
def __reduce__(self):
return (self.__class__, self.__getstate())
+ def __tojava__(self, java_class):
+ from java.lang import Object
+ from java.sql import Date
+ from java.util import Calendar
+ from org.python.core import Py
+
+ if java_class not in (Calendar, Date, Object):
+ return Py.NoConversion
+
+ calendar = Calendar.getInstance()
+ calendar.clear()
+ calendar.set(self.year, self.month - 1, self.day)
+ if java_class == Calendar:
+ return calendar
+ else:
+ return Date(calendar.getTimeInMillis())
+
+
_date_class = date # so functions w/ args named "date" can get at the class
date.min = date(1, 1, 1)
@@ -1089,7 +1115,7 @@
self = object.__new__(cls)
if isinstance(hour, str):
# Pickle support
- self.__setstate((hour, minute or None))
+ self.__setstate(hour, minute or None)
return self
_check_tzinfo_arg(tzinfo)
_check_time_fields(hour, minute, second, microsecond)
@@ -1327,22 +1353,39 @@
else:
return (basestate, self._tzinfo)
- def __setstate(self, state):
- assert isinstance(state, tuple)
- assert 1 <= len(state) <= 2
- string = state[0]
- assert len(string) == 6
+ def __setstate(self, string, tzinfo):
+ if len(string) != 6 or ord(string[0]) >= 24:
+ raise TypeError("an integer is required")
self.__hour, self.__minute, self.__second, us1, us2, us3 = \
map(ord, string)
self.__microsecond = (((us1 << 8) | us2) << 8) | us3
- if len(state) == 1:
- self._tzinfo = None
- else:
- self._tzinfo = state[1]
+ self._tzinfo = tzinfo
def __reduce__(self):
- return (self.__class__, self.__getstate())
+ return (time, self.__getstate())
+ def __tojava__(self, java_class):
+ # TODO, if self.tzinfo is not None, convert time to UTC
+ from java.lang import Object
+ from java.sql import Time
+ from java.util import Calendar
+ from org.python.core import Py
+
+ if java_class not in (Calendar, Time, Object):
+ return Py.NoConversion
+
+ calendar = Calendar.getInstance()
+ calendar.clear()
+ calendar.set(Calendar.HOUR_OF_DAY, self.hour)
+ calendar.set(Calendar.MINUTE, self.minute)
+ calendar.set(Calendar.SECOND, self.second)
+ calendar.set(Calendar.MILLISECOND, self.microsecond // 1000)
+ if java_class == Calendar:
+ return calendar
+ else:
+ return Time(calendar.getTimeInMillis())
+
+
_time_class = time # so functions w/ args named "time" can get at the class
time.min = time(0, 0, 0)
@@ -1359,7 +1402,7 @@
if isinstance(year, str):
# Pickle support
self = date.__new__(cls, year[:4])
- self.__setstate((year, month))
+ self.__setstate(year, month)
return self
_check_tzinfo_arg(tzinfo)
_check_time_fields(hour, minute, second, microsecond)
@@ -1396,8 +1439,17 @@
converter = _time.gmtime
y, m, d, hh, mm, ss, weekday, jday, dst = converter(t)
us = int((t % 1.0) * 1000000)
+
+ if us == 1000001 or us == 999999:
+ us = 0
+ rounded = True
+ else:
+ rounded = False
+
ss = min(ss, 59) # clamp out leap seconds if the platform has them
result = cls(y, m, d, hh, mm, ss, us, tz)
+ if rounded:
+ result += timedelta(seconds=1)
if tz is not None:
result = tz.fromutc(result)
return result
@@ -1439,6 +1491,15 @@
time.tzinfo)
combine = classmethod(combine)
+ def strptime(cls, date_string, format):
+ """datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
+
+ The year, month and day arguments are required. tzinfo may be None, or an
+ instance of a tzinfo subclass. The remaining arguments may be ints or longs."""
+ return cls(*(_time.strptime(date_string, format))[0:6])
+
+ strptime = classmethod(strptime)
+
def timetuple(self):
"Return local time tuple compatible with time.localtime()."
dst = self._dst()
@@ -1561,7 +1622,7 @@
if L[-1] == 0:
del L[-1]
if L[-1] == 0:
- del L[-1]
+ del L[-1]
s = ", ".join(map(str, L))
s = "%s(%s)" % ('datetime.' + self.__class__.__name__, s)
if self._tzinfo is not None:
@@ -1625,7 +1686,7 @@
def __eq__(self, other):
if isinstance(other, datetime):
return self.__cmp(other) == 0
- elif hasattr(other, "timetuple"):
+ elif hasattr(other, "timetuple") and not isinstance(other, date):
return NotImplemented
else:
return False
@@ -1633,7 +1694,7 @@
def __ne__(self, other):
if isinstance(other, datetime):
return self.__cmp(other) != 0
- elif hasattr(other, "timetuple"):
+ elif hasattr(other, "timetuple") and not isinstance(other, date):
return NotImplemented
else:
return True
@@ -1641,7 +1702,7 @@
def __le__(self, other):
if isinstance(other, datetime):
return self.__cmp(other) <= 0
- elif hasattr(other, "timetuple"):
+ elif hasattr(other, "timetuple") and not isinstance(other, date):
return NotImplemented
else:
_cmperror(self, other)
@@ -1649,7 +1710,7 @@
def __lt__(self, other):
if isinstance(other, datetime):
return self.__cmp(other) < 0
- elif hasattr(other, "timetuple"):
+ elif hasattr(other, "timetuple") and not isinstance(other, date):
return NotImplemented
else:
_cmperror(self, other)
@@ -1657,7 +1718,7 @@
def __ge__(self, other):
if isinstance(other, datetime):
return self.__cmp(other) >= 0
- elif hasattr(other, "timetuple"):
+ elif hasattr(other, "timetuple") and not isinstance(other, date):
return NotImplemented
else:
_cmperror(self, other)
@@ -1665,7 +1726,7 @@
def __gt__(self, other):
if isinstance(other, datetime):
return self.__cmp(other) > 0
- elif hasattr(other, "timetuple"):
+ elif hasattr(other, "timetuple") and not isinstance(other, date):
return NotImplemented
else:
_cmperror(self, other)
@@ -1713,7 +1774,7 @@
self.__second + other.seconds,
self.__microsecond + other.microseconds)
self._checkOverflow(t.year)
- result = self.__class__(t.year, t.month, t.day,
+ result = datetime(t.year, t.month, t.day,
t.hour, t.minute, t.second,
t.microsecond, tzinfo=self._tzinfo)
return result
@@ -1768,24 +1829,38 @@
else:
return (basestate, self._tzinfo)
- def __setstate(self, state):
- assert isinstance(state, tuple)
- assert 1 <= len(state) <= 2
- string = state[0]
- assert len(string) == 10
+ def __setstate(self, string, tzinfo):
(yhi, ylo, self.__month, self.__day, self.__hour,
self.__minute, self.__second, us1, us2, us3) = map(ord, string)
self.__year = yhi * 256 + ylo
self.__microsecond = (((us1 << 8) | us2) << 8) | us3
- if len(state) == 1:
- self._tzinfo = None
- else:
- self._tzinfo = state[1]
+ self._tzinfo = tzinfo
def __reduce__(self):
return (self.__class__, self.__getstate())
+ def __tojava__(self, java_class):
+ # TODO, if self.tzinfo is not None, convert time to UTC
+ from java.lang import Object
+ from java.sql import Timestamp
+ from java.util import Calendar
+ from org.python.core import Py
+ if java_class not in (Calendar, Timestamp, Object):
+ return Py.NoConversion
+
+ calendar = Calendar.getInstance()
+ calendar.clear()
+ calendar.set(self.year, self.month - 1, self.day,
+ self.hour, self.minute, self.second)
+ calendar.set(Calendar.MILLISECOND, self.microsecond // 1000)
+
+ if java_class == Calendar:
+ return calendar
+ else:
+ return Timestamp(calendar.getTimeInMillis())
+
+
datetime.min = datetime(1, 1, 1)
datetime.max = datetime(9999, 12, 31, 23, 59, 59, 999999)
datetime.resolution = timedelta(microseconds=1)
@@ -2000,9 +2075,3 @@
pretty bizarre, and a tzinfo subclass can override fromutc() if it is.
"""
-def _test():
- import test_datetime
- test_datetime.test_main()
-
-if __name__ == "__main__":
- _test()
Copied: trunk/jython/Lib/decimal.py (from rev 4961, branches/asm/Lib/decimal.py)
===================================================================
--- trunk/jython/Lib/decimal.py (rev 0)
+++ trunk/jython/Lib/decimal.py 2008-08-19 21:06:39 UTC (rev 5206)
@@ -0,0 +1,5173 @@
+# Copyright (c) 2004 Python Software Foundation.
+# All rights reserved.
+
+# Written by Eric Price <eprice at tjhsst.edu>
+# and Facundo Batista <facundo at taniquetil.com.ar>
+# and Raymond Hettinger <python at rcn.com>
+# and Aahz <aahz at pobox.com>
+# and Tim Peters
+
+# This module is currently Py2.3 compatible and should be kept that way
+# unless a major compelling advantage arises. IOW, 2.3 compatibility is
+# strongly preferred, but not guaranteed.
+
+# Also, this module should be kept in sync with the latest updates of
+# the IBM specification as it evolves. Those updates will be treated
+# as bug fixes (deviation from the spec is a compatibility, usability
+# bug) and will be backported. At this point the spec is stabilizing
+# and the updates are becoming fewer, smaller, and less significant.
+
+"""
+This is a Py2.3 implementation of decimal floating point arithmetic based on
+the General Decimal Arithmetic Specification:
+
+ www2.hursley.ibm.com/decimal/decarith.html
+
+and IEEE standard 854-1987:
+
+ http://www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html
+
+Decimal floating point has finite precision with arbitrarily large bounds.
+
+The purpose of this module is to support arithmetic using familiar
+"schoolhouse" rules and to avoid some of the tricky representation
+issues associated with binary floating point. The package is especially
+useful for financial applications or for contexts where users have
+expectations that are at odds with binary floating point (for instance,
+in binary floating point, 1.00 % 0.1 gives 0.09999999999999995 instead
+of the expected Decimal("0.00") returned by decimal floating point).
+
+Here are some examples of using the decimal module:
+
+>>> from decimal import *
+>>> setcontext(ExtendedContext)
+>>> Decimal(0)
+Decimal("0")
+>>> Decimal("1")
+Decimal("1")
+>>> Decimal("-.0123")
+Decimal("-0.0123")
+>>> Decimal(123456)
+Decimal("123456")
+>>> Decimal("123.45e12345678901234567890")
+Decimal("1.2345E+12345678901234567892")
+>>> Decimal("1.33") + Decimal("1.27")
+Decimal("2.60")
+>>> Decimal("12.34") + Decimal("3.87") - Decimal("18.41")
+Decimal("-2.20")
+>>> dig = Decimal(1)
+>>> print dig / Decimal(3)
+0.333333333
+>>> getcontext().prec = 18
+>>> print dig / Decimal(3)
+0.333333333333333333
+>>> print dig.sqrt()
+1
+>>> print Decimal(3).sqrt()
+1.73205080756887729
+>>> print Decimal(3) ** 123
+4.85192780976896427E+58
+>>> inf = Decimal(1) / Decimal(0)
+>>> print inf
+Infinity
+>>> neginf = Decimal(-1) / Decimal(0)
+>>> print neginf
+-Infinity
+>>> print neginf + inf
+NaN
+>>> print neginf * inf
+-Infinity
+>>> print dig / 0
+Infinity
+>>> getcontext().traps[DivisionByZero] = 1
+>>> print dig / 0
+Traceback (most recent call last):
+ ...
+ ...
+ ...
+DivisionByZero: x / 0
+>>> c = Context()
+>>> c.traps[InvalidOperation] = 0
+>>> print c.flags[InvalidOperation]
+0
+>>> c.divide(Decimal(0), Decimal(0))
+Decimal("NaN")
+>>> c.traps[InvalidOperation] = 1
+>>> print c.flags[InvalidOperation]
+1
+>>> c.flags[InvalidOperation] = 0
+>>> print c.flags[InvalidOperation]
+0
+>>> print c.divide(Decimal(0), Decimal(0))
+Traceback (most recent call last):
+ ...
+ ...
+ ...
+InvalidOperation: 0 / 0
+>>> print c.flags[InvalidOperation]
+1
+>>> c.flags[InvalidOperation] = 0
+>>> c.traps[InvalidOperation] = 0
+>>> print c.divide(Decimal(0), Decimal(0))
+NaN
+>>> print c.flags[InvalidOperation]
+1
+>>>
+"""
+
+__all__ = [
+ # Two major classes
+ 'Decimal', 'Context',
+
+ # Contexts
+ 'DefaultContext', 'BasicContext', 'ExtendedContext',
+
+ # Exceptions
+ 'DecimalException', 'Clamped', 'InvalidOperation', 'DivisionByZero',
+ 'Inexact', 'Rounded', 'Subnormal', 'Overflow', 'Underflow',
+
+ # Constants for use in setting up contexts
+ 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING',
+ 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', 'ROUND_05UP',
+
+ # Functions for manipulating contexts
+ 'setcontext', 'getcontext', 'localcontext'
+]
+
+import copy as _copy
+
+# Rounding
+ROUND_DOWN = 'ROUND_DOWN'
+ROUND_HALF_UP = 'ROUND_HALF_UP'
+ROUND_HALF_EVEN = 'ROUND_HALF_EVEN'
+ROUND_CEILING = 'ROUND_CEILING'
+ROUND_FLOOR = 'ROUND_FLOOR'
+ROUND_UP = 'ROUND_UP'
+ROUND_HALF_DOWN = 'ROUND_HALF_DOWN'
+ROUND_05UP = 'ROUND_05UP'
+
+# Errors
+
+class DecimalException(ArithmeticError):
+ """Base exception class.
+
+ Used exceptions derive from this.
+ If an exception derives from another exception besides this (such as
+ Underflow (Inexact, Rounded, Subnormal) that indicates that it is only
+ called if the others are present. This isn't actually used for
+ anything, though.
+
+ handle -- Called when context._raise_error is called and the
+ trap_enabler is set. First argument is self, second is the
+ context. More arguments can be given, those being after
+ the explanation in _raise_error (For example,
+ context._raise_error(NewError, '(-x)!', self._sign) would
+ call NewError().handle(context, self._sign).)
+
+ To define a new exception, it should be sufficient to have it derive
+ from DecimalException.
+ """
+ def handle(self, context, *args):
+ pass
+
+
+class Clamped(DecimalException):
+ """Exponent of a 0 changed to fit bounds.
+
+ This occurs and signals clamped if the exponent of a result has been
+ altered in order to fit the constraints of a specific concrete
+ representation. This may occur when the exponent of a zero result would
+ be outside the bounds of a representation, or when a large normal
+ number would have an encoded exponent that cannot be represented. In
+ this latter case, the exponent is reduced to fit and the corresponding
+ number of zero digits are appended to the coefficient ("fold-down").
+ """
+
+class InvalidOperation(DecimalException):
+ """An invalid operation was performed.
+
+ Various bad things cause this:
+
+ Something creates a signaling NaN
+ -INF + INF
+ 0 * (+-)INF
+ (+-)INF / (+-)INF
+ x % 0
+ (+-)INF % x
+ x._rescale( non-integer )
+ sqrt(-x) , x > 0
+ 0 ** 0
+ x ** (non-integer)
+ x ** (+-)INF
+ An operand is invalid
+
+ The result of the operation after these is a quiet positive NaN,
+ except when the cause is a signaling NaN, in which case the result is
+ also a quiet NaN, but with the original sign, and an optional
+ diagnostic information.
+ """
+ def handle(self, context, *args):
+ if args:
+ ans = _dec_from_triple(args[0]._sign, args[0]._int, 'n', True)
+ return ans._fix_nan(context)
+ return NaN
+
+class ConversionSyntax(InvalidOperation):
+ """Trying to convert badly formed string.
+
+ This occurs and signals invalid-operation if an string is being
+ converted to a number and it does not conform to the numeric string
+ syntax. The result is [0,qNaN].
+ """
+ def handle(self, context, *args):
+ return NaN
+
+class DivisionByZero(DecimalException, ZeroDivisionError):
+ """Division by 0.
+
+ This occurs and signals division-by-zero if division of a finite number
+ by zero was attempted (during a divide-integer or divide operation, or a
+ power operation with negative right-hand operand), and the dividend was
+ not zero.
+
+ The result of the operation is [sign,inf], where sign is the exclusive
+ or of the signs of the operands for divide, or is 1 for an odd power of
+ -0, for power.
+ """
+
+ def handle(self, context, sign, *args):
+ return Infsign[sign]
+
+class DivisionImpossible(InvalidOperation):
+ """Cannot perform the division adequately.
+
+ This occurs and signals invalid-operation if the integer result of a
+ divide-integer or remainder operation had too many digits (would be
+ longer than precision). The result is [0,qNaN].
+ """
+
+ def handle(self, context, *args):
+ return NaN
+
+class DivisionUndefined(InvalidOperation, ZeroDivisionError):
+ """Undefined result of division.
+
+ This occurs and signals invalid-operation if division by zero was
+ attempted (during a divide-integer, divide, or remainder operation), and
+ the dividend is also zero. The result is [0,qNaN].
+ """
+
+ def handle(self, context, *args):
+ return NaN
+
+class Inexact(DecimalException):
+ """Had to round, losing information.
+
+ This occurs and signals inexact whenever the result of an operation is
+ not exact (that is, it needed to be rounded and any discarded digits
+ were non-zero), or if an overflow or underflow condition occurs. The
+ result in all cases is unchanged.
+
+ The inexact signal may be tested (or trapped) to determine if a given
+ operation (or sequence of operations) was inexact.
+ """
+
+class InvalidContext(InvalidOperation):
+ """Invalid context. Unknown rounding, for example.
+
+ This occurs and signals invalid-operation if an invalid context was
+ detected during an operation. This can occur if contexts are not checked
+ on creation and either the precision exceeds the capability of the
+ underlying concrete representation or an unknown or unsupported rounding
+ was specified. These aspects of the context need only be checked when
+ the values are required to be used. The result is [0,qNaN].
+ """
+
+ def handle(self, context, *args):
+ return NaN
+
+class Rounded(DecimalException):
+ """Number got rounded (not necessarily changed during rounding).
+
+ This occurs and signals rounded whenever the result of an operation is
+ rounded (that is, some zero or non-zero digits were discarded from the
+ coefficient), or if an overflow or underflow condition occurs. The
+ result in all cases is unchanged.
+
+ The rounded signal may be tested (or trapped) to determine if a given
+ operation (or sequence of operations) caused a loss of precision.
+ """
+
+class Subnormal(DecimalException):
+ """Exponent < Emin before rounding.
+
+ This occurs and signals subnormal whenever the result of a conversion or
+ operation is subnormal (that is, its adjusted exponent is less than
+ Emin, before any rounding). The result in all cases is unchanged.
+
+ The subnormal signal may be tested (or trapped) to determine if a given
+ or operation (or sequence of operations) yielded a subnormal result.
+ """
+
+class Overflow(Inexact, Rounded):
+ """Numerical overflow.
+
+ This occurs and signals overflow if the adjusted exponent of a result
+ (from a conversion or from an operation that is not an attempt to divide
+ by zero), after rounding, would be greater than the largest value that
+ can be handled by the implementation (the value Emax).
+
+ The result depends on the rounding mode:
+
+ For round-half-up and round-half-even (and for round-half-down and
+ round-up, if implemented), the result of the operation is [sign,inf],
+ where sign is the sign of the intermediate result. For round-down, the
+ result is the largest finite number that can be represented in the
+ current precision, with the sign of the intermediate result. For
+ round-ceiling, the result is the same as for round-down if the sign of
+ the intermediate result is 1, or is [0,inf] otherwise. For round-floor,
+ the result is the same as for round-down if the sign of the intermediate
+ result is 0, or is [1,inf] otherwise. In all cases, Inexact and Rounded
+ will also be raised.
+ """
+
+ def handle(self, context, sign, *args):
+ if context.rounding in (ROUND_HALF_UP, ROUND_HALF_EVEN,
+ ROUND_HALF_DOWN, ROUND_UP):
+ return Infsign[sign]
+ if sign == 0:
+ if context.rounding == ROUND_CEILING:
+ return Infsign[sign]
+ return _dec_from_triple(sign, '9'*context.prec,
+ context.Emax-context.prec+1)
+ if sign == 1:
+ if context.rounding == ROUND_FLOOR:
+ return Infsign[sign]
+ return _dec_from_triple(sign, '9'*context.prec,
+ context.Emax-context.prec+1)
+
+
+class Underflow(Inexact, Rounded, Subnormal):
+ """Numerical underflow with result rounded to 0.
+
+ This occurs and signals underflow if a result is inexact and the
+ adjusted exponent of the result would be smaller (more negative) than
+ the smallest value that can be handled by the implementation (the value
+ Emin). That is, the result is both inexact and subnormal.
+
+ The result after an underflow will be a subnormal number rounded, if
+ necessary, so that its exponent is not less than Etiny. This may result
+ in 0 with the sign of the intermediate result and an exponent of Etiny.
+
+ In all cases, Inexact, Rounded, and Subnormal will also be raised.
+ """
+
+# List of public traps and flags
+_signals = [Clamped, DivisionByZero, Inexact, Overflow, Rounded,
+ Underflow, InvalidOperation, Subnormal]
+
+# Map conditions (per the spec) to signals
+_condition_map = {ConversionSyntax:InvalidOperation,
+ DivisionImpossible:InvalidOperation,
+ DivisionUndefined:InvalidOperation,
+ InvalidContext:InvalidOperation}
+
+##### Context Functions ##################################################
+
+# The getcontext() and setcontext() function manage access to a thread-local
+# current context. Py2.4 offers direct support for thread locals. If that
+# is not available, use threading.currentThread() which is slower but will
+# work for older Pythons. If threads are not part of the build, create a
+# mock threading object with threading.local() returning the module namespace.
+
+try:
+ import threading
+except ImportError:
+ # Python was compiled without threads; create a mock object instead
+ import sys
+ class MockThreading(object):
+ def local(self, sys=sys):
+ return sys.modules[__name__]
+ threading = MockThreading()
+ del sys, MockThreading
+
+try:
+ threading.local
+
+except AttributeError:
+
+ # To fix reloading, force it to create a new context
+ # Old contexts have different exceptions in their dicts, making problems.
+ if hasattr(threading.currentThread(), '__decimal_context__'):
+ del threading.currentThread().__decimal_context__
+
+ def setcontext(context):
+ """Set this thread's context to context."""
+ if context in (DefaultContext, BasicContext, ExtendedContext):
+ context = context.copy()
+ context.clear_flags()
+ threading.currentThread().__decimal_context__ = context
+
+ def getcontext():
+ """Returns this thread's context.
+
+ If this thread does not yet have a context, returns
+ a new context and sets this thread's context.
+ New contexts are copies of DefaultContext.
+ """
+ try:
+ return threading.currentThread().__decimal_context__
+ except AttributeError:
+ context = Context()
+ threading.currentThread().__decimal_context__ = context
+ return context
+
+else:
+
+ local = threading.local()
+ if hasattr(local, '__decimal_context__'):
+ del local.__decimal_context__
+
+ def getcontext(_local=local):
+ """Returns this thread's context.
+
+ If this thread does not yet have a context, returns
+ a new context and sets this thread's context.
+ New contexts are copies of DefaultContext.
+ """
+ try:
+ return _local.__decimal_context__
+ except AttributeError:
+ context = Context()
+ _local.__decimal_context__ = context
+ return context
+
+ def setcontext(context, _local=local):
+ """Set this thread's context to context."""
+ if context in (DefaultContext, BasicContext, ExtendedContext):
+ context = context.copy()
+ context.clear_flags()
+ _local.__decimal_context__ = context
+
+ del threading, local # Don't contaminate the namespace
+
+def localcontext(ctx=None):
+ """Return a context manager for a copy of the supplied context
+
+ Uses a copy of the current context if no context is specified
+ The returned context manager creates a local decimal context
+ in a with statement:
+ def sin(x):
+ with localcontext() as ctx:
+ ctx.prec += 2
+ # Rest of sin calculation algorithm
+ # uses a precision 2 greater than normal
+ return +s # Convert result to normal precision
+
+ def sin(x):
+ with localcontext(ExtendedContext):
+ # Rest of sin calculation algorithm
+ # uses the Extended Context from the
+ # General Decimal Arithmetic Specification
+ return +s # Convert result to normal context
+
+ """
+ # The string below can't be included in the docstring until Python 2.6
+ # as the doctest module doesn't understand __future__ statements
+ """
+ >>> from __future__ import with_statement
+ >>> print getcontext().prec
+ 28
+ >>> with localcontext():
+ ... ctx = getcontext()
+ ... ctx.prec += 2
+ ... print ctx.prec
+ ...
+ 30
+ >>> with localcontext(ExtendedContext):
+ ... print getcontext().prec
+ ...
+ 9
+ >>> print getcontext().prec
+ 28
+ """
+ if ctx is None: ctx = getcontext()
+ return _ContextManager(ctx)
+
+
+##### Decimal class #######################################################
+
+class Decimal(object):
+ """Floating point class for decimal arithmetic."""
+
+ __slots__ = ('_exp','_int','_sign', '_is_special')
+ # Generally, the value of the Decimal instance is given by
+ # (-1)**_sign * _int * 10**_exp
+ # Special values are signified by _is_special == True
+
+ # We're immutable, so use __new__ not __init__
+ def __new__(cls, value="0", context=None):
+ """Create a decimal point instance.
+
+ >>> Decimal('3.14') # string input
+ Decimal("3.14")
+ >>> Decimal((0, (3, 1, 4), -2)) # tuple (sign, digit_tuple, exponent)
+ Decimal("3.14")
+ >>> Decimal(314) # int or long
+ Decimal("314")
+ >>> Decimal(Decimal(314)) # another decimal instance
+ Decimal("314")
+ """
+
+ # Note that the coefficient, self._int, is actually stored as
+ # a string rather than as a tuple of digits. This speeds up
+ # the "digits to integer" and "integer to digits" conversions
+ # that are used in almost every arithmetic operation on
+ # Decimals. This is an internal detail: the as_tuple function
+ # and the Decimal constructor still deal with tuples of
+ # digits.
+
+ self = object.__new__(cls)
+
+ # From a string
+ # REs insist on real strings, so we can too.
+ if isinstance(value, basestring):
+ m = _parser(value)
+ if m is None:
+ if context is None:
+ context = getcontext()
+ return context._raise_error(ConversionSyntax,
+ "Invalid literal for Decimal: %r" % value)
+
+ if m.group('sign') == "-":
+ self._sign = 1
+ else:
+ self._sign = 0
+ intpart = m.group('int')
+ if intpart is not None:
+ # finite number
+ fracpart = m.group('frac')
+ exp = int(m.group('exp') or '0')
+ if fracpart is not None:
+ self._int = str((intpart+fracpart).lstrip('0') or '0')
+ self._exp = exp - len(fracpart)
+ else:
+ self._int = str(intpart.lstrip('0') or '0')
+ self._exp = exp
+ self._is_special = False
+ else:
+ diag = m.group('diag')
+ if diag is not None:
+ # NaN
+ self._int = str(diag.lstrip('0'))
+ if m.group('signal'):
+ self._exp = 'N'
+ else:
+ self._exp = 'n'
+ else:
+ # infinity
+ self._int = '0'
+ self._exp = 'F'
+ self._is_special = True
+ return self
+
+ # From an integer
+ if isinstance(value, (int,long)):
+ if value >= 0:
+ self._sign = 0
+ else:
+ self._sign = 1
+ self._exp = 0
+ self._int = str(abs(value))
+ self._is_special = False
+ return self
+
+ # From another decimal
+ if isinstance(value, Decimal):
+ self._exp = value._exp
+ self._sign = value._sign
+ self._int = value._int
+ self._is_special = value._is_special
+ return self
+
+ # From an internal working value
+ if isinstance(value, _WorkRep):
+ self._sign = value.sign
+ self._int = str(value.int)
+ self._exp = int(value.exp)
+ self._is_special = False
+ return self
+
+ # tuple/list conversion (possibly from as_tuple())
+ if isinstance(value, (list,tuple)):
+ if len(value) != 3:
+ raise ValueError('Invalid tuple size in creation of Decimal '
+ 'from list or tuple. The list or tuple '
+ 'should have exactly three elements.')
+ # process sign. The isinstance test rejects floats
+ if not (isinstance(value[0], (int, long)) and value[0] in (0,1)):
+ raise ValueError("Invalid sign. The first value in the tuple "
+ "should be an integer; either 0 for a "
+ "positive number or 1 for a negative number.")
+ self._sign = value[0]
+ if value[2] == 'F':
+ # infinity: value[1] is ignored
+ self._int = '0'
+ self._exp = value[2]
+ self._is_special = True
+ else:
+ # process and validate the digits in value[1]
+ digits = []
+ for digit in value[1]:
+ if isinstance(digit, (int, long)) and 0 <= digit <= 9:
+ # skip leading zeros
+ if digits or digit != 0:
+ digits.append(digit)
+ else:
+ raise ValueError("The second value in the tuple must "
+ "be composed of integers in the range "
+ "0 through 9.")
+ if value[2] in ('n', 'N'):
+ # NaN: digits form the diagnostic
+ self._int = ''.join(map(str, digits))
+ self._exp = value[2]
+ self._is_special = True
+ elif isinstance(value[2], (int, long)):
+ # finite number: digits give the coefficient
+ self._int = ''.join(map(str, digits or [0]))
+ self._exp = value[2]
+ self._is_special = False
+ else:
+ raise ValueError("The third value in the tuple must "
+ "be an integer, or one of the "
+ "strings 'F', 'n', 'N'.")
+ return self
+
+ if isinstance(value, float):
+ raise TypeError("Cannot convert float to Decimal. " +
+ "First convert the float to a string")
+
+ raise TypeError("Cannot convert %r to Decimal" % value)
+
+ def _isnan(self):
+ """Returns whether the number is not actually one.
+
+ 0 if a number
+ 1 if NaN
+ 2 if sNaN
+ """
+ if self._is_special:
+ exp = self._exp
+ if exp == 'n':
+ return 1
+ elif exp == 'N':
+ return 2
+ return 0
+
+ def _isinfinity(self):
+ """Returns whether the number is infinite
+
+ 0 if finite or not a number
+ 1 if +INF
+ -1 if -INF
+ """
+ if self._exp == 'F':
+ if self._sign:
+ return -1
+ return 1
+ return 0
+
+ def _check_nans(self, other=None, context=None):
+ """Returns whether the number is not actually one.
+
+ if self, other are sNaN, signal
+ if self, other are NaN return nan
+ return 0
+
+ Done before operations.
+ """
+
+ self_is_nan = self._isnan()
+ if other is None:
+ other_is_nan = False
+ else:
+ other_is_nan = other._isnan()
+
+ if self_is_nan or other_is_nan:
+ if context is None:
+ context = getcontext()
+
+ if self_is_nan == 2:
+ return context._raise_error(InvalidOperation, 'sNaN',
+ self)
+ if other_is_nan == 2:
+ return context._raise_error(InvalidOperation, 'sNaN',
+ other)
+ if self_is_nan:
+ return self._fix_nan(context)
+
+ return other._fix_nan(context)
+ return 0
+
+ def __nonzero__(self):
+ """Return True if self is nonzero; otherwise return False.
+
+ NaNs and infinities are considered nonzero.
+ """
+ return self._is_special or self._int != '0'
+
+ def __cmp__(self, other):
+ other = _convert_other(other)
+ if other is NotImplemented:
+ # Never return NotImplemented
+ return 1
+
+ if self._is_special or other._is_special:
+ # check for nans, without raising on a signaling nan
+ if self._isnan() or other._isnan():
+ return 1 # Comparison involving NaN's always reports self > other
+
+ # INF = INF
+ return cmp(self._isinfinity(), other._isinfinity())
+
+ # check for zeros; note that cmp(0, -0) should return 0
+ if not self:
+ if not other:
+ return 0
+ else:
+ return -((-1)**other._sign)
+ if not other:
+ return (-1)**self._sign
+
+ # If different signs, neg one is less
+ if other._sign < self._sign:
+ return -1
+ if self._sign < other._sign:
+ return 1
+
+ self_adjusted = self.adjusted()
+ other_adjusted = other.adjusted()
+ if self_adjusted == other_adjusted:
+ self_padded = self._int + '0'*(self._exp - other._exp)
+ other_padded = other._int + '0'*(other._exp - self._exp)
+ return cmp(self_padded, other_padded) * (-1)**self._sign
+ elif self_adjusted > other_adjusted:
+ return (-1)**self._sign
+ else: # self_adjusted < other_adjusted
+ return -((-1)**self._sign)
+
+ def __eq__(self, other):
+ if not isinstance(other, (Decimal, int, long)):
+ return NotImplemented
+ return self.__cmp__(other) == 0
+
+ def __ne__(self, other):
+ if not isinstance(other, (Decimal, int, long)):
+ return NotImplemented
+ return self.__cmp__(other) != 0
+
+ def compare(self, other, context=None):
+ """Compares one to another.
+
+ -1 => a < b
+ 0 => a = b
+ 1 => a > b
+ NaN => one is NaN
+ Like __cmp__, but returns Decimal instances.
+ """
+ other = _convert_other(other, raiseit=True)
+
+ # Compare(NaN, NaN) = NaN
+ if (self._is_special or other and other._is_special):
+ ans = self._check_nans(other, context)
+ if ans:
+ return ans
+
+ return Decimal(self.__cmp__(other))
+
+ def __hash__(self):
+ """x.__hash__() <==> hash(x)"""
+ # Decimal integers must hash the same as the ints
+ #
+ # The hash of a nonspecial noninteger Decimal must depend only
+ # on the value of that Decimal, and not on its representation.
+ # For example: hash(Decimal("100E-1")) == hash(Decimal("10")).
+ if self._is_special:
+ if self._isnan():
+ raise TypeError('Cannot hash a NaN value.')
+ return hash(str(self))
+ if not self:
+ return 0
+ if self._isinteger():
+ op = _WorkRep(self.to_integral_value())
+ return hash((-1)**op.sign*op.int*10**op.exp)
+ # The value of a nonzero nonspecial Decimal instance is
+ # faithfully represented by the triple consisting of its sign,
+ # its adjusted exponent, and its coefficient with trailing
+ # zeros removed.
+ return hash((self._sign,
+ self._exp+len(self._int),
+ self._int.rstrip('0')))
+
+ def as_tuple(self):
+ """Represents the number as a triple tuple.
+
+ To show the internals exactly as they are.
+ """
+ return (self._sign, tuple(map(int, self._int)), self._exp)
+
+ def __repr__(self):
+ """Represents the number as an instance of Decimal."""
+ # Invariant: eval(repr(d)) == d
+ return 'Decimal("%s")' % str(self)
+
+ def __str__(self, eng=False, context=None):
+ """Return string representation of the number in scientific notation.
+
+ Captures all of the information in the underlying representation.
+ """
+
+ sign = ['', '-'][self._sign]
+ if self._is_special:
+ if self._exp == 'F':
+ return sign + 'Infinity'
+ elif self._exp == 'n':
+ return sign + 'NaN' + self._int
+ else: # self._exp == 'N'
+ return sign + 'sNaN' + self._int
+
+ # number of digits of self._int to left of decimal point
+ leftdigits = self._exp + len(self._int)
+
+ # dotplace is number of digits of self._int to the left of the
+ # decimal point in the mantissa of the output string (that is,
+ # after adjusting the exponent)
+ if self._exp <= 0 and leftdigits > -6:
+ # no exponent required
+ dotplace = leftdigits
+ elif not eng:
+ # usual scientific notation: 1 digit on left of the point
+ dotplace = 1
+ elif self._int == '0':
+ # engineering notation, zero
+ dotplace = (leftdigits + 1) % 3 - 1
+ else:
+ # engineering notation, nonzero
+ dotplace = (leftdigits - 1) % 3 + 1
+
+ if dotplace <= 0:
+ intpart = '0'
+ fracpart = '.' + '0'*(-dotplace) + self._int
+ elif dotplace >= len(self._int):
+ intpart = self._int+'0'*(dotplace-len(self._int))
+ fracpart = ''
+ else:
+ intpart = self._int[:dotplace]
+ fracpart = '.' + self._int[dotplace:]
+ if leftdigits == dotplace:
+ exp = ''
+ else:
+ if context is None:
+ context = getcontext()
+ exp = ['e', 'E'][context.capitals] + "%+d" % (leftdigits-dotplace)
+
+ return sign + intpart + fracpart + exp
+
+ def to_eng_string(self, context=None):
+ """Convert to engineering-type string.
+
+ Engineering notation has an exponent which is a multiple of 3, so there
+ are up to 3 digits left of the decimal place.
+
+ Same rules for when in exponential and when as a value as in __str__.
+ """
+ return self.__str__(eng=True, context=context)
+
+ def __neg__(self, context=None):
+ """Returns a copy with the sign switched.
+
+ Rounds, if it has reason.
+ """
+ if self._is_special:
+ ans = self._check_nans(context=context)
+ if ans:
+ return ans
+
+ if not self:
+ # -Decimal('0') is Decimal('0'), not Decimal('-0')
+ ans = self.copy_abs()
+ else:
+ ans = self.copy_negate()
+
+ if context is None:
+ context = getcontext()
+ return ans._fix(context)
+
+ def __pos__(self, context=None):
+ """Returns a copy, unless it is a sNaN.
+
+ Rounds the number (if more then precision digits)
+ """
+ if self._is_special:
+ ans = self._check_nans(context=context)
+ if ans:
+ return ans
+
+ if not self:
+ # + (-0) = 0
+ ans = self.copy_abs()
+ else:
+ ans = Decimal(self)
+
+ if context is None:
+ context = getcontext()
+ return ans._fix(context)
+
+ def __abs__(self, round=True, context=None):
+ """Returns the absolute value of self.
+
+ If the keyword argument 'round' is false, do not round. The
+ expression self.__abs__(round=False) is equivalent to
+ self.copy_abs().
+ """
+ if not round:
+ return self.copy_abs()
+
+ if self._is_special:
+ ans = self._check_nans(context=context)
+ if ans:
+ return ans
+
+ if self._sign:
+ ans = self.__neg__(context=context)
+ else:
+ ans = self.__pos__(context=context)
+
+ return ans
+
+ def __add__(self, other, context=None):
+ """Returns self + other.
+
+ -INF + INF (or the reverse) cause InvalidOperation errors.
+ """
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+
+ if context is None:
+ context = getcontext()
+
+ if self._is_special or other._is_special:
+ ans = self._check_nans(other, context)
+ if ans:
+ return ans
+
+ if self._isinfinity():
+ # If both INF, same sign => same as both, opposite => error.
+ if self._sign != other._sign and other._isinfinity():
+ return context._raise_error(InvalidOperation, '-INF + INF')
+ return Decimal(self)
+ if other._isinfinity():
+ return Decimal(other) # Can't both be infinity here
+
+ exp = min(self._exp, other._exp)
+ negativezero = 0
+ if context.rounding == ROUND_FLOOR and self._sign != other._sign:
+ # If the answer is 0, the sign should be negative, in this case.
+ negativezero = 1
+
+ if not self and not other:
+ sign = min(self._sign, other._sign)
+ if negativezero:
+ sign = 1
+ ans = _dec_from_triple(sign, '0', exp)
+ ans = ans._fix(context)
+ return ans
+ if not self:
+ exp = max(exp, other._exp - context.prec-1)
+ ans = other._rescale(exp, context.rounding)
+ ans = ans._fix(context)
+ return ans
+ if not other:
+ exp = max(exp, self._exp - context.prec-1)
+ ans = self._rescale(exp, context.rounding)
+ ans = ans._fix(context)
+ return ans
+
+ op1 = _WorkRep(self)
+ op2 = _WorkRep(other)
+ op1, op2 = _normalize(op1, op2, context.prec)
+
+ result = _WorkRep()
+ if op1.sign != op2.sign:
+ # Equal and opposite
+ if op1.int == op2.int:
+ ans = _dec_from_triple(negativezero, '0', exp)
+ ans = ans._fix(context)
+ return ans
+ if op1.int < op2.int:
+ op1, op2 = op2, op1
+ # OK, now abs(op1) > abs(op2)
+ if op1.sign == 1:
+ result.sign = 1
+ op1.sign, op2.sign = op2.sign, op1.sign
+ else:
+ result.sign = 0
+ # So we know the sign, and op1 > 0.
+ elif op1.sign == 1:
+ result.sign = 1
+ op1.sign, op2.sign = (0, 0)
+ else:
+ result.sign = 0
+ # Now, op1 > abs(op2) > 0
+
+ if op2.sign == 0:
+ result.int = op1.int + op2.int
+ else:
+ result.int = op1.int - op2.int
+
+ result.exp = op1.exp
+ ans = Decimal(result)
+ ans = ans._fix(context)
+ return ans
+
+ __radd__ = __add__
+
+ def __sub__(self, other, context=None):
+ """Return self - other"""
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+
+ if self._is_special or other._is_special:
+ ans = self._check_nans(other, context=context)
+ if ans:
+ return ans
+
+ # self - other is computed as self + other.copy_negate()
+ return self.__add__(other.copy_negate(), context=context)
+
+ def __rsub__(self, other, context=None):
+ """Return other - self"""
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+
+ return other.__sub__(self, context=context)
+
+ def __mul__(self, other, context=None):
+ """Return self * other.
+
+ (+-) INF * 0 (or its reverse) raise InvalidOperation.
+ """
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+
+ if context is None:
+ context = getcontext()
+
+ resultsign = self._sign ^ other._sign
+
+ if self._is_special or other._is_special:
+ ans = self._check_nans(other, context)
+ if ans:
+ return ans
+
+ if self._isinfinity():
+ if not other:
+ return context._raise_error(InvalidOperation, '(+-)INF * 0')
+ return Infsign[resultsign]
+
+ if other._isinfinity():
+ if not self:
+ return context._raise_error(InvalidOperation, '0 * (+-)INF')
+ return Infsign[resultsign]
+
+ resultexp = self._exp + other._exp
+
+ # Special case for multiplying by zero
+ if not self or not other:
+ ans = _dec_from_triple(resultsign, '0', resultexp)
+ # Fixing in case the exponent is out of bounds
+ ans = ans._fix(context)
+ return ans
+
+ # Special case for multiplying by power of 10
+ if self._int == '1':
+ ans = _dec_from_triple(resultsign, other._int, resultexp)
+ ans = ans._fix(context)
+ return ans
+ if other._int == '1':
+ ans = _dec_from_triple(resultsign, self._int, resultexp)
+ ans = ans._fix(context)
+ return ans
+
+ op1 = _WorkRep(self)
+ op2 = _WorkRep(other)
+
+ ans = _dec_from_triple(resultsign, str(op1.int * op2.int), resultexp)
+ ans = ans._fix(context)
+
+ return ans
+ __rmul__ = __mul__
+
+ def __div__(self, other, context=None):
+ """Return self / other."""
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return NotImplemented
+
+ if context is None:
+ context = getcontext()
+
+ sign = self._sign ^ other._sign
+
+ if self._is_special or other._is_special:
+ ans = self._check_nans(other, context)
+ if ans:
+ return ans
+
+ if self._isinfinity() and other._isinfinity():
+ return context._raise_error(InvalidOperation, '(+-)INF/(+-)INF')
+
+ if self._isinfinity():
+ return Infsign[sign]
+
+ if other._isinfinity():
+ context._raise_error(Clamped, 'Division by infinity')
+ return _dec_from_triple(sign, '0', context.Etiny())
+
+ # Special cases for zeroes
+ if not other:
+ if not self:
+ return context._raise_error(DivisionUndefined, '0 / 0')
+ return context._raise_error(DivisionByZero, 'x / 0', sign)
+
+ if not self:
+ exp = self._exp - other._exp
+ coeff = 0
+ else:
+ # OK, so neither = 0, INF or NaN
+ shift = len(other._int) - len(self._int) + context.prec + 1
+ exp = self._exp - other._exp - shift
+ op1 = _WorkRep(self)
+ op2 = _WorkRep(other)
+ if shift >= 0:
+ coeff, remainder = divmod(op1.int * 10**shift, op2.int)
+ else:
+ coeff, remainder = divmod(op1.int, op2.int * 10**-shift)
+ if remainder:
+ # result is not exact; adjust to ensure correct rounding
+ if coeff % 5 == 0:
+ coeff += 1
+ else:
+ # result is exact; get as close to ideal exponent as possible
+ ideal_exp = self._exp - other._exp
+ while exp < ideal_exp and coeff % 10 == 0:
+ coeff //= 10
+ exp += 1
+
+ ans = _dec_from_triple(sign, str(coeff), exp)
+ return ans._fix(context)
+
+ __truediv__ = __div__
+
+ def _divide(self, other, context):
+ """Return (self // other, self % other), to context.prec precision.
+
+ Assumes that neither self nor other is a NaN, that self is not
+ infinite and that other is nonzero.
+ """
+ sign = self._sign ^ other._sign
+ if other._isinfinity():
+ ideal_exp = self._exp
+ else:
+ ideal_exp = min(self._exp, other._exp)
+
+ expdiff = self.adjusted() - other.adjusted()
+ if not self or other._isinfinity() or expdiff <= -2:
+ return (_dec_from_triple(sign, '0', 0),
+ self._rescale(ideal_exp, context.rounding))
+ if expdiff <= context.prec:
+ op1 = _WorkRep(self)
+ op2 = _WorkRep(other)
+ if op1.exp >= op2.exp:
+ op1.int *= 10**(op1.exp - op2.exp)
+ else:
+ op2.int *= 10**(op2.exp - op1.exp)
+ q, r = divmod(op1.int, op2.int)
+ if q < 10**context.prec:
+ return (_dec_from_triple(sign, str(q), 0),
+ _dec_from_triple(self._sign, str(r), ideal_exp))
+
+ # Here the quotient is too large to be representable
+ ans = context._raise_error(DivisionImpossible,
+ 'quotient too large in //, % or divmod')
+ return ans, ans
+
+ def __rdiv__(self, other, context=None):
+ """Swaps self/other and returns __div__."""
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+ return other.__div__(self, context=context)
+ __rtruediv__ = __rdiv__
+
+ def __divmod__(self, other, context=None):
+ """
+ Return (self // other, self % other)
+ """
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+
+ if context is None:
+ context = getcontext()
+
+ ans = self._check_nans(other, context)
+ if ans:
+ return (ans, ans)
+
+ sign = self._sign ^ other._sign
+ if self._isinfinity():
+ if other._isinfinity():
+ ans = context._raise_error(InvalidOperation, 'divmod(INF, INF)')
+ return ans, ans
+ else:
+ return (Infsign[sign],
+ context._raise_error(InvalidOperation, 'INF % x'))
+
+ if not other:
+ if not self:
+ ans = context._raise_error(DivisionUndefined, 'divmod(0, 0)')
+ return ans, ans
+ else:
+ return (context._raise_error(DivisionByZero, 'x // 0', sign),
+ context._raise_error(InvalidOperation, 'x % 0'))
+
+ quotient, remainder = self._divide(other, context)
+ remainder = remainder._fix(context)
+ return quotient, remainder
+
+ def __rdivmod__(self, other, context=None):
+ """Swaps self/other and returns __divmod__."""
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+ return other.__divmod__(self, context=context)
+
+ def __mod__(self, other, context=None):
+ """
+ self % other
+ """
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+
+ if context is None:
+ context = getcontext()
+
+ ans = self._check_nans(other, context)
+ if ans:
+ return ans
+
+ if self._isinfinity():
+ return context._raise_error(InvalidOperation, 'INF % x')
+ elif not other:
+ if self:
+ return context._raise_error(InvalidOperation, 'x % 0')
+ else:
+ return context._raise_error(DivisionUndefined, '0 % 0')
+
+ remainder = self._divide(other, context)[1]
+ remainder = remainder._fix(context)
+ return remainder
+
+ def __rmod__(self, other, context=None):
+ """Swaps self/other and returns __mod__."""
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+ return other.__mod__(self, context=context)
+
+ def remainder_near(self, other, context=None):
+ """
+ Remainder nearest to 0- abs(remainder-near) <= other/2
+ """
+ if context is None:
+ context = getcontext()
+
+ other = _convert_other(other, raiseit=True)
+
+ ans = self._check_nans(other, context)
+ if ans:
+ return ans
+
+ # self == +/-infinity -> InvalidOperation
+ if self._isinfinity():
+ return context._raise_error(InvalidOperation,
+ 'remainder_near(infinity, x)')
+
+ # other == 0 -> either InvalidOperation or DivisionUndefined
+ if not other:
+ if self:
+ return context._raise_error(InvalidOperation,
+ 'remainder_near(x, 0)')
+ else:
+ return context._raise_error(DivisionUndefined,
+ 'remainder_near(0, 0)')
+
+ # other = +/-infinity -> remainder = self
+ if other._isinfinity():
+ ans = Decimal(self)
+ return ans._fix(context)
+
+ # self = 0 -> remainder = self, with ideal exponent
+ ideal_exponent = min(self._exp, other._exp)
+ if not self:
+ ans = _dec_from_triple(self._sign, '0', ideal_exponent)
+ return ans._fix(context)
+
+ # catch most cases of large or small quotient
+ expdiff = self.adjusted() - other.adjusted()
+ if expdiff >= context.prec + 1:
+ # expdiff >= prec+1 => abs(self/other) > 10**prec
+ return context._raise_error(DivisionImpossible)
+ if expdiff <= -2:
+ # expdiff <= -2 => abs(self/other) < 0.1
+ ans = self._rescale(ideal_exponent, context.rounding)
+ return ans._fix(context)
+
+ # adjust both arguments to have the same exponent, then divide
+ op1 = _WorkRep(self)
+ op2 = _WorkRep(other)
+ if op1.exp >= op2.exp:
+ op1.int *= 10**(op1.exp - op2.exp)
+ else:
+ op2.int *= 10**(op2.exp - op1.exp)
+ q, r = divmod(op1.int, op2.int)
+ # remainder is r*10**ideal_exponent; other is +/-op2.int *
+ # 10**ideal_exponent. Apply correction to ensure that
+ # abs(remainder) <= abs(other)/2
+ if 2*r + (q&1) > op2.int:
+ r -= op2.int
+ q += 1
+
+ if q >= 10**context.prec:
+ return context._raise_error(DivisionImpossible)
+
+ # result has same sign as self unless r is negative
+ sign = self._sign
+ if r < 0:
+ sign = 1-sign
+ r = -r
+
+ ans = _dec_from_triple(sign, str(r), ideal_exponent)
+ return ans._fix(context)
+
+ def __floordiv__(self, other, context=None):
+ """self // other"""
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+
+ if context is None:
+ context = getcontext()
+
+ ans = self._check_nans(other, context)
+ if ans:
+ return ans
+
+ if self._isinfinity():
+ if other._isinfinity():
+ return context._raise_error(InvalidOperation, 'INF // INF')
+ else:
+ return Infsign[self._sign ^ other._sign]
+
+ if not other:
+ if self:
+ return context._raise_error(DivisionByZero, 'x // 0',
+ self._sign ^ other._sign)
+ else:
+ return context._raise_error(DivisionUndefined, '0 // 0')
+
+ return self._divide(other, context)[0]
+
+ def __rfloordiv__(self, other, context=None):
+ """Swaps self/other and returns __floordiv__."""
+ other = _convert_other(other)
+ if other is NotImplemented:
+ return other
+ return other.__floordiv__(self, context=context)
+
+ def __float__(self):
+ """Float representation."""
+ return float(str(self))
+
+ def __int__(self):
+ """Converts self to an int, truncating if necessary."""
+ if self._is_special:
+ if self._isnan():
+ context = getcontext()
+ return context._raise_error(InvalidContext)
+ elif self._isinfinity():
+ raise OverflowError("Cannot convert infinity to long")
+ s = (-1)**self._sign
+ if self._exp >= 0:
+ return s*int(self._int)*10**self._exp
+ else:
+ return s*int(self._int[:self._exp] or '0')
+
+ def __long__(self):
+ """Converts to a long.
+
+ Equivalent to long(int(self))
+ """
+ return long(self.__int__())
+
+ def _fix_nan(self, context):
+ """Decapitate the payload of a NaN to fit the context"""
+ payload = self._int
+
+ # maximum length of payload is precision if _clamp=0,
+ # precision-1 if _clamp=1.
+ max_payload_len = context.prec - context._clamp
+ if len(payload) > max_payload_len:
+ payload = payload[len(payload)-max_payload_len:].lstrip('0')
+ return _dec_from_triple(self._sign, payload, self._exp, True)
+ return Decimal(self)
+
+ def _fix(self, context):
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|