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

strptime gives TypeError: __import__() takes at most 4 arguments (5 given) #37

Open
martior opened this issue Jun 12, 2017 · 6 comments

Comments

@martior
Copy link

martior commented Jun 12, 2017

I have the following code in a BASIC element

test_date = context.modules.datetime.datetime.now().strftime("%Y-%m-%d")
context.modules.datetime.datetime.strptime(test_date,"%Y-%m-%d" )

this gives the following error

2017-06-12 14:50:32 ERROR Rapido Rapido execution error - cafemenu
File "menuedit.py", line 10, in next_weeks
TypeError: __import__() takes at most 4 arguments (5 given)

Line 10 is the last line in the first code block.

The same code in pure python 2.7 works fine

>>> import datetime
>>> test_date = datetime.datetime.now().strftime("%Y-%m-%d")
>>> datetime.datetime.strptime(test_date,"%Y-%m-%d" )
@ebrehault
Copy link
Member

what is your line 10? (the first or the second you have pasted?)

@martior
Copy link
Author

martior commented Jun 14, 2017

Last one.

@ebrehault
Copy link
Member

That's super strange, it means the first call to datetime works but not the second one.
Could you try this:

datetime = context.modules.datetime.datetime
test_date = datetime.now().strftime("%Y-%m-%d")
datetime.strptime(test_date,"%Y-%m-%d" )

@martior
Copy link
Author

martior commented Jun 14, 2017

I did try something very similar having datetime defined in a variable like that and got the same error. Will try again . But my testing shows it is the strptime call that fails. Calling strptime with only one parameter works as far as you get the normal error from strptime about number of parameters having to be two.

@ebrehault
Copy link
Member

This is really making no sense.
FYI I am about to release a new version based on PythonScripts instead of zope.unrestrictedpython (for security reasons), and it might have an impact on external modules.

@martior
Copy link
Author

martior commented Jun 15, 2017

nope, no sense at all, that is why I created the ticket :-P

let me know when it is released and I can test again. No point hunting down these kind of bugs if we are replacing the source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants