Opened 5 years ago

Closed 4 years ago

#543 closed defect (fixed)

cython-closures has Py3 issues

Reported by: scoder Owned by: haoyu
Priority: major Milestone: 0.13
Component: Python 3.0 Keywords:
Cc: biahaoyu@…

Description

See:

https://sage.math.washington.edu:8091/hudson/view/cython-closures/job/cython-closures-tests-py3k-c/

Traceback (most recent call last):
  File "/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/python/lib/python3.2/doctest.py", line 2104, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for closure_decorators_T478
  File "/mnt/usb1/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/BUILD/run/c/closure_decorators_T478.so", line 1, in closure_decorators_T478

----------------------------------------------------------------------
File "/mnt/usb1/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/BUILD/run/c/closure_decorators_T478.so", line 3, in closure_decorators_T478
Failed example:
    Num(13).is_prime()
Exception raised:
    Traceback (most recent call last):
      File "/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/python/lib/python3.2/doctest.py", line 1244, in __run
        compileflags, 1), test.globs)
      File "<doctest closure_decorators_T478[0]>", line 1, in <module>
        Num(13).is_prime()
      File "closure_decorators_T478.pyx", line 17, in closure_decorators_T478.print_args.f (closure_decorators_T478.c:520)
    TypeError: descriptor 'is_prime' of 'closure_decorators_T478.Num' object needs an argument
----------------------------------------------------------------------
File "/mnt/usb1/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/BUILD/run/c/closure_decorators_T478.so", line 6, in closure_decorators_T478
Failed example:
    Num(13).is_prime(True)
Exception raised:
    Traceback (most recent call last):
      File "/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/python/lib/python3.2/doctest.py", line 1244, in __run
        compileflags, 1), test.globs)
      File "<doctest closure_decorators_T478[1]>", line 1, in <module>
        Num(13).is_prime(True)
      File "closure_decorators_T478.pyx", line 17, in closure_decorators_T478.print_args.f (closure_decorators_T478.c:520)
    TypeError: descriptor 'is_prime' requires a 'closure_decorators_T478.Num' object but received a 'bool'
----------------------------------------------------------------------
File "/mnt/usb1/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/BUILD/run/c/closure_decorators_T478.so", line 9, in closure_decorators_T478
Failed example:
    Num(15).is_prime(print_factors=True)
Exception raised:
    Traceback (most recent call last):
      File "/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/python/lib/python3.2/doctest.py", line 1244, in __run
        compileflags, 1), test.globs)
      File "<doctest closure_decorators_T478[2]>", line 1, in <module>
        Num(15).is_prime(print_factors=True)
      File "closure_decorators_T478.pyx", line 17, in closure_decorators_T478.print_args.f (closure_decorators_T478.c:520)
    TypeError: descriptor 'is_prime' of 'closure_decorators_T478.Num' object needs an argument

and:

Traceback (most recent call last):
  File "/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/python/lib/python3.2/doctest.py", line 2104, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for function_binding_T494.__test__.add_to_func (line 12)
  File "/mnt/usb1/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/BUILD/run/c/function_binding_T494.so", line unknown line number, in add_to_func (line 12)

----------------------------------------------------------------------
File "/mnt/usb1/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/BUILD/run/c/function_binding_T494.so", line ?, in function_binding_T494.__test__.add_to_func (line 12)
Failed example:
    SomeNumber(3).add_to(10)
Exception raised:
    Traceback (most recent call last):
      File "/scratch/hudson/jobs/cython-closures-tests-py3k-c/workspace/python/lib/python3.2/doctest.py", line 1244, in __run
        compileflags, 1), test.globs)
      File "<doctest function_binding_T494.__test__.add_to_func (line 12)[1]>", line 1, in <module>
      File "function_binding_T494.pyx", line 12, in function_binding_T494.add_to_func (function_binding_T494.c:606)
    TypeError: add_to_func() takes exactly 2 positional arguments (1 given)

Change History (3)

comment:1 Changed 4 years ago by haoyu

  • Cc biahaoyu@… added

The following patch should fix this:

diff -r d77e3f839dd6 Cython/Compiler/ModuleNode.py
--- a/Cython/Compiler/ModuleNode.py	Fri Jun 25 22:26:46 2010 +0800
+++ b/Cython/Compiler/ModuleNode.py	Sun Jun 27 16:37:05 2010 +0800
@@ -583,7 +583,7 @@
 
         code.put("""
 #if PY_MAJOR_VERSION >= 3
-  #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
+  #define PyMethod_New(func, self, klass) (self ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
 #endif
 
 #if PY_VERSION_HEX < 0x02050000

comment:2 Changed 4 years ago by scoder

  • Owner changed from somebody to haoyu

Applied here:

http://hg.cython.org/cython-closures/rev/1a4c9ca9edde

Fixes both test failures for me.

comment:3 Changed 4 years ago by scoder

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.