Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'float' object cannot be interpreted as an integer #38

Closed
WuShell opened this issue Jun 15, 2022 · 2 comments
Closed

TypeError: 'float' object cannot be interpreted as an integer #38

WuShell opened this issue Jun 15, 2022 · 2 comments
Labels

Comments

@WuShell
Copy link

WuShell commented Jun 15, 2022

BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

What I did:

Upgrade a development env that was working just fine in python 3.9.x to 3.10.4 then ran tests on my code base (pyramid web app that uses traversal, ZODB and some zope libs)

What I expect to happen:

Tests to pass, code to run as it ran with 3.9

What actually happened:

Whenever I have to query the catalog, an exception is raised. This is an example on a test failure:

Traceback (most recent call last):                                                                                                                                                                                                      
  File "/usr/local/lib/python3.10/doctest.py", line 1346, in __run                                                                                                                                                                      
    exec(compile(example.source, filename, "single",                                                                                                                                                                                    
  File "<doctest migrations.31.migrate[33]>", line 2, in <module>                                                                                                                                                            
  File "/home/wu/REPO/models/scan.py", line 141, in search                                                                                                                        
    res = self.query(                                                                                                                                                                                                                   
  File "/home/wu/REPO/catalog.py", line 208, in query                                                                                                                             
    number, results = catalog.query(query, reverse=reverse)                                                                                                                                                                             
  File "/home/wu/ENVS/3.10/lib/python3.10/site-packages/repoze/catalog/catalog.py", line 153, in query                                                                                                   
    results = queryobject._apply(self, names)                                                                                                                                                                                           
  File "/home/wu/ENVS/3.10/lib/python3.10/site-packages/repoze/catalog/query.py", line 95, in _apply                                                                                                     
    return index.applyContains(self._get_value(names))                                                                                                                                                                                  
  File "/home/wu/ENVS/3.10/lib/python3.10/site-packages/repoze/catalog/indexes/text.py", line 74, in applyContains                                                                                       
    return self.apply(value)                                                                                                                                                                                                            
  File "/home/wu/ENVS/3.10/lib/python3.10/site-packages/zope/index/text/textindex.py", line 73, in apply                                                                                                 
    results = tree.executeQuery(self.index)  
  File "/home/wu/ENVS/3.10/lib/python3.10/site-packages/zope/index/text/parsetree.py", line 123, in executeQuery                                                                                         
    return index.search_phrase(self.getValue())                                                                     
  File "/home/wu/ENVS/3.10/lib/python3.10/site-packages/zope/index/text/baseindex.py", line 203, in search_phrase
    scores = self._search_wids(wids)                                                                                                                                                                                                    
  File "/home/wu/ENVS/3.10/lib/python3.10/site-packages/zope/index/text/okapiindex.py", line 347, in _c_search_wids
    score(result, items, docid2len, idf, meandoclen)
TypeError: 'float' object cannot be interpreted as an integer

What version of Python and Zope/Addons I am using:

  • FreeBSD 13.1

  • Python 3.10.4

pyramid              1.10.8
pyramid-debugtoolbar 4.9   
pyramid-jinja2       2.10       
pyramid-ldap3        0.5   
pyramid-mailer       0.15.1
pyramid-mako         1.1.0
pyramid-retry        2.1.1                                                                                          
pyramid-tm           2.5  
pyramid-zodbconn     0.8.1
zc.lockfile          2.0
ZConfig              3.6.0
zdaemon              4.3
ZEO                  5.3.0
ZODB                 5.7.0
ZODB3                3.11.0
zodbpickle           2.3
zodburi              2.5.0
zope.component       5.0.1
zope.deprecation     4.4.0
zope.event           4.5.0
zope.hookable        5.1.0
zope.index           5.1.0
zope.interface       5.4.0

More info/research.

Looking a bit at the 3.10.x changelog (https://docs.python.org/3/whatsnew/3.10.html) There is this point here:

Builtin and extension functions that take integer arguments no longer accept Decimals, Fractions and other objects that can be converted to integers only with a loss (e.g. that have the int() method but do not have the index() method). (Contributed by Serhiy Storchaka in bpo-37999.)

Which points to this bugfix: python/cpython#82180

Maybe that is causing this behaviour?

@icemac
Copy link
Member

icemac commented Jun 24, 2022

@WuShell Hi, you are using zope.index version which does not support Python 3.10. Please update to version 5.2.0 and report back whether this fixes your problem.

@icemac icemac added the invalid label Jan 29, 2024
@icemac
Copy link
Member

icemac commented Jan 29, 2024

I am closing this old issue. Feel free to re-open it if there are any news about the topic.

@icemac icemac closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants