[pypy-commit] pypy utf8-unicode2: Try to fix unicode.join([]). It passed locally but failed on the buildbot

2014-08-08 Thread waedt
Author: Tyler Wade 
Branch: utf8-unicode2
Changeset: r72717:e941f1e74248
Date: 2014-08-05 14:11 -0500
http://bitbucket.org/pypy/pypy/changeset/e941f1e74248/

Log:Try to fix unicode.join([]). It passed locally
but failed on the buildbot

diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -235,7 +235,8 @@
 else:
 if r_lst.item_repr == rstr.repr:
 llfn = self.ll.ll_join
-elif r_lst.item_repr == char_repr:
+elif (r_lst.item_repr == char_repr or
+  r_lst.item_repr == unichar_repr):
 llfn = self.ll.ll_join_chars_with_str
 else:
 raise TyperError("sep.join() of non-string list: %r" % r_lst)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy utf8-unicode2: Some non-ascii Utf8Str's were being marked as ascii

2014-08-08 Thread waedt
Author: Tyler Wade 
Branch: utf8-unicode2
Changeset: r72718:f324ba27ece1
Date: 2014-08-06 21:10 -0500
http://bitbucket.org/pypy/pypy/changeset/f324ba27ece1/

Log:Some non-ascii Utf8Str's were being marked as ascii

diff --git a/pypy/interpreter/test/test_utf8_codecs.py 
b/pypy/interpreter/test/test_utf8_codecs.py
--- a/pypy/interpreter/test/test_utf8_codecs.py
+++ b/pypy/interpreter/test/test_utf8_codecs.py
@@ -746,6 +746,12 @@
 u = Utf8Str.from_unicode(unicode(s, 'raw-unicode-escape'))
 assert decoder(s, len(s), 'strict')[0] == u
 
+def test_decode_unicode_escape(self):
+decoder = self.getdecoder('unicode-escape')
+s = '\\\xff'
+u = Utf8Str.from_unicode(unicode(s, 'unicode-escape'))
+assert decoder(s, len(s), 'strict')[0] == u
+
 
 class TestTranslation(object):
 def test_utf8(self):
diff --git a/pypy/interpreter/utf8.py b/pypy/interpreter/utf8.py
--- a/pypy/interpreter/utf8.py
+++ b/pypy/interpreter/utf8.py
@@ -478,7 +478,7 @@
 for s in other:
 if not s._is_ascii:
 is_ascii = False
-break
+break
 return Utf8Str(self.bytes.join([s.bytes for s in other]), is_ascii)
 else:
 assert isinstance(other[0], str)
@@ -678,6 +678,8 @@
 elif isinstance(s, Utf8Str):
 self._builder.append_slice(s.bytes, s.index_of_char(start),
s.index_of_char(end))
+if not s._is_ascii:
+self._is_ascii = False
 else:
 raise TypeError("Invalid type '%s' for Utf8Str.append_slice" %
 type(s))
diff --git a/pypy/interpreter/utf8_codecs.py b/pypy/interpreter/utf8_codecs.py
--- a/pypy/interpreter/utf8_codecs.py
+++ b/pypy/interpreter/utf8_codecs.py
@@ -134,7 +134,7 @@
 builder.append(res)
 else:
 builder.append('\\')
-builder.append(ch)
+builder.append(ord(ch))
 
 return builder.build(), pos
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy utf8-unicode2: Refactor Utf8Builder API some; don't allow .append()

2014-08-08 Thread waedt
Author: Tyler Wade 
Branch: utf8-unicode2
Changeset: r72719:b5e27ed82427
Date: 2014-08-08 02:12 -0500
http://bitbucket.org/pypy/pypy/changeset/b5e27ed82427/

Log:Refactor Utf8Builder API some; don't allow .append()

diff --git a/pypy/interpreter/test/test_utf8.py 
b/pypy/interpreter/test/test_utf8.py
--- a/pypy/interpreter/test/test_utf8.py
+++ b/pypy/interpreter/test/test_utf8.py
@@ -9,10 +9,10 @@
 
 def build_utf8str():
 builder = Utf8Builder()
-builder.append('A') #0x41
-builder.append(0x10F) #0xC4 0x8F
-builder.append(0x20AC) #0xE2 0x82 0xAC
-builder.append(0x1F63D) #0xF0 0x9F 0x98 0xBD
+builder.append_ascii('A') #0x41
+builder.append_codepoint(0x10F) #0xC4 0x8F
+builder.append_codepoint(0x20AC) #0xE2 0x82 0xAC
+builder.append_codepoint(0x1F63D) #0xF0 0x9F 0x98 0xBD
 return builder.build()
 
 def test_builder():
@@ -88,7 +88,7 @@
 
 def test_unicode_literal_comparison():
 builder = Utf8Builder()
-builder.append(0x10F)
+builder.append_codepoint(0x10F)
 s = builder.build()
 assert s == u'\u010F'
 assert s[0] == u'\u010F'
diff --git a/pypy/interpreter/test/test_utf8_codecs.py 
b/pypy/interpreter/test/test_utf8_codecs.py
--- a/pypy/interpreter/test/test_utf8_codecs.py
+++ b/pypy/interpreter/test/test_utf8_codecs.py
@@ -58,7 +58,7 @@
 assert t is s
 assert start == startingpos
 assert stop == endingpos
-return "42424242", None, stop
+return Utf8Str("42424242"), None, stop
 encoder = self.getencoder(encoding)
 result = encoder(s, len(s), "foo!", errorhandler)
 assert called[0]
@@ -85,8 +85,8 @@
 assert stop == endingpos
 if msg is not None:
 assert errmsg == msg
-return "42424242", stop
-return "", endingpos
+return Utf8Str("42424242"), stop
+return Utf8Str(""), endingpos
 decoder = self.getdecoder(encoding)
 if addstuff:
 s += "some rest in ascii"
diff --git a/pypy/interpreter/utf8.py b/pypy/interpreter/utf8.py
--- a/pypy/interpreter/utf8.py
+++ b/pypy/interpreter/utf8.py
@@ -21,7 +21,7 @@
 # Like unichr, but returns a Utf8Str object
 # TODO: Do this without the builder so its faster
 b = Utf8Builder()
