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

Update to python 3 #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

JamesWrigley
Copy link

Hi there,
I got some errors when I tried to use pyrc with a python 3 project, so I made a few changes for it to work with python 3. Though it probably breaks backward compatibility with python 2, so I dunno if you'd want to merge it.

Anyway, no pressure, just thought I'd put it out there :)

@wei2912 wei2912 mentioned this pull request Dec 13, 2014
pyrc/bots.py Outdated
@@ -131,7 +132,7 @@ def parsefuncs(self, target, sender, message, funcs):

if group_dict and (len(groups) > len(group_dict)):
# match.groups() also returns named parameters
raise "You cannot use both named and unnamed parameters"
raise IOError("You cannot use both named and unnamed parameters")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe TypeError or ValueError would be better here?

pyrc/bots.py Outdated
@@ -95,8 +96,8 @@ def run_listeners(self, line):
callback(*match.groups())

def addhooks(self):
for func in self.__class__.__dict__.values():
if callable(func) and hasattr(func, '_type'):
for func in list(self.__class__.__dict__.values()):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for func in vars(self.__class__).values(): would work.

pyrc/bots.py Outdated
@@ -5,7 +5,8 @@
import re
import os

import threads
from . import threads
import collections

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: PEP8 would put collections in the group above.

Reorder imports, use vars(), and throw a TypeError instead of an IOError when
the user passes in named and unnamed parameters.
@JamesWrigley
Copy link
Author

One sec, fixing the conflicts now.

Note: now we use func.__name__ instead of func.func_name in hooks.py.
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

Successfully merging this pull request may close these issues.

2 participants