-b.append(value)
+b.append_codepoint(value)
 return b.build()
 
 def utf8ord_bytes(bytes, start):
@@ -130,6 +130,13 @@
 else:
 self._len = len(data)
 
+if not we_are_translated():
+self.bytes.decode('utf8')
+
+if self._is_ascii:
+for i in self.bytes:
+assert ord(i) < 128
+
 def _calc_length(self):
 pos = 0
 length = 0
@@ -559,15 +566,15 @@
 i += 1
 c2 = intmask(array[i])
 if c2 == 0:
-builder.append(c)
+builder.append_codepoint(c)
 break
 elif not (0xDC00 <= c2 <= 0xDFFF):
-builder.append(c)
+builder.append_codepoint(c)
 c = c2
 else:
 c = (((c & 0x3FF)<<10) | (c2 & 0x3FF)) + 0x1;
 
-builder.append(c)
+builder.append_codepoint(c)
 i += 1
 
 return builder.build()
@@ -587,15 +594,15 @@
 i += 1
 c2 = intmask(array[i])
 if c2 == 0:
-builder.append(c)
+builder.append_codepoint(c)
 break
 elif not (0xDC00 <= c2 <= 0xDFFF):
-builder.append(c)
+builder.append_codepoint(c)
 c = c2
 else:
 c = (((c & 0x3FF)<<10) | (c2 & 0x3FF)) + 0x1;
 
-builder.append(c)
+builder.append_codepoint(c)
 i += 1
 
 return builder.build()
@@ -613,12 +620,12 @@
 i += 1
 c2 = intmask(array[i])
 if not (0xDC00 <= c2 <= 0xDFFF):
-builder.append(c)
+builder.append_codepoint(c)
 c = c2
 else:
 c = (((c & 0x3FF)<<10) | (c2 & 0x3FF)) + 0x1;
 
-builder.append(c)
+builder.append_codepoint(c)
 i += 1
 
 return builder.build()
@@ -634,42 +641,54 @@
 self._length = 0
 
 
+def append_codepoint(self, c):
+if c < 0x80:
+self._builder.append(chr(c))
+elif c < 0x800:
+self._builder.append(chr(0xC0 | (c >> 6)))
+self._builder.append(chr(0x80 | (c & 0x3F)))
+self._is_ascii = False
+elif c < 0x1:
+self.

[pypy-commit] lang-smalltalk emscripten: changes for emscripten compile

2014-08-08 Thread timfel
Author: Tim Felgentreff 
Branch: emscripten
Changeset: r1031:e0767d248b23
Date: 2014-08-08 11:45 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/e0767d248b23/

Log:changes for emscripten compile
  - no references to cursor stuff
  - async flag in interpreter

diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -61,7 +61,7 @@
 class Interpreter(object):
 _immutable_fields_ = ["space", "image",
   "interrupt_counter_size", "trace_important",
-  "startup_time", "evented", "interrupts"]
+  "startup_time", "evented", "interrupts", "is_async"]
 
 jit_driver = jit.JitDriver(
 greens=['pc', 'self', 'method'],
@@ -71,10 +71,11 @@
 )
 
 def __init__(self, space, image=None, trace_important=False,
-trace=False, evented=True, interrupts=True):
+trace=False, evented=True, interrupts=True, is_async=False):
 # === Initialize immutable variables
 self.space = space
 self.image = image
+self.is_async = is_async
 if image:
 self.startup_time = image.startup_time
 else:
@@ -105,6 +106,8 @@
 except ContextSwitchException, e:
 if self.is_tracing():
 e.print_trace()
+if self.is_async:
+return e.s_new_context.w_self()
 s_context = e.s_new_context
 except Return, ret:
 target = s_sender if ret.arrived_at_target else 
ret.s_target_context
diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -987,16 +987,16 @@
 def convert_to_c_layout(self):
 if self.words is None:
 return self.c_words
-else:
-from spyvm.interpreter_proxy import sqIntArrayPtr
-size = self.size()
-old_words = self.words
-c_words = self.c_words = lltype.malloc(sqIntArrayPtr.TO, size, 
flavor='raw')
-for i in range(size):
-c_words[i] = intmask(old_words[i])
-self.words = None
-return c_words
-
+# else:
+# from spyvm.interpreter_proxy import sqIntArrayPtr
+# size = self.size()
+# old_words = self.words
+# c_words = self.c_words = lltype.malloc(sqIntArrayPtr.TO, size, 
flavor='raw')
+# for i in range(size):
+# c_words[i] = intmask(old_words[i])
+# self.words = None
+# return c_words
+
 def _become(self, w_other):
 assert isinstance(w_other, W_WordsObject)
 self.words, w_other.words = w_other.words, self.words
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -712,14 +712,15 @@
 depth = interp.space.unwrap_int(w_rcvr.fetch(interp.space, 3))
 hotpt = wrapper.PointWrapper(interp.space, w_rcvr.fetch(interp.space, 4))
 if not interp.image.is_modern:
-display.SDLCursor.set(
-w_bitmap.words,
-width,
-height,
-hotpt.x(),
-hotpt.y(),
-mask_words=mask_words
-)
+# display.SDLCursor.set(
+# w_bitmap.words,
+# width,
+# height,
+# hotpt.x(),
+# hotpt.y(),
+# mask_words=mask_words
+# )
+pass
 else:
 # TODO: Implement
 pass
@@ -890,18 +891,18 @@
 if signature[0] == 'BitBltPlugin':
 from spyvm.plugins.bitblt import BitBltPlugin
 return BitBltPlugin.call(signature[1], interp, s_frame, argcount, 
w_method)
-elif signature[0] == "SocketPlugin":
-from spyvm.plugins.socket import SocketPlugin
-return SocketPlugin.call(signature[1], interp, s_frame, argcount, 
w_method)
+# elif signature[0] == "SocketPlugin":
+# from spyvm.plugins.socket import SocketPlugin
+# return SocketPlugin.call(signature[1], interp, s_frame, argcount, 
w_method)
 elif signature[0] == "FilePlugin":
 from spyvm.plugins.fileplugin import FilePlugin
 return FilePlugin.call(signature[1], interp, s_frame, argcount, 
w_method)
 elif signature[0] == "VMDebugging":
 from spyvm.plugins.vmdebugging import DebuggingPlugin
 return DebuggingPlugin.call(signature[1], interp, s_frame, argcount, 
w_method)
-else:
-from spyvm.interpreter_proxy import IProxy
-return IProxy.call(signature, interp, s_frame, argcount, w_method)
+# else:
+# from spyvm.interpreter_proxy import IProxy
+# return IProxy.call(signature, interp, s_frame, argcount, w_method)
 raise PrimitiveFailedError
 
 @expose_primitive(COMPILED_METHOD_FLUSH_CACHE, unwrap_spec=[object])
@@ -1497,6 +1498,7 @@
 @expose_primitive(IDLE_FOR_MICROSECONDS, unwrap_spec=[object, i

[pypy-commit] lang-smalltalk emscripten: more changes for emscripten

2014-08-08 Thread timfel
Author: Tim Felgentreff 
Branch: emscripten
Changeset: r1032:2a78caaf3e0f
Date: 2014-08-08 11:48 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/2a78caaf3e0f/

Log:more changes for emscripten

diff --git a/spyvm/display.py b/spyvm/display.py
--- a/spyvm/display.py
+++ b/spyvm/display.py
@@ -47,7 +47,7 @@
 assert RSDL.Init(RSDL.INIT_VIDEO) >= 0
 RSDL.WM_SetCaption(title, "RSqueakVM")
 RSDL.EnableUNICODE(1)
-SDLCursor.has_display = True
+# SDLCursor.has_display = True
 self.has_surface = False
 self.mouse_position = [0, 0]
 self.interrupt_key = 15 << 8 # pushing all four meta keys, of which we 
support three...
@@ -270,45 +270,45 @@
 self.interrupt_key = encoded_key
 
 
-class SDLCursorClass(object):
-_attrs_ = ["cursor", "has_cursor", "has_display"]
+# class SDLCursorClass(object):
+# _attrs_ = ["cursor", "has_cursor", "has_display"]
 
-instance = None
+# instance = None
 
-def __init__(self):
-self.cursor = lltype.nullptr(RSDL.CursorPtr.TO)
-self.has_cursor = False
-self.has_display = False
+# def __init__(self):
+# self.cursor = lltype.nullptr(RSDL.CursorPtr.TO)
+# self.has_cursor = False
+# self.has_display = False
 
-def set(self, data_words, w, h, x, y, mask_words=None):
-if not self.has_display:
-return
-if self.has_cursor:
-RSDL.FreeCursor(self.cursor)
-data = self.words_to_bytes(len(data_words) * 4, data_words)
-try:
-mask = self.words_to_bytes(len(data_words) * 4, mask_words)
-try:
-self.cursor = RSDL.CreateCursor(data, mask, w * 2, h, x, y)
-self.has_cursor = True
-RSDL.SetCursor(self.cursor)
-finally:
-lltype.free(mask, flavor="raw")
-finally:
-lltype.free(data, flavor="raw")
+# def set(self, data_words, w, h, x, y, mask_words=None):
+# if not self.has_display:
+# return
+# if self.has_cursor:
+# RSDL.FreeCursor(self.cursor)
+# data = self.words_to_bytes(len(data_words) * 4, data_words)
+# try:
+# mask = self.words_to_bytes(len(data_words) * 4, mask_words)
+# try:
+# self.cursor = RSDL.CreateCursor(data, mask, w * 2, h, x, y)
+# self.has_cursor = True
+# RSDL.SetCursor(self.cursor)
+# finally:
+# lltype.free(mask, flavor="raw")
+# finally:
+# lltype.free(data, flavor="raw")
 
-def words_to_bytes(self, bytenum, words):
-bytes = lltype.malloc(RSDL.Uint8P.TO, bytenum, flavor="raw")
-if words:
-for pos in range(bytenum / 4):
-word = words[pos]
-bytes[pos * 4] = rffi.r_uchar((word >> 24) & 0xff)
-bytes[pos * 4 + 1] = rffi.r_uchar((word >> 16) & 0xff)
-bytes[pos * 4 + 2] = rffi.r_uchar((word >> 8) & 0xff)
-bytes[pos * 4 + 3] = rffi.r_uchar(word & 0xff)
-else:
-for idx in range(bytenum):
-bytes[idx] = rffi.r_uchar(0)
-return bytes
+# def words_to_bytes(self, bytenum, words):
+# bytes = lltype.malloc(RSDL.Uint8P.TO, bytenum, flavor="raw")
+# if words:
+# for pos in range(bytenum / 4):
+# word = words[pos]
+# bytes[pos * 4] = rffi.r_uchar((word >> 24) & 0xff)
+# bytes[pos * 4 + 1] = rffi.r_uchar((word >> 16) & 0xff)
+# bytes[pos * 4 + 2] = rffi.r_uchar((word >> 8) & 0xff)
+# bytes[pos * 4 + 3] = rffi.r_uchar(word & 0xff)
+# else:
+# for idx in range(bytenum):
+# bytes[idx] = rffi.r_uchar(0)
+# return bytes
 
-SDLCursor = SDLCursorClass()
+# SDLCursor = SDLCursorClass()
diff --git a/targetimageloadingsmalltalk.py b/targetimageloadingsmalltalk.py
--- a/targetimageloadingsmalltalk.py
+++ b/targetimageloadingsmalltalk.py
@@ -3,12 +3,14 @@
 import os
 
 from rpython.rlib.streamio import open_file_as_stream
-from rpython.rlib import jit, rpath, objectmodel
+from rpython.rlib import jit, rpath, objectmodel, rgc
+from rpython.rlib.entrypoint import entrypoint
+from rpython.rtyper.lltypesystem import rffi, llmemory, lltype
 
 from spyvm import model, interpreter, squeakimage, objspace, wrapper,\
 error, shadow, storage_logger, constants
 from spyvm.tool.analyseimage import create_image
-from spyvm.interpreter_proxy import VirtualMachine
+# from spyvm.interpreter_proxy import VirtualMachine
 
 def _usage(argv):
 print """
@@ -200,6 +202,61 @@
 storage_logger.print_aggregated_log()
 return 0
 
+
+@entrypoint('main', [rffi.INT], c_name='load_image')
+def load_image(bitflags):
+trace = (bitflags & 0b1) != 0
+trace_important = (bitflags & 0b10) != 0
+safe_trace = (bitflags & 0b1

[pypy-commit] lang-smalltalk emscripten: new branch

2014-08-08 Thread timfel
Author: Tim Felgentreff 
Branch: emscripten
Changeset: r1030:a1c54c159f54
Date: 2014-08-08 17:41 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/a1c54c159f54/

Log:new branch

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: ensure the cffi.egg-info version is up to date

2014-08-08 Thread pjenvey
Author: Philip Jenvey 
Branch: 
Changeset: r72720:6e76708b4faf
Date: 2014-08-08 12:35 -0700
http://bitbucket.org/pypy/pypy/changeset/6e76708b4faf/

Log:ensure the cffi.egg-info version is up to date

diff --git a/lib_pypy/cffi.egg-info b/lib_pypy/cffi.egg-info
--- a/lib_pypy/cffi.egg-info
+++ b/lib_pypy/cffi.egg-info
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: cffi
-Version: 0.8
+Version: 0.8.6
 Summary: Foreign Function Interface for Python calling C code.
 Home-page: http://cffi.readthedocs.org
 Author: Armin Rigo, Maciej Fijalkowski
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_egg_version.py 
b/pypy/module/test_lib_pypy/cffi_tests/test_egg_version.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_egg_version.py
@@ -0,0 +1,12 @@
+from email.parser import Parser
+
+import py
+
+import cffi
+import pypy
+
+egg_info = py.path.local(pypy.__file__) / '../../lib_pypy/cffi.egg-info'
+
+def test_egg_version():
+info = Parser().parsestr(egg_info.read())
+assert info['version'] == cffi.__version__
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy.org extradoc: update the values

2014-08-08 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r519:c5acb1ff57b7
Date: 2014-08-08 22:10 +0200
http://bitbucket.org/pypy/pypy.org/changeset/c5acb1ff57b7/

Log:update the values

diff --git a/don1.html b/don1.html
--- a/don1.html
+++ b/don1.html
@@ -15,7 +15,7 @@
 
 

-   $52117 of $105000 (49.6%)
+   $52126 of $105000 (49.6%)


 
diff --git a/don3.html b/don3.html
--- a/don3.html
+++ b/don3.html
@@ -15,7 +15,7 @@
 
 

-   $48360 of $6 (80.6%)
+   $48374 of $6 (80.6%)


 
diff --git a/don4.html b/don4.html
--- a/don4.html
+++ b/don4.html
@@ -9,7 +9,7 @@
 
   $(function() {
 $("#progressbar").progressbar({
-  value: 16.7
+  value: 16.8
});
   });
 
@@ -17,7 +17,7 @@
2nd call:

-   $13393 of $8 (16.7%)
+   $13463 of $8 (16.8%)


 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy.org extradoc: merged upstream

2014-08-08 Thread alex_gaynor
Author: Alex Gaynor 
Branch: extradoc
Changeset: r521:08ddef577737
Date: 2014-08-08 16:02 -0700
http://bitbucket.org/pypy/pypy.org/changeset/08ddef577737/

Log:merged upstream

diff --git a/don1.html b/don1.html
--- a/don1.html
+++ b/don1.html
@@ -9,13 +9,13 @@
 
   $(function() {
 $("#progressbar").progressbar({
-  value: 49.5
+  value: 49.6
});
   });
 
 

-   $51969 of $105000 (49.5%)
+   $52126 of $105000 (49.6%)


 
diff --git a/don3.html b/don3.html
--- a/don3.html
+++ b/don3.html
@@ -9,13 +9,13 @@
 
   $(function() {
 $("#progressbar").progressbar({
-  value: 80.5
+  value: 80.6
});
   });
 
 

-   $48322 of $6 (80.5%)
+   $48374 of $6 (80.6%)


 
diff --git a/don4.html b/don4.html
--- a/don4.html
+++ b/don4.html
@@ -9,7 +9,7 @@
 
   $(function() {
 $("#progressbar").progressbar({
-  value: 3.7
+  value: 16.8
});
   });
 
@@ -17,7 +17,7 @@
2nd call:

-   $2959 of $8 (3.7%)
+   $13463 of $8 (16.8%)


 
diff --git a/download.html b/download.html
--- a/download.html
+++ b/download.html
@@ -90,7 +90,7 @@
 https://github.com/squeaky-pl/portable-pypy";>portable Linux 
binaries.
 
 https://bitbucket.org/pypy/pypy/downloads/pypy-2.3.1-linux.tar.bz2";>Linux 
x86 binary (32bit, tar.bz2 built on Ubuntu 10.04.4 LTS) (see [1] below)
-https://bitbucket.org/pypy/pypy/downloads/pypy-2.3.1-linux64.tar.bz2";>Linux
 x86 binary (64bit, tar.bz2 built on Ubuntu 12.04.2 LTS) (see [1] below)
+https://bitbucket.org/pypy/pypy/downloads/pypy-2.3.1-linux64.tar.bz2";>Linux
 x86-64 binary (64bit, tar.bz2 built on Ubuntu 12.04 - 14.04) (see [1] below)
 https://bitbucket.org/pypy/pypy/downloads/pypy-2.3.1-linux-armhf-raspbian.tar.bz2";>ARM
 Hardfloat Linux binary (ARMHF/gnueabihf, tar.bz2, Raspbian) (see [1] below)
 https://bitbucket.org/pypy/pypy/downloads/pypy-2.3.1-linux-armhf-raring.tar.bz2";>ARM
 Hardfloat Linux binary (ARMHF/gnueabihf, tar.bz2, Ubuntu Raring) (see [1] below)
 https://bitbucket.org/pypy/pypy/downloads/pypy-2.3.1-linux-armel.tar.bz2";>ARM
 Softfloat Linux binary (ARMEL/gnueabi, tar.bz2,  Ubuntu Precise) (see [1] below)
@@ -111,8 +111,8 @@
 them unless you're ready to hack your system by adding symlinks to the
 libraries it tries to open.
 
-https://bitbucket.org/pypy/pypy/downloads/pypy3-2.3.1-linux.tar.bz2";>Linux
 binary (32bit, tar.bz2 built on Ubuntu 10.04.4 LTS) (see [1] below)
-https://bitbucket.org/pypy/pypy/downloads/pypy3-2.3.1-linux64.tar.bz2";>Linux
 binary (64bit, tar.bz2 built on Ubuntu 12.04.2 LTS) (see [1] below)
+https://bitbucket.org/pypy/pypy/downloads/pypy3-2.3.1-linux.tar.bz2";>Linux
 x86 binary (32bit, tar.bz2 built on Ubuntu 10.04.4 LTS) (see [1] below)
+https://bitbucket.org/pypy/pypy/downloads/pypy3-2.3.1-linux64.tar.bz2";>Linux
 x86-64 binary (64bit, tar.bz2 built on Ubuntu 12.04 - 14.04) (see [1] below)
 https://bitbucket.org/pypy/pypy/downloads/pypy3-2.3.1-linux-armhf-raspbian.tar.bz2";>ARM
 Hardfloat Linux binary (ARMHF/gnueabihf, tar.bz2, Raspbian) (see [1] below)
 https://bitbucket.org/pypy/pypy/downloads/pypy3-2.3.1-linux-armhf-raring.tar.bz2";>ARM
 Hardfloat Linux binary (ARMHF/gnueabihf, tar.bz2, Ubuntu Raring) (see [1] below)
 https://bitbucket.org/pypy/pypy/downloads/pypy3-2.3.1-linux-armel.tar.bz2";>ARM
 Softfloat Linux binary (ARMEL/gnueabi, tar.bz2,  Ubuntu Precise) (see [1] below)
diff --git a/source/download.txt b/source/download.txt
--- a/source/download.txt
+++ b/source/download.txt
@@ -73,7 +73,7 @@
 .. _`portable Linux binaries`: https://github.com/squeaky-pl/portable-pypy
 
 * `Linux x86 binary (32bit, tar.bz2 built on Ubuntu 10.04.4 LTS)`__ (see 
``[1]`` below)
-* `Linux x86 binary (64bit, tar.bz2 built on Ubuntu 12.04.2 LTS)`__ (see 
``[1]`` below)
+* `Linux x86-64 binary (64bit, tar.bz2 built on Ubuntu 12.04 - 14.04)`__ (see 
``[1]`` below)
 * `ARM Hardfloat Linux binary (ARMHF/gnueabihf, tar.bz2, Raspbian)`__ (see 
``[1]`` below)
 * `ARM Hardfloat Linux binary (ARMHF/gnueabihf, tar.bz2, Ubuntu Raring)`__ 
(see ``[1]`` below)
 * `ARM Softfloat Linux binary (ARMEL/gnueabi, tar.bz2,  Ubuntu Precise)`__ 
(see ``[1]`` below)
@@ -107,8 +107,8 @@
 them** unless you're ready to hack your system by adding symlinks to the
 libraries it tries to open.
 
-* `Linux binary (32bit, tar.bz2 built on Ubuntu 10.04.4 LTS)`__ (see ``[1]`` 
below)
-* `Linux binary (64bit, tar.bz2 built on Ubuntu 12.04.2 LTS)`__ (see ``[1]`` 
below)
+* `Linux x86 binary (32bit, tar.bz2 built on Ubuntu 10.04.4 LTS)`__ (see 
``[1]`` below)
+* `Linux x86-64 binary (64bit, tar.bz2 built on Ubuntu 12.04 - 14.04)`__ (see 
``[1]`` below)
 * `ARM Hardfloat Linux binary (ARMHF/gnueabihf, tar.bz2, Raspbian)`__ (see 
``[1]`` below)
 * `ARM Hardfloat Linux binary (ARMHF/gnueabihf, tar.bz2, Ubuntu Raring)`__ 
(see ``[1]`` below)
 * `ARM Softfloat Linux binary (ARMEL/gnueabi, tar.bz2,  Ubuntu Precise)`__ 
(see ``[1]`` below)
diff --git a/talk/ep2014-status.html b/talk/ep2014-status.html
new file mode 100644

[pypy-commit] pypy.org extradoc: Fixed a few typos

2014-08-08 Thread alex_gaynor
Author: Alex Gaynor 
Branch: extradoc
Changeset: r520:ec3445c33f07
Date: 2014-08-08 16:02 -0700
http://bitbucket.org/pypy/pypy.org/changeset/ec3445c33f07/

Log:Fixed a few typos

diff --git a/numpydonate.html b/numpydonate.html
--- a/numpydonate.html
+++ b/numpydonate.html
@@ -126,7 +126,7 @@
 About estimates and costs
 For each step, we estimated the time that it would take to complete for an
 experienced developer who is already familiar with the PyPy codebase.  From
-this number, the money is calculated considering a hourly rate of $60, and a
+this number, the money is calculated considering an hourly rate of $60, and a
 5% general donation which goes to the http://sfconservancy.org/";>Software Freedom Conservancy itself, the 
non-profit
 organization of which the PyPy project is a member and which manages all the
 issues related to donations, payments, and tax-exempt status.
@@ -158,7 +158,7 @@
 for tight loops
 
 As with all speed improvements, it's relatively hard to predict exactly
-how it'll cope, however we expect the results to be withing an order
+how it'll cope, however we expect the results to be within an order
 of magnitude of handwritten C equivalent.
 Estimated costs: USD$30,000. Estimated duration: 3 months.
 
diff --git a/py3donate.html b/py3donate.html
--- a/py3donate.html
+++ b/py3donate.html
@@ -64,7 +64,7 @@
 continue using Python 2 while others work with Python 3, making it
 harder for everyone.
 The PyPy project is in a unique position in that it could support
-Python 3 without having to discontinue supporting Python 2, with the 
possibility of reusing a large part of of code base and fully
+Python 3 without having to discontinue supporting Python 2, with the 
possibility of reusing a large part of the code base and fully
 reusing its unique translation and JIT-Compiler technologies.
 However, it requires a lot of work, and it will take a long time
 before we can complete a Python 3 port if we only wait for volunteer
@@ -115,7 +115,7 @@
 About estimates and costs
 For each step, we estimated the time that it would take to complete for an
 experienced developer who is already familiar with the PyPy codebase.  From
-this number, the money is calculated considering a hourly rate of $60, and a
+this number, the money is calculated considering an hourly rate of $60, and a
 5% general donation which goes to the http://sfconservancy.org/";>Software Freedom Conservancy itself, the 
non-profit
 association of which the PyPy project is a member and which manages all the
 issues related to donations, taxes and payments.
@@ -255,7 +255,7 @@
 some attention towards implementing Python 3. This will not hinder other
 directions in which PyPy is going like improving performance. The goal
 of the PyPy community is to support both Python 2 and Python 3 for the
-forseeable future.
+foreseeable future.
 PyPy's developers make all PyPy software available to the public without
 charge, under PyPy's Open Source copyright license, the permissive MIT
 License.  PyPy's license assures that PyPy is equally available to
diff --git a/source/numpydonate.txt b/source/numpydonate.txt
--- a/source/numpydonate.txt
+++ b/source/numpydonate.txt
@@ -104,7 +104,7 @@
 
 For each step, we estimated the time that it would take to complete for an
 experienced developer who is already familiar with the PyPy codebase.  From
-this number, the money is calculated considering a hourly rate of $60, and a
+this number, the money is calculated considering an hourly rate of $60, and a
 5% general donation which goes to the `Software Freedom Conservancy`_ itself, 
the non-profit
 organization of which the PyPy project is a member and which manages all the
 issues related to donations, payments, and tax-exempt status.
@@ -145,7 +145,7 @@
 for tight loops
 
   As with all speed improvements, it's relatively hard to predict exactly
-  how it'll cope, however we expect the results to be withing an order
+  how it'll cope, however we expect the results to be within an order
   of magnitude of handwritten C equivalent.
 
   Estimated costs: USD$30,000. Estimated duration: 3 months.
diff --git a/source/py3donate.txt b/source/py3donate.txt
--- a/source/py3donate.txt
+++ b/source/py3donate.txt
@@ -25,7 +25,7 @@
 harder for everyone. 
 
 The PyPy project is in a unique position in that it could support
-Python 3 without having to discontinue supporting Python 2, with the 
possibility of reusing a large part of of code base and fully
+Python 3 without having to discontinue supporting Python 2, with the 
possibility of reusing a large part of the code base and fully
 reusing its unique translation and JIT-Compiler technologies.
 However, it requires a lot of work, and it will take a long time
 before we can complete a Python 3 port if we only wait for volunteer
@@ -89,7 +89,7 @@
 
 For each step, we estimated the time that it would take to complete for an
 experienced developer who is already familiar with the PyPy codebase.  From
-this

[pypy-commit] pypy utf8-unicode2: Explictly check for negative codepoints

2014-08-08 Thread waedt
Author: Tyler Wade 
Branch: utf8-unicode2
Changeset: r72721:3a4bfe6c37ee
Date: 2014-08-08 22:00 -0500
http://bitbucket.org/pypy/pypy/changeset/3a4bfe6c37ee/

Log:Explictly check for negative codepoints

diff --git a/pypy/interpreter/utf8.py b/pypy/interpreter/utf8.py
--- a/pypy/interpreter/utf8.py
+++ b/pypy/interpreter/utf8.py
@@ -642,7 +642,9 @@
 
 
 def append_codepoint(self, c):
-if c < 0x80:
+if c < 0:
+raise ValueError("Invalid unicode codepoint < 0.")
+elif c < 0x80:
 self._builder.append(chr(c))
 elif c < 0x800:
 self._builder.append(chr(0xC0 | (c >> 6)))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy utf8-unicode2: Fix unicode keys in (app-level) dictionaries

2014-08-08 Thread waedt
Author: Tyler Wade 
Branch: utf8-unicode2
Changeset: r72722:a97578376264
Date: 2014-08-08 22:42 -0500
http://bitbucket.org/pypy/pypy/changeset/a97578376264/

Log:Fix unicode keys in (app-level) dictionaries

diff --git a/pypy/interpreter/utf8.py b/pypy/interpreter/utf8.py
--- a/pypy/interpreter/utf8.py
+++ b/pypy/interpreter/utf8.py
@@ -1,6 +1,6 @@
 from rpython.rlib.rstring import StringBuilder
 from rpython.rlib.objectmodel import (
-we_are_translated, specialize, import_from_mixin)
+we_are_translated, specialize, import_from_mixin, compute_hash)
 from rpython.rlib.runicode import utf8_code_length
 from rpython.rlib.unicodedata import unicodedb_5_2_0 as unicodedb
 from rpython.rlib.rarithmetic import r_uint, intmask, base_int
@@ -230,7 +230,7 @@
 return self._len
 
 def __hash__(self):
-return hash(self.bytes)
+return compute_hash(self.bytes)
 
 def __eq__(self, other):
 if isinstance(other, Utf8Str):
diff --git a/pypy/objspace/std/dictmultiobject.py 
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -9,6 +9,7 @@
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import (
 WrappedDefault, applevel, interp2app, unwrap_spec)
+from pypy.interpreter.utf8 import Utf8Str
 from pypy.interpreter.mixedmodule import MixedModule
 from pypy.interpreter.signature import Signature
 from pypy.objspace.std.stdtypedef import StdTypeDef
@@ -1035,7 +1036,6 @@
 
 create_iterator_classes(BytesDictStrategy)
 
-
 class UnicodeDictStrategy(AbstractTypedStrategy, DictStrategy):
 erase, unerase = rerased.new_erasing_pair("unicode")
 erase = staticmethod(erase)
@@ -1052,9 +1052,9 @@
 return space.is_w(space.type(w_obj), space.w_unicode)
 
 def get_empty_storage(self):
-res = {}
-mark_dict_non_null(res)
-return self.erase(res)
+new_dict = r_dict(Utf8Str.__eq__, Utf8Str.__hash__,
+  force_non_null=True)
+return self.erase(new_dict)
 
 def _never_equal_to(self, w_lookup_type):
 return _never_equal_to_string(self.space, w_lookup_type)
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -2,6 +2,7 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.signature import Signature
 from pypy.interpreter.baseobjspace import W_Root
+from pypy.interpreter.utf8 import Utf8Str
 from pypy.objspace.std.bytesobject import W_BytesObject
 from pypy.objspace.std.intobject import W_IntObject
 from pypy.objspace.std.stdtypedef import StdTypeDef
@@ -1250,10 +1251,14 @@
   name='set(unicode).intersect')
 
 def get_empty_storage(self):
-return self.erase({})
+new_dict = r_dict(Utf8Str.__eq__, Utf8Str.__hash__,
+  force_non_null=True)
+return self.erase(new_dict)
 
 def get_empty_dict(self):
-return {}
+new_dict = r_dict(Utf8Str.__eq__, Utf8Str.__hash__,
+  force_non_null=True)
+return new_dict
 
 def listview_unicode(self, w_set):
 return self.unerase(w_set.sstorage).keys()
diff --git a/pypy/objspace/std/test/test_setobject.py 
b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -109,9 +109,9 @@
 w_set = W_SetObject(self.space)
 _initialize_set(self.space, w_set, w_list)
 assert w_set.strategy is self.space.fromcache(UnicodeSetStrategy)
-assert w_set.strategy.unerase(w_set.sstorage) == {Utf8Str("1") :None,
-  Utf8Str("2") :None,
-  Utf8Str("3") :None}
+assert dict(w_set.strategy.unerase(w_set.sstorage)) == {Utf8Str("1") 
:None,
+Utf8Str("2") 
:None,
+Utf8Str("3") 
:None}
 
 w_list = W_ListObject(self.space, [w("1"), w(2), w("3")])
 w_set = W_SetObject(self.space)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: avoid deprecated imp.get_suffixes on >= 3.3

2014-08-08 Thread pjenvey
Author: Philip Jenvey 
Branch: 
Changeset: r1554:7560687dfd75
Date: 2014-07-27 16:20 -0700
http://bitbucket.org/cffi/cffi/changeset/7560687dfd75/

Log:avoid deprecated imp.get_suffixes on >= 3.3

diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -1,7 +1,17 @@
-import sys, os, binascii, imp, shutil
+import sys, os, binascii, shutil
 from . import __version__
 from . import ffiplatform
 
+if sys.version_info >= (3, 3):
+import importlib.machinery
+def extension_suffixes():
+return importlib.machinery.EXTENSION_SUFFIXES[:]
+else:
+import imp
+def extension_suffixes():
+return [suffix for suffix, _, type in imp.get_suffixes()
+if type == imp.C_EXTENSION]
+
 
 class Verifier(object):
 
@@ -222,11 +232,7 @@
 pass
 
 def _get_so_suffixes():
-suffixes = []
-for suffix, mode, type in imp.get_suffixes():
-if type == imp.C_EXTENSION:
-suffixes.append(suffix)
-
+suffixes = extension_suffixes()
 if not suffixes:
 # bah, no C_EXTENSION available.  Occurs on pypy without cpyext
 if sys.platform == 'win32':
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Merged in pjenvey/cffi (pull request #44)

2014-08-08 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r1556:303042482cf7
Date: 2014-08-09 08:44 +0200
http://bitbucket.org/cffi/cffi/changeset/303042482cf7/

Log:Merged in pjenvey/cffi (pull request #44)

avoid deprecated imp.get_suffixes on >= 3.3

diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -1,7 +1,17 @@
-import sys, os, binascii, imp, shutil
+import sys, os, binascii, shutil
 from . import __version__
 from . import ffiplatform
 
+if sys.version_info >= (3, 3):
+import importlib.machinery
+def _extension_suffixes():
+return importlib.machinery.EXTENSION_SUFFIXES[:]
+else:
+import imp
+def _extension_suffixes():
+return [suffix for suffix, _, type in imp.get_suffixes()
+if type == imp.C_EXTENSION]
+
 
 class Verifier(object):
 
@@ -222,11 +232,7 @@
 pass
 
 def _get_so_suffixes():
-suffixes = []
-for suffix, mode, type in imp.get_suffixes():
-if type == imp.C_EXTENSION:
-suffixes.append(suffix)
-
+suffixes = _extension_suffixes()
 if not suffixes:
 # bah, no C_EXTENSION available.  Occurs on pypy without cpyext
 if sys.platform == 'win32':
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: make this not public

2014-08-08 Thread pjenvey
Author: Philip Jenvey 
Branch: 
Changeset: r1555:dfdc10d75879
Date: 2014-07-28 09:51 -0700
http://bitbucket.org/cffi/cffi/changeset/dfdc10d75879/

Log:make this not public

diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -4,11 +4,11 @@
 
 if sys.version_info >= (3, 3):
 import importlib.machinery
-def extension_suffixes():
+def _extension_suffixes():
 return importlib.machinery.EXTENSION_SUFFIXES[:]
 else:
 import imp
-def extension_suffixes():
+def _extension_suffixes():
 return [suffix for suffix, _, type in imp.get_suffixes()
 if type == imp.C_EXTENSION]
 
@@ -232,7 +232,7 @@
 pass
 
 def _get_so_suffixes():
-suffixes = extension_suffixes()
+suffixes = _extension_suffixes()
 if not suffixes:
 # bah, no C_EXTENSION available.  Occurs on pypy without cpyext
 if sys.platform == 'win32':
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy utf8-unicode2: Fix mismatch between translated and untranslated behavior

2014-08-08 Thread waedt
Author: Tyler Wade 
Branch: utf8-unicode2
Changeset: r72723:d124ea9a7f3a
Date: 2014-08-09 00:37 -0500
http://bitbucket.org/pypy/pypy/changeset/d124ea9a7f3a/

Log:Fix mismatch between translated and untranslated behavior

diff --git a/pypy/interpreter/utf8.py b/pypy/interpreter/utf8.py
--- a/pypy/interpreter/utf8.py
+++ b/pypy/interpreter/utf8.py
@@ -229,6 +229,10 @@
 assert self._len >= 0
 return self._len
 
+def __bool__(self):
+# XXX Make the untranslated behavior the same as the translated 
behavior
+raise True
+
 def __hash__(self):
 return compute_hash(self.bytes)
 
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -372,9 +372,10 @@
 newline = None
 else:
 newline = space.unicode_w(w_newline)
-if newline and not (utf8.EQ(newline, Utf8Str('\n')) or
-utf8.EQ(newline, Utf8Str('\r\n')) or
-utf8.EQ(newline, Utf8Str('\r'))):
+if (newline is not None and len(newline) > 0 and
+not (utf8.EQ(newline, Utf8Str('\n')) or
+ utf8.EQ(newline, Utf8Str('\r\n')) or
+ utf8.EQ(newline, Utf8Str('\r':
 r = space.str_w(space.repr(w_newline))
 raise OperationError(space.w_ValueError, space.wrap(
 "illegal newline value: %s" % (r,)))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy utf8-unicode2: Fix error handling in unicode_internal codec

2014-08-08 Thread waedt
Author: Tyler Wade 
Branch: utf8-unicode2
Changeset: r72725:36fc05030a2a
Date: 2014-08-09 01:45 -0500
http://bitbucket.org/pypy/pypy/changeset/36fc05030a2a/

Log:Fix error handling in unicode_internal codec

diff --git a/pypy/interpreter/utf8_codecs.py b/pypy/interpreter/utf8_codecs.py
--- a/pypy/interpreter/utf8_codecs.py
+++ b/pypy/interpreter/utf8_codecs.py
@@ -1351,12 +1351,8 @@
 
 def str_decode_unicode_internal(s, size, errors, final=False,
 errorhandler=None):
-if BYTEORDER == 'little':
-result, length, byteorder = str_decode_utf_32_helper(
-s, size, errors, final, errorhandler, "little", "unicode_internal")
-else:
-result, length, byteorder = str_decode_utf_32_helper(
-s, size, errors, final, errorhandler, "internal", 
"unicode_internal")
+result, length = str_decode_unicode_internal_helper(
+s, size, errors, final, errorhandler)
 return result, length
 
 def unicode_encode_unicode_internal(s, size, errors, errorhandler=None):
@@ -1365,6 +1361,46 @@
 else:
 return unicode_encode_utf_32_be(s, size, errors, errorhandler)
 
+def str_decode_unicode_internal_helper(s, size, errors, final=True,
+   errorhandler=None):
+if errorhandler is None:
+errorhandler = default_unicode_error_decode
+
+if BYTEORDER == 'little':
+iorder = [0, 1, 2, 3]
+else:
+iorder = [3, 2, 1, 0]
+
+if size == 0:
+return Utf8Str(''), 0
+
+pos = 0
+result = Utf8Builder(size // 4)
+
+while pos < size:
+# remaining bytes at the end? (size should be divisible by 4)
+if len(s) - pos < 4:
+if not final:
+break
+r, pos = errorhandler(errors, "unicode_internal", "truncated data",
+  s, pos, len(s))
+result.append_utf8(r)
+if len(s) - pos < 4:
+break
+continue
+ch = ((ord(s[pos + iorder[3]]) << 24) | (ord(s[pos + iorder[2]]) << 
16) |
+  (ord(s[pos + iorder[1]]) << 8)  | ord(s[pos + iorder[0]]))
+if ch >= 0x11:
+r, pos = errorhandler(errors, "unicode_internal",
+  "codepoint not in range(0x11)",
+  s, pos, pos + 4)
+result.append_utf8(r)
+continue
+
+result.append_codepoint(ch)
+pos += 4
+return result.build(), pos
+
 # }}}
 
 # 
diff --git a/pypy/module/_codecs/test/test_codecs.py 
b/pypy/module/_codecs/test/test_codecs.py
--- a/pypy/module/_codecs/test/test_codecs.py
+++ b/pypy/module/_codecs/test/test_codecs.py
@@ -727,3 +727,12 @@
 _codecs.register_error("test.test_codecs_not_a_string", f)
 raises(TypeError, u'\u1234'.encode, 'ascii',
'test.test_codecs_not_a_string')
+
+def test_decode_callback(self):
+import codecs
+codecs.register_error("UnicodeInternalTest", codecs.ignore_errors)
+decoder = codecs.getdecoder("unicode_internal")
+ab = u"ab".encode("unicode_internal")
+ignored = decoder("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]),
+"UnicodeInternalTest")
+assert (u"ab", 12) == ignored
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy utf8-unicode2: Attempt to fix some translated test failures

2014-08-08 Thread waedt
Author: Tyler Wade 
Branch: utf8-unicode2
Changeset: r72724:d2ab58ed2eed
Date: 2014-08-09 01:45 -0500
http://bitbucket.org/pypy/pypy/changeset/d2ab58ed2eed/

Log:Attempt to fix some translated test failures

diff --git a/pypy/interpreter/utf8.py b/pypy/interpreter/utf8.py
--- a/pypy/interpreter/utf8.py
+++ b/pypy/interpreter/utf8.py
@@ -8,13 +8,13 @@
 from rpython.tool.sourcetools import func_with_new_name
 
 
-wchar_rint = rffi.r_uint
-WCHAR_INTP = rffi.UINTP
-WCHAR_INT = rffi.UINT
+wchar_rint = rffi.r_int
+WCHAR_INTP = rffi.INTP
+WCHAR_INT = rffi.INT
 if rffi.sizeof(rffi.WCHAR_T) == 2:
-wchar_rint = rffi.r_ushort
-WCHAR_INTP = rffi.USHORTP
-WCHAR_INT = rffi.USHORT
+wchar_rint = rffi.r_short
+WCHAR_INTP = rffi.SHORTP
+WCHAR_INT = rffi.SHORT
 
 
 def utf8chr(value):
@@ -27,6 +27,8 @@
 def utf8ord_bytes(bytes, start):
 codepoint_length = utf8_code_length[ord(bytes[start])]
 
+assert codepoint_length != 0, "byte index isn't the start of a character"
+
 if codepoint_length == 1:
 res = ord(bytes[start])
 
@@ -168,6 +170,9 @@
 return pos
 
 def __getitem__(self, char_pos):
+if not isinstance(char_pos, int):
+raise TyperError("string index must be an integer, not %r" %
+  type(char_pos))
 # This if statement is needed for [-1:0] to slice correctly
 if char_pos >= self._len:
 raise IndexError()
@@ -222,9 +227,16 @@
 return Utf8Str(self.bytes + other.bytes,
self._is_ascii and other._is_ascii)
 
+def __radd__(self, other):
+return Utf8Str(other.bytes + self.bytes,
+   self._is_ascii and other._is_ascii)
+
 def __mul__(self, count):
 return Utf8Str(self.bytes * count, self._is_ascii)
 
+def __rmul__(self, count):
+return Utf8Str(count * self.bytes, self._is_ascii)
+
 def __len__(self):
 assert self._len >= 0
 return self._len
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